From owner-p4-projects@FreeBSD.ORG Thu Aug 7 16:49:39 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A8CB7106568B; Thu, 7 Aug 2008 16:49:39 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BE43106567F for ; Thu, 7 Aug 2008 16:49:39 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 59B628FC25 for ; Thu, 7 Aug 2008 16:49:39 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m77Gnd5a078893 for ; Thu, 7 Aug 2008 16:49:39 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m77Gndgi078891 for perforce@freebsd.org; Thu, 7 Aug 2008 16:49:39 GMT (envelope-from gabor@freebsd.org) Date: Thu, 7 Aug 2008 16:49:39 GMT Message-Id: <200808071649.m77Gndgi078891@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 146843 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 16:49:40 -0000 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 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");