Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2008 10:45:05 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 144083 for review
Message-ID:  <200806251045.m5PAj5l6073238@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144083

Change 144083 by gabor@gabor_server on 2008/06/25 10:44:04

	- Check EILSEQ when dealing with wide chars and return 1, when
	  EILSEQ is triggered.
	
	  Suggested by:	ache

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/file.c#12 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/grep/file.c#12 (text+ko) ====

@@ -38,6 +38,7 @@
 
 #include <bzlib.h>
 #include <err.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -65,8 +66,12 @@
 	if (fseek(f->f, 0L, SEEK_SET) == -1)
 		return (0);
 
-	for (i = 0; (i <= BUFSIZ) && (ch != WEOF); i++) {
-		ch = fgetwc(f->f);
+	for (i = 0; i <= BUFSIZ; i++) {
+		if ((ch = fgetwc(f->f)) == WEOF) {
+			if (errno == EILSEQ)
+				ret = 1;
+			break;
+		}
 		if (iswbinary(ch)) {
 			ret = 1;
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806251045.m5PAj5l6073238>