Date: Sun, 10 Aug 2008 17:31:15 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 147092 for review Message-ID: <200808101731.m7AHVF7a037588@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) ====
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808101731.m7AHVF7a037588>