PERFORCE change 143829 for review
Gabor Kovesdan
gabor at FreeBSD.org
Fri Jun 20 18:01:05 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143829
Change 143829 by gabor at 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);
More information about the p4-projects
mailing list