Fix previously broken fix for pcre2grep with -Mo matching strings that cross
line boundaries.
This commit is contained in:
parent
8a3a452ea9
commit
0299bba9d9
|
@ -352,6 +352,11 @@ group whose number is greater than 128. (In that case, the pattern is so
|
||||||
complicated that this optimization probably isn't worth it.) This fixes
|
complicated that this optimization probably isn't worth it.) This fixes
|
||||||
oss-fuzz issue 557.
|
oss-fuzz issue 557.
|
||||||
|
|
||||||
|
55. Issue 32 for 10.22 below was not correctly fixed. If pcre2grep in multiline
|
||||||
|
mode with --only-matching matched several lines, it restarted scanning at the
|
||||||
|
next line instead of moving on to the end of the matched string, which can be
|
||||||
|
several lines after the start.
|
||||||
|
|
||||||
|
|
||||||
Version 10.22 29-July-2016
|
Version 10.22 29-July-2016
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
|
@ -593,6 +593,11 @@ echo "---------------------------- Test 118 -----------------------------" >>tes
|
||||||
(cd $srcdir; $valgrind $vjs $pcre2grep -tL 'the' testdata/grepinput*) >>testtrygrep
|
(cd $srcdir; $valgrind $vjs $pcre2grep -tL 'the' testdata/grepinput*) >>testtrygrep
|
||||||
echo "RC=$?" >>testtrygrep
|
echo "RC=$?" >>testtrygrep
|
||||||
|
|
||||||
|
echo "---------------------------- Test 119 -----------------------------" >>testtrygrep
|
||||||
|
printf "123\n456\n789\n---abc\ndef\nxyz\n---\n" >testNinputgrep
|
||||||
|
(cd $srcdir; $valgrind $vjs $pcre2grep -Mo '(\n|[^-])*---' testNinputgrep) >>testtrygrep
|
||||||
|
echo "RC=$?" >>testtrygrep
|
||||||
|
|
||||||
# Now compare the results.
|
# Now compare the results.
|
||||||
|
|
||||||
$cf $srcdir/testdata/grepoutput testtrygrep
|
$cf $srcdir/testdata/grepoutput testtrygrep
|
||||||
|
|
|
@ -2285,11 +2285,6 @@ while (ptr < endptr)
|
||||||
if (line_buffered) fflush(stdout);
|
if (line_buffered) fflush(stdout);
|
||||||
rc = 0; /* Had some success */
|
rc = 0; /* Had some success */
|
||||||
|
|
||||||
/* If the current match ended past the end of the line (only possible
|
|
||||||
in multiline mode), we are done with this line. */
|
|
||||||
|
|
||||||
if (offsets[1] > linelength) goto END_ONE_MATCH;
|
|
||||||
|
|
||||||
/* If the pattern contained a lookbehind that included \K, it is
|
/* If the pattern contained a lookbehind that included \K, it is
|
||||||
possible that the end of the match might be at or before the actual
|
possible that the end of the match might be at or before the actual
|
||||||
starting offset we have just used. In this case, start one character
|
starting offset we have just used. In this case, start one character
|
||||||
|
@ -2301,9 +2296,23 @@ while (ptr < endptr)
|
||||||
{
|
{
|
||||||
if (startoffset >= length) goto END_ONE_MATCH; /* Were at end */
|
if (startoffset >= length) goto END_ONE_MATCH; /* Were at end */
|
||||||
startoffset = oldstartoffset + 1;
|
startoffset = oldstartoffset + 1;
|
||||||
if (utf)
|
if (utf) while ((matchptr[startoffset] & 0xc0) == 0x80) startoffset++;
|
||||||
while ((matchptr[startoffset] & 0xc0) == 0x80) startoffset++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the current match ended past the end of the line (only possible
|
||||||
|
in multiline mode), we must move on to the line in which it did end
|
||||||
|
before searching for more matches. */
|
||||||
|
|
||||||
|
while (startoffset > linelength)
|
||||||
|
{
|
||||||
|
matchptr = ptr += linelength + endlinelength;
|
||||||
|
filepos += (int)(linelength + endlinelength);
|
||||||
|
linenumber++;
|
||||||
|
startoffset -= (int)(linelength + endlinelength);
|
||||||
|
t = end_of_line(ptr, endptr, &endlinelength);
|
||||||
|
linelength = t - ptr - endlinelength;
|
||||||
|
}
|
||||||
|
|
||||||
goto ONLY_MATCHING_RESTART;
|
goto ONLY_MATCHING_RESTART;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -819,3 +819,13 @@ RC=0
|
||||||
testdata/grepinput3
|
testdata/grepinput3
|
||||||
testdata/grepinput8
|
testdata/grepinput8
|
||||||
RC=0
|
RC=0
|
||||||
|
---------------------------- Test 119 -----------------------------
|
||||||
|
123
|
||||||
|
456
|
||||||
|
789
|
||||||
|
---
|
||||||
|
abc
|
||||||
|
def
|
||||||
|
xyz
|
||||||
|
---
|
||||||
|
RC=0
|
||||||
|
|
Loading…
Reference in New Issue