summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2017-02-10 17:47:34 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2017-02-10 17:47:34 +0000
commit5be027b624bc866702808abadfe5f99360414086 (patch)
tree7fd14b4dbe5c96fd42432961dcea55f6ae4df1a7
parent073bb6628f95d32ea11f7ee328ed5f0c935cd11c (diff)
downloadpcre-5be027b624bc866702808abadfe5f99360414086.tar.gz
Correct fix for pcre2grep multiline with --only-matching.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1678 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog5
-rw-r--r--configure.ac6
-rw-r--r--pcregrep.c20
3 files changed, 23 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index ab4e053..373ee84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,11 @@ Version 8.41
1. Fixed typo in CMakeLists.txt (wrong number of arguments for
PCRE_STATIC_RUNTIME (affects MSVC only).
+2. Issue 1 for 8.40 below was not correctly fixed. If pcregrep 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 8.40 11-January-2017
----------------------------
diff --git a/configure.ac b/configure.ac
index 24ef727..8f12eca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,9 +9,9 @@ dnl The PCRE_PRERELEASE feature is for identifying release candidates. It might
dnl be defined as -RC2, for example. For real releases, it should be empty.
m4_define(pcre_major, [8])
-m4_define(pcre_minor, [40])
-m4_define(pcre_prerelease, [])
-m4_define(pcre_date, [2017-01-11])
+m4_define(pcre_minor, [41])
+m4_define(pcre_prerelease, [-RC1])
+m4_define(pcre_date, [2017-02-01])
# NOTE: The CMakeLists.txt file searches for the above variables in the first
# 50 lines of this file. Please update that if the variables above are moved.
diff --git a/pcregrep.c b/pcregrep.c
index fd2a676..2070c05 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -1804,11 +1804,6 @@ while (ptr < endptr)
if (line_buffered) fflush(stdout);
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 ((unsigned int)offsets[1] > linelength) goto END_ONE_MATCH;
-
startoffset = offsets[1]; /* Restart after the match */
if (startoffset <= oldstartoffset)
{
@@ -1818,6 +1813,21 @@ while (ptr < endptr)
if (utf8)
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 > (int)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;
}
}