PERFORCE change 143880 for review
Gabor Kovesdan
gabor at FreeBSD.org
Sat Jun 21 14:40:25 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143880
Change 143880 by gabor at gabor_server on 2008/06/21 14:40:13
- Polish GNU compatibility blog
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#33 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#33 (text+ko) ====
@@ -195,76 +195,80 @@
Our library rejects '|' with empty subexpressions. Just cut out
those parts, e.g. "(|a|b||c|)" will be "(a|b|c)" */
st = pat;
- while (((ptr = strstr(st, "|)"))) != NULL && (strstr(st, "\\|)") != (ptr - 1))) {
- strlcpy(ptr, &(ptr[1]), strlen(ptr));
+ 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) && (strstr(st, "(\\|") != ptr) && (strstr(st, "\\(|") != (ptr - 1))) {
- strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
- st = ptr;
+ 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) && (strstr(st, "\\||") != (ptr - 1))) {
- strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
- st = ptr;
+ 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) && (strstr(st, "\\*?") != (ptr - 1))) {
- strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
- st = ptr;
+ 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) && (strstr(st, "\\?*") != (ptr - 1))) {
- strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
- st = ptr;
+ 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) && (strstr(st, "\\**") != (ptr - 1)) && (strstr(st, "\\(**") != (ptr - 2))) {
- strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
- st = ptr;
+ 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) && (strstr(st, "\\??") != (ptr - 1))) {
- strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
- st = ptr;
+ 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;
+ st = 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(st, "(*")) != NULL) {
+ if (strstr(st, "\\(*") != (ptr - 1))
+ strlcpy(&(ptr[1]), &(ptr[2]), strlen(ptr));
+ st = ptr + 1;
}
st = pat;
-/* XXX
- while ((ptr = strstr(st, "{1")) != NULL && (strstr(st, "\\{1") != (ptr - 1))) {
- st = ptr;
- } */
if (Eflag) {
st = pat;
lbr = 0;
while ((ptr = strstr(st, "(")) != NULL) {
if (strstr(st, "\\(") != (ptr - 1))
lbr++;
- st = &(ptr[1]);
+ st = ptr + 1;
}
st = pat;
rbr = 0;
while ((ptr = strstr(st, ")")) != NULL) {
if (strstr(st, "\\)") != (ptr - 1))
rbr++;
- st = &(ptr[1]);
+ st = ptr + 1;
}
if (lbr != rbr) {
errx(2, "parentheses not balanced");
}
}
-/// printf("PAT %s\n", pat);
+// printf("PAT %s\n", pat);
/* Work-around to allow * at the beginning of the regexp */
while (pat[0] == '*')
More information about the p4-projects
mailing list