Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2008 11:38:25 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 143815 for review
Message-ID:  <200806201138.m5KBcPYO091292@repoman.freebsd.org>

index | next in thread | raw e-mail

http://perforce.freebsd.org/chv.cgi?CH=143815

Change 143815 by gabor@gabor_server on 2008/06/20 11:37:51

	- Fix some regressions that went through
	
	Reported by:	Jaakko Heinonen <jh@saunalahti.fi>

Affected files ...

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

Differences ...

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

@@ -192,12 +192,15 @@
 /* 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)
-		strlcpy(ptr, &(ptr[1]), strlen(pat) - strlen(ptr));
-	while ((ptr = strstr(pat, "(|")) != NULL)
-		strlcpy(&(ptr[1]), &(ptr[2]), strlen(pat) - strlen(ptr) - 1);
-	while ((ptr = strstr(pat, "||")) != NULL)
-		strlcpy(&(ptr[1]), &(ptr[2]), strlen(pat) - strlen(ptr) - 1);
+	while (((ptr = strstr(pat, "|)"))) != NULL && (strstr(pat, "\\|)") != (ptr - 1))) {
+		strlcpy(ptr, &(ptr[1]), strlen(ptr));
+	}
+	while (((ptr = strstr(pat, "(|")) != NULL) && (strstr(pat, "(\\|") != ptr) && (strstr(pat, "\\(|") != (ptr - 1))) {
+		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+	}
+	while ((ptr = strstr(pat, "||")) != NULL) {
+		strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+	}
 
 /* Work-around to allow * at the beginning of the regexp */
 	while (pat[0] == '*')


help

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