From owner-p4-projects@FreeBSD.ORG Sun Aug 10 17:31:15 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BF3A41065670; Sun, 10 Aug 2008 17:31:15 +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 50B821065673 for ; Sun, 10 Aug 2008 17:31:15 +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 491BA8FC21 for ; Sun, 10 Aug 2008 17:31:15 +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 m7AHVFPV037590 for ; Sun, 10 Aug 2008 17:31:15 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7AHVF7a037588 for perforce@freebsd.org; Sun, 10 Aug 2008 17:31:15 GMT (envelope-from gabor@freebsd.org) Date: Sun, 10 Aug 2008 17:31:15 GMT Message-Id: <200808101731.m7AHVF7a037588@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 147092 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: Sun, 10 Aug 2008 17:31:16 -0000 http://perforce.freebsd.org/chv.cgi?CH=147092 Change 147092 by gabor@gabor_server on 2008/08/10 17:30:17 - Fixed string code can now use the starting position to continue searching - Reversed searching cannot be used when we are using -o or --color, because we need to count and record the matches then - Thus now we are using the fixed string code in the former cases with the modifications Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#5 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#74 edit .. //depot/projects/soc2008/gabor_textproc/grep/util.c#73 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#5 (text+ko) ==== @@ -169,7 +169,7 @@ */ if ((!(lflag || cflag)) && ((!(bol || eol)) && ((lastHalfDot) && ((firstHalfDot < 0) || - ((fg->patternLen - (lastHalfDot + 1)) < firstHalfDot))))) { + ((fg->patternLen - (lastHalfDot + 1)) < firstHalfDot)))) && !oflag && !color) { fg->reversedSearch = 1; hasDot = fg->patternLen - (firstHalfDot < 0 ? firstLastHalfDot : firstHalfDot) - 1; @@ -228,8 +228,14 @@ int j; int rtrnVal = REG_NOMATCH; - pmatch->rm_so = -1; - pmatch->rm_eo = -1; + if (pmatch->rm_so == dataLen) + return (rtrnVal); + + if (fg->bol && pmatch->rm_so != 0) { + pmatch->rm_so = dataLen; + pmatch->rm_eo = dataLen; + return (rtrnVal); + } /* No point in going farther if we do not have enough data. */ if (dataLen < fg->patternLen) @@ -258,7 +264,7 @@ j = dataLen; do { if (grep_cmp(fg->pattern, data + j - fg->patternLen, - fg->patternLen) == -1) { + fg->patternLen) == -1) { pmatch->rm_so = j - fg->patternLen; pmatch->rm_eo = j; rtrnVal = 0; @@ -271,7 +277,7 @@ } while (j >= fg->patternLen); } else { /* Quick Search algorithm. */ - j = 0; + j = pmatch->rm_so; do { if (grep_cmp(fg->pattern, data + j, fg->patternLen) == -1) { pmatch->rm_so = j; ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#74 (text+ko) ==== @@ -599,13 +599,10 @@ */ for (i = 0; i < patterns; ++i) { /* Check if cheating is allowed (always is for fgrep). */ - if (grepbehave == GREP_FIXED && !color && !oflag) + if (grepbehave == GREP_FIXED) fgrepcomp(&fg_pattern[i], pattern[i]); else { - if (oflag || color) - goto fallback; if (fastcomp(&fg_pattern[i], pattern[i])) { -fallback: /* Fall back to full regex library */ c = regcomp(&r_pattern[i], pattern[i], cflags); if (c != 0) { ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#73 (text+ko) ====