mlmmj

changeset 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 diff
     1.1 --- a/src/mygetline.c	Fri Oct 29 22:25:56 2010 +1100
     1.2 +++ b/src/mygetline.c	Mon Nov 01 08:31:08 2010 +1100
     1.3 @@ -26,11 +26,12 @@
     1.4  #include <string.h>
     1.5  #include <unistd.h>
     1.6  #include <errno.h>
     1.7 +#include <stdio.h>
     1.8  
     1.9  #include "mygetline.h"
    1.10  #include "memory.h"
    1.11  
    1.12 -static char *mygetuntil(int fd, char eof)
    1.13 +static char *mygetuntil(int fd, int eof)
    1.14  {
    1.15  	size_t i = 0, res, buf_size = BUFSIZE;  /* initial buffer size */
    1.16  	char *buf, ch;
    1.17 @@ -62,7 +63,7 @@
    1.18  			buf = myrealloc(buf, buf_size);
    1.19  		}
    1.20  		buf[i++] = ch;
    1.21 -		if(ch == eof) {
    1.22 +		if(eof != EOF && ch == eof) {
    1.23  			buf[i] = '\0';
    1.24  			return buf;
    1.25  		}
    1.26 @@ -76,5 +77,5 @@
    1.27  
    1.28  char *mygetcontent(int fd)
    1.29  {
    1.30 -	return mygetuntil(fd, '\0');
    1.31 +	return mygetuntil(fd, EOF);
    1.32  }