PERFORCE change 146843 for review
Gabor Kovesdan
gabor at FreeBSD.org
Thu Aug 7 16:49:40 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146843
Change 146843 by gabor at gabor_server on 2008/08/07 16:49:07
- Fix -v beaviour
- Simplify the -v handling
Reported by: Chuck Swiger <cswiger at mac.com>
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/util.c#70 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/util.c#70 (text+ko) ====
@@ -243,14 +243,12 @@
regmatch_t pmatch;
regmatch_t matches[MAX_LINE_MATCHES];
regoff_t st = 0;
- int c = 0, i, r = 0, m = 0, t;
+ int c = 0, i, r = 0, m = 0;
#ifdef WITH_PCRE
int ovector[3];
#endif
if (!matchall) {
- t = vflag ? REG_NOMATCH : 0;
-
/* Loop to process the whole line */
while (st <= l->len) {
pmatch.rm_so = st;
@@ -260,6 +258,7 @@
for (i = 0; i < patterns; i++) {
if (grepbehave != GREP_PERL) {
r = regexec(&r_pattern[i], l->dat, 1, &pmatch, eflags);
+ r = (r == 0) ? (vflag ? REG_NOMATCH : 0) : (vflag ? 0 : REG_NOMATCH);
st = pmatch.rm_eo;
} else {
#ifdef WITH_PCRE
@@ -271,7 +270,7 @@
;
#endif
}
- if (r == REG_NOMATCH && t == 0)
+ if (r == REG_NOMATCH)
continue;
/* Check for full match */
if (r == 0 && xflag)
@@ -290,7 +289,7 @@
r = REG_NOMATCH;
free(wbegin);
}
- if (r == t) {
+ if (r == 0) {
if (m == 0)
c++;
if (m < MAX_LINE_MATCHES)
@@ -313,7 +312,7 @@
return (c); /* Binary file */
/* Dealing with the context */
- if ((tail || (c && !vflag)) && !cflag && !qflag) {
+ if ((tail || c) && !cflag && !qflag) {
if (c) {
if (!first && !prev && !tail && Aflag)
printf("--\n");
More information about the p4-projects
mailing list