Date: Wed, 23 Jul 2008 16:07:04 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 145723 for review Message-ID: <200807231607.m6NG74jo015667@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=145723 Change 145723 by gabor@gabor_server on 2008/07/23 16:06:30 - Really fix the off-by-ones and hangs Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/file.c#27 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/file.c#27 (text+ko) ==== @@ -128,11 +128,7 @@ if (binbufptr == NULL) { /* Only pre-read to the buffer if we need the binary check. */ if (binbehave != BINFILE_TEXT) { - for (; i < (BUFSIZ * sizeof(wint_t)); i++) { - if (grep_feof(f)) { - i--; - break; - } + for (; (i < (BUFSIZ * sizeof(wint_t))) && !grep_feof(f); i++) { ch = grep_fgetc(f); binbuf[i] = ch; } @@ -156,10 +152,8 @@ } /* Read a line whether from the buffer or from the file itself. */ - for (i = 0; ; i++) { + for (i = 0; !grep_feof(f); i++) { if (binbufptr == &binbuf[binbufsiz]) { - if (grep_feof(f)) - break; ch = grep_fgetc(f); } else { ch = binbufptr[0];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807231607.m6NG74jo015667>