PERFORCE change 145723 for review

Gabor Kovesdan gabor at FreeBSD.org
Wed Jul 23 16:07:05 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=145723

Change 145723 by gabor at 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];


More information about the p4-projects mailing list