Mercurial > hg > mlmmj
changeset 771:5bab557020a6
More readable interface to mygetuntil() when reading to EOF
author | Ben Schmidt |
---|---|
date | Mon, 01 Nov 2010 08:31:08 +1100 |
parents | b9b60f3dd694 |
children | 179d5a0ed686 |
files | src/mygetline.c |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mygetline.c Fri Oct 29 22:25:56 2010 +1100 +++ b/src/mygetline.c Mon Nov 01 08:31:08 2010 +1100 @@ -26,11 +26,12 @@ #include <string.h> #include <unistd.h> #include <errno.h> +#include <stdio.h> #include "mygetline.h" #include "memory.h" -static char *mygetuntil(int fd, char eof) +static char *mygetuntil(int fd, int eof) { size_t i = 0, res, buf_size = BUFSIZE; /* initial buffer size */ char *buf, ch; @@ -62,7 +63,7 @@ buf = myrealloc(buf, buf_size); } buf[i++] = ch; - if(ch == eof) { + if(eof != EOF && ch == eof) { buf[i] = '\0'; return buf; } @@ -76,5 +77,5 @@ char *mygetcontent(int fd) { - return mygetuntil(fd, '\0'); + return mygetuntil(fd, EOF); }