PERFORCE change 143815 for review
Gabor Kovesdan
gabor at FreeBSD.org
Fri Jun 20 11:38:26 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143815
Change 143815 by gabor at gabor_server on 2008/06/20 11:37:51
- Fix some regressions that went through
Reported by: Jaakko Heinonen <jh at 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] == '*')
More information about the p4-projects
mailing list