Date: Tue, 10 Mar 2009 23:01:20 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 159037 for review Message-ID: <200903102301.n2AN1KpR016618@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=159037 Change 159037 by gabor@gabor_server on 2009/03/10 23:01:18 - Fix EOF handling Thanks to: ed, delphij, James Bailie <jimmy@mammothcheese.ca> Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/file.c#41 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.h#46 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/file.c#41 (text+ko) ==== @@ -60,9 +60,9 @@ /* Some global variable for the buffering and reading. */ static char *lnbuf; static size_t lnbuflen; -static char *binbuf; +static unsigned char *binbuf; static int binbufsiz; -char *binbufptr; +unsigned char *binbufptr; static int bzerr; #define iswbinary(ch) (!iswspace((ch)) && iswcntrl((ch)) && (ch != L'\b') && (ch != L'\0')) @@ -74,7 +74,7 @@ int grep_fgetc(struct file *f) { - char c; + int c; switch (filebehave) { case FILE_STDIO: @@ -141,8 +141,13 @@ binbuf = grep_malloc(sizeof(char) * bufsiz); - for (; i < bufsiz && !grep_feof(f); i++) - binbuf[i] = grep_fgetc(f); + while (i < bufsiz) { + ch = grep_fgetc(f); + if (ch == EOF) + break; + binbuf[i++] = ch; + } + f->binary = memchr(binbuf, (filebehave != FILE_GZIP) ? '\0' : '\200', i - 1) != 0; } binbufsiz = i; ==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#46 (text+ko) ==== @@ -144,7 +144,7 @@ void clearqueue(void); /* file.c */ -char *binbufptr; +unsigned char *binbufptr; void grep_close(struct file *f); struct file *grep_stdin_open(void);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903102301.n2AN1KpR016618>