Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Feb 2009 18:20:07 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 157045 for review
Message-ID:  <200902021820.n12IK7xf046362@repoman.freebsd.org>

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

Change 157045 by gabor@gabor_server on 2009/02/02 18:19:49

	- wchar-safe check()
	- wchar-safe -i
	- Restore -B

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/diff/diffreg.c#11 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/diff/diffreg.c#11 (text+ko) ====

@@ -748,11 +748,11 @@
 static void
 check(char *file1, FILE *f1, char *file2, FILE *f2)
 {
-	int	 i, j, jackpot, c, d;
+	int	 i, j, jackpot, a, b;
+	wint_t	 c, d;
 	long	 ctold, ctnew;
-	char	*strc, *strd;
+	wchar_t	*strc, *strd;
 	size_t	 lenc, lend;
-	int	 a, b;
 
 	rewind(f1);
 	rewind(f2);
@@ -770,20 +770,22 @@
 			j++;
 		}
 
-		strc = fgetln(f1, &lenc);
-		strd = fgetln(f2, &lend);
+		strc = fgetwln(f1, &lenc);
+		strd = fgetwln(f2, &lend);
+
+		if (Bflag) {
+			while ((lenc = 1) && (strc[0] == L'\n'))
+				strc = fgetwln(f1, &lenc);
+			while ((lend = 1) && (strd[0] == L'\n'))
+				strd = fgetwln(f2, &lend);
+		}
 
-/*		if (!bflag && !Bflag && !wflag && !iflag &&
-		    !strip_cr && (strcmp(strc, strd) != 0)) {
-			J[i] = 0;
-			ctold += lenc;
-			ctnew += lend;
-			ixold[i] = ctold;
-			ixnew[j] = ctnew;
-			j++;
-			break;
+		if (iflag) {
+			for (a = 0; a < lenc; a++)
+				strc[a] = towlower(strc[a]);
+			for (b = 0; b < lend; b++)
+				strd[b] = towlower(strd[b]);
 		}
-*/
 
 		for (a = b = 0; (a < lenc) && (b < lend); a++, b++) {
 			c = strc[a];
@@ -793,38 +795,38 @@
 			 * in one file if bflag || wflag.
 			 */
 			if ((bflag || wflag) &&
-			    ((c == EOF && d == '\n') ||
-			    (c == '\n' && d == EOF))) {
+			    ((c == EOF && d == L'\n') ||
+			    (c == L'\n' && d == EOF))) {
 				break;
 			}
 
 			ctold++;
 			ctnew++;
-			while ((strip_cr) && (c == '\r') && (d == '\n'))
+			while ((strip_cr) && (c == L'\r') && (d == L'\n'))
 				c = strc[++a];
-			while ((strip_cr) && (d == '\r') && (c == '\n'))
+			while ((strip_cr) && (d == L'\r') && (c == L'\n'))
 				d = strd[++b];
 			if (wflag) {
-				while (isspace(c) && c != '\n') {
+				while (isspace(c) && c != L'\n') {
 					c = strc[++a];
 					ctold++;
 				}
-				while (isspace(d) && d != '\n') {
+				while (isspace(d) && d != L'\n') {
 					d = strd[++b];
 					ctnew++;
 				}
 			}
 
-			if (chrtran[c] != chrtran[d]) {
+			if (c != d) {
 //				jackpot++;
 				J[i] = 0;
-				if (c != '\n' && c != EOF)
+				if (c != L'\n' && c != EOF)
 					ctold += lenc - a + 1;
-				if (d != '\n' && c != EOF)
+				if (d != L'\n' && c != EOF)
 					ctnew += lend - b + 1;
 				break;
 			}
-			if (c == '\n' || c == EOF)
+			if (c == L'\n' || c == EOF)
 				break;
 		}
 		ixold[i] = ctold;



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