Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2008 18:01:04 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 143829 for review
Message-ID:  <200806201801.m5KI144D055463@repoman.freebsd.org>

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

Change 143829 by gabor@gabor_server on 2008/06/20 18:00:53

	- Rework the GNU compatibility part a bit, the workaround substitutions
	  are more accurate now

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#29 edit

Differences ...

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

@@ -187,37 +187,55 @@
 static void
 add_pattern(char *pat, size_t len)
 {
-	char	*ptr;
+	char	*ptr, *st;
 
 /* Workaround for our libc-regex library to match GNU behaviour.
    Our library rejects '|' with empty subexpressions.  Just cut out
    those parts, e.g. "(|a|b||c|)" will be "(a|b|c)" */
-	while (((ptr = strstr(pat, "|)"))) != NULL && (strstr(pat, "\\|)") != (ptr - 1))) {
+	st = pat;
+	while (((ptr = strstr(st, "|)"))) != NULL && (strstr(st, "\\|)") != (ptr - 1))) {
 		strlcpy(ptr, &(ptr[1]), strlen(ptr));
+		st = ptr;
 	}
-	while (((ptr = strstr(pat, "(|")) != NULL) && (strstr(pat, "(\\|") != ptr) && (strstr(pat, "\\(|") != (ptr - 1))) {
+	st = pat;
+	while (((ptr = strstr(st, "(|")) != NULL) && (strstr(st, "(\\|") != ptr) && (strstr(st, "\\(|") != (ptr - 1))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while (((ptr = strstr(pat, "||")) != NULL) && (strstr(pat, "\\||") != (ptr - 1))) {
+	st = pat;
+	while (((ptr = strstr(st, "||")) != NULL) && (strstr(st, "\\||") != (ptr - 1))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while (((ptr = strstr(pat, "*?")) != NULL) && (strstr(pat, "\\*?") != (ptr - 1))) {
+	st = pat;
+	while (((ptr = strstr(st, "*?")) != NULL) && (strstr(st, "\\*?") != (ptr - 1))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while (((ptr = strstr(pat, "?*")) != NULL) && (strstr(pat, "\\?*") != (ptr - 1))) {
+	st = pat;
+	while (((ptr = strstr(st, "?*")) != NULL) && (strstr(st, "\\?*") != (ptr - 1))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while (((ptr = strstr(pat, "**")) != NULL) && (strstr(pat, "\\**") != (ptr - 1)) && (strstr(pat, "\\(**") != (ptr - 2))) {
+	st = pat;
+	while (((ptr = strstr(st, "**")) != NULL) && (strstr(st, "\\**") != (ptr - 1)) && (strstr(st, "\\(**") != (ptr - 2))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while (((ptr = strstr(pat, "??")) != NULL) && (strstr(pat, "\\??") != (ptr - 1))) {
+	st = pat;
+	while (((ptr = strstr(st, "??")) != NULL) && (strstr(st, "\\??") != (ptr - 1))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while ((ptr = strstr(pat, "^*")) != NULL) {
+	st = pat;
+	while ((ptr = strstr(st, "^*")) != NULL) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
-	while ((ptr = strstr(pat, "(*")) != NULL && (strstr(pat, "\\(*") != (ptr - 1))) {
+	st = pat;
+	while ((ptr = strstr(st, "(*")) != NULL && (strstr(st, "\\(*") != (ptr - 1))) {
 		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+		st = ptr;
 	}
 
 //	printf("PAT %s\n", pat);



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