svn commit: r225542 - user/gabor/grep/trunk

Gabor Kovesdan gabor at FreeBSD.org
Wed Sep 14 00:40:01 UTC 2011


Author: gabor
Date: Wed Sep 14 00:40:00 2011
New Revision: 225542
URL: http://svn.freebsd.org/changeset/base/225542

Log:
  - Failing fixncomp() does not always mean the pattern is invalid, e.g.
    MBS with REG_ICASE cannot be handled by the fast matcher. Furthermore,
    fastncomp() always catches fix patterns so the distinction is not
    really necessary, it just makes the code longer.
  
  Reported by:	aakuusta at gmail.com

Modified:
  user/gabor/grep/trunk/grep.c

Modified: user/gabor/grep/trunk/grep.c
==============================================================================
--- user/gabor/grep/trunk/grep.c	Tue Sep 13 23:28:04 2011	(r225541)
+++ user/gabor/grep/trunk/grep.c	Wed Sep 14 00:40:00 2011	(r225542)
@@ -685,29 +685,17 @@ main(int argc, char *argv[])
 	r_pattern = grep_calloc(patterns, sizeof(*r_pattern));
 
 	/* Check if cheating is allowed (always is for fgrep). */
-	if (grepbehave == GREP_FIXED) {
-		for (i = 0; i < patterns; ++i) {
-			c = fixncomp(&fg_pattern[i], pattern[i].pat,
-			    pattern[i].len, cflags);
+	for (i = 0; i < patterns; ++i) {
+		if (fastncomp(&fg_pattern[i], pattern[i].pat,
+		    pattern[i].len, cflags) != 0) {
+			/* Fall back to full regex library */
+			c = regcomp(&r_pattern[i], pattern[i].pat, cflags);
 			if (c != 0) {
 				regerror(c, &r_pattern[i], re_error,
 				    RE_ERROR_BUF);
 				errx(2, "%s", re_error);
 			}
 		}
-	} else {
-		for (i = 0; i < patterns; ++i) {
-			if (fastncomp(&fg_pattern[i], pattern[i].pat,
-			    pattern[i].len, cflags) != 0) {
-				/* Fall back to full regex library */
-				c = regcomp(&r_pattern[i], pattern[i].pat, cflags);
-				if (c != 0) {
-					regerror(c, &r_pattern[i], re_error,
-					    RE_ERROR_BUF);
-					errx(2, "%s", re_error);
-				}
-			}
-		}
 	}
 
 	if (lbflag)


More information about the svn-src-user mailing list