PERFORCE change 159037 for review
Gabor Kovesdan
gabor at FreeBSD.org
Tue Mar 10 16:01:22 PDT 2009
http://perforce.freebsd.org/chv.cgi?CH=159037
Change 159037 by gabor at gabor_server on 2009/03/10 23:01:18
- Fix EOF handling
Thanks to: ed, delphij, James Bailie <jimmy at 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);
More information about the p4-projects
mailing list