PERFORCE change 144267 for review
    Gabor Kovesdan 
    gabor at FreeBSD.org
       
    Sun Jun 29 12:36:12 UTC 2008
    
    
  
http://perforce.freebsd.org/chv.cgi?CH=144267
Change 144267 by gabor at gabor_server on 2008/06/29 12:35:28
	- Drop the GNU compatibility pre-editing workarounds. They don't work
	  entirely and it is very weird to apply hacks in grep for our regex
	  library. If we want better compatibility, the problem should be
	  addressed there. A different behaviour in BSD grep than the behaviour
	  of the base system regex library is clearly unwanted and I'm getting
	  very frustrated of dealing with these weird workarounds. When I can
	  make something compatible, compatibility breaks at another place.
	  It wouldn't lead to anywhere.
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/Makefile#10 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#53 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/Makefile#10 (text+ko) ====
@@ -31,8 +31,4 @@
 CFLAGS+=	-DWITHOUT_NLS
 .endif
 
-.if defined(WITHOUT_GNU_COMPAT)
-CFLAGS+=	-DWITHOUT_GNU_COMPAT
-.endif
-
 .include <bsd.prog.mk>
==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#53 (text+ko) ====
@@ -202,92 +202,6 @@
 static void
 add_pattern(char *pat, size_t len)
 {
-#ifndef WITHOUT_GNU_COMPAT
-	char	*ptr, *st;
-	int	 lbr, rbr;
-
-/* Workaround for our libc-regex library for better GNU compatibility.
-   Our library rejects some non-standard regular expressions, for example
-   '|' cannot stand with empty subexpressions.  In these cases the
-   non-standard regex will be pre-edited,
-   e.g. "(|a|b||c|)" will be "(a|b|c)" */
-	st = pat;
-	while (((ptr = strstr(st, "|)"))) != NULL) {
-		if (strstr(st, "\\|)") != (ptr - 1))
-			strlcpy(ptr, &(ptr[1]), strlen(ptr));
-		st = ptr;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "(|")) != NULL) {
-		if ((strstr(st, "(\\|") != ptr) && (strstr(st, "\\(|") != (ptr - 1)))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "||")) != NULL) {
-		if (strstr(st, "\\||") != (ptr - 1))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "*?")) != NULL) {
-		if (strstr(st, "\\*?") != (ptr - 1))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "?*")) != NULL) {
-		if (strstr(st, "\\?*") != (ptr - 1))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "**")) != NULL) {
-		if ((strstr(st, "\\**") != (ptr - 1)) && (strstr(st, "\\(**") != (ptr - 2)))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "??")) != NULL) {
-		if (strstr(st, "\\??") != (ptr - 1))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "^*")) != NULL) {
-		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	while ((ptr = strstr(st, "(*")) != NULL) {
-		if (strstr(st, "\\(*") != (ptr - 1))
-			strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
-		st = ptr + 1;
-	}
-	st = pat;
-	if (Eflag) {
-		st = pat;
-		lbr = 0;
-		while ((ptr = strstr(st, "(")) != NULL) {
-			if (strstr(st, "\\(") != (ptr - 1))
-				lbr++;
-			st = ptr + 1;
-		}
-		st = pat;
-		rbr = 0;
-		while ((ptr = strstr(st, ")")) != NULL) {
-			if (strstr(st, "\\)") != (ptr - 1))
-				rbr++;
-			st = ptr + 1;
-		}
-		if (lbr != rbr) {
-			errx(2, getstr(8));
-		}
-	}
-	while (pat[0] == '*')
-		pat++;
-#endif
-
 	if (len == 0 || matchall) {
 		matchall = 1;
 		return;
    
    
More information about the p4-projects
mailing list