Date: Thu, 25 Dec 2008 04:54:26 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 155261 for review Message-ID: <200812250454.mBP4sQ6J056005@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=155261 Change 155261 by gabor@gabor_server on 2008/12/25 04:54:25 - Some simplifications Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/file.c#35 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/file.c#35 (text+ko) ==== @@ -124,13 +124,8 @@ if (binbufptr == NULL) { /* Only pre-read to the buffer if we need the binary check. */ if (binbehave != BINFILE_TEXT) { - for (; i < sizeof(binbuf) && !grep_feof(f); i++) { - ch = grep_fgetc(f); - if (ch != EOF) - binbuf[i] = ch; - else - break; - } + for (; i < sizeof(binbuf) && !grep_feof(f); i++) + binbuf[i] = grep_fgetc(f); f->binary = memchr(binbuf, (filebehave != FILE_GZIP) ? '\0' : '\200', i - 1) != 0; } binbufsiz = i; @@ -149,14 +144,11 @@ lnbuflen *= 2; lnbuf = grep_realloc(lnbuf, ++lnbuflen); } - if (ch == '\n') { + if ((ch == '\n') || (ch == EOF)) { lnbuf[i] = '\0'; break; - } - if (ch != EOF) + } else lnbuf[i] = ch; - else - break; } if (grep_feof(f) && (i == 0) && (ch != '\n')) return (NULL);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812250454.mBP4sQ6J056005>