Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2008 14:14:16 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 149662 for review
Message-ID:  <200809121414.m8CEEGpY099717@repoman.freebsd.org>

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

Change 149662 by gabor@gabor_server on 2008/09/12 14:13:41

	- Eliminate some widechar-incompatible parts.  The -i fixed string
	  search is not 100% correct yet, and there are other snippets
	  to fix.
	
	Reported by:	ache

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#9 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#9 (text+ko) ====

@@ -61,31 +61,13 @@
 	fg->eol = 0;
 	fg->reversed = 0;
 
-	/*
-	 * Make a copy and upper case it for later if in -i mode,
-	 * else just copy the pointer.
-	 */
-	if (iflag) {
-		fg->pattern = grep_malloc(fg->len + 1);
-		for (i = 0; i < fg->len; i++)
-			fg->pattern[i] = toupper(pattern[i]);
-		fg->pattern[fg->len] = '\0';
-	} else
-		fg->pattern = (unsigned char *)pattern;	/* really const */
+	fg->pattern = (unsigned char *)pattern;	/* really const */
 
 	/* Preprocess pattern. */
 	for (i = 0; i <= UCHAR_MAX; i++)
 		fg->qsBc[i] = fg->len;
-	for (i = 1; i < fg->len; i++) {
+	for (i = 1; i < fg->len; i++)
 		fg->qsBc[fg->pattern[i]] = fg->len - i;
-		/*
-		 * If case is ignored, make the jump apply to both upper and
-		 * lower cased characters.  As the pattern is stored in upper
-		 * case, apply the same to the lower case equivalents.
-		 */
-		if (iflag)
-			fg->qsBc[tolower(fg->pattern[i])] = fg->len - i;
-	}
 }
 
 /*
@@ -144,14 +126,7 @@
 	for (i = 0; i < fg->len; i++)
 	{
 		/* Can still cheat? */
-		if ((isalnum(fg->pattern[i])) || isspace(fg->pattern[i]) ||
-		    (fg->pattern[i] == '_') || (fg->pattern[i] == ',') ||
-		    (fg->pattern[i] == '=') || (fg->pattern[i] == '-') ||
-		    (fg->pattern[i] == ':') || (fg->pattern[i] == '/')) {
-			/* As long as it is good, upper case it for later. */
-			if (iflag)
-				fg->pattern[i] = toupper(fg->pattern[i]);
-		} else if (fg->pattern[i] == '.') {
+		if (fg->pattern[i] == '.') {
 			hasDot = i;
 			if (i < fg->len / 2) {
 				if (firstHalfDot < 0)
@@ -211,13 +186,6 @@
 		fg->qsBc[i] = shiftPatternLen;
 	for (i = hasDot + 1; i < fg->len; i++) {
 		fg->qsBc[fg->pattern[i]] = fg->len - i;
-		/*
-		 * If case is ignored, make the jump apply to both upper and
-		 * lower cased characters.  As the pattern is stored in upper
-		 * case, apply the same to the lower case equivalents.
-		 */
-		if (iflag)
-			fg->qsBc[tolower(fg->pattern[i])] = fg->len - i;
 	}
 
 	/*
@@ -316,7 +284,7 @@
 
 	for (i = 0; i < len; i++) {
 		if (((pattern[i] == data[i]) || ((grepbehave != GREP_FIXED) && pattern[i] == '.'))
-		    || (iflag && pattern[i] == toupper(data[i])))
+		    || (iflag && toupper(pattern[i]) == toupper(data[i])))
 			continue;
 		return (i);
 	}



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