Date: Thu, 7 Aug 2008 16:49:39 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 146843 for review Message-ID: <200808071649.m77Gndgi078891@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146843 Change 146843 by gabor@gabor_server on 2008/08/07 16:49:07 - Fix -v beaviour - Simplify the -v handling Reported by: Chuck Swiger <cswiger@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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808071649.m77Gndgi078891>