[Pcre-svn] [1658] code/trunk: Fix bad interaction between -o…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1658] code/trunk: Fix bad interaction between -o and -M in pcregrep.
Revision: 1658
          http://vcs.pcre.org/viewvc?view=rev&revision=1658
Author:   ph10
Date:     2016-06-17 18:28:14 +0100 (Fri, 17 Jun 2016)
Log Message:
-----------
Fix bad interaction between -o and -M in pcregrep.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/configure.ac
    code/trunk/pcregrep.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2016-06-14 10:27:41 UTC (rev 1657)
+++ code/trunk/ChangeLog    2016-06-17 17:28:14 UTC (rev 1658)
@@ -4,6 +4,13 @@
 Note that the PCRE 8.xx series (PCRE1) is now in a bugfix-only state. All
 development is happening in the PCRE2 10.xx series.


+Version 8.40 17-June-2016
+-------------------------
+
+1.  Using -o with -M in pcregrep could cause unnecessary repeated output when
+    the match extended over a line boundary.
+     
+
 Version 8.39 14-June-2016
 -------------------------



Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac    2016-06-14 10:27:41 UTC (rev 1657)
+++ code/trunk/configure.ac    2016-06-17 17:28:14 UTC (rev 1658)
@@ -9,9 +9,9 @@
 dnl be defined as -RC2, for example. For real releases, it should be empty.


m4_define(pcre_major, [8])
-m4_define(pcre_minor, [39])
-m4_define(pcre_prerelease, [])
-m4_define(pcre_date, [2016-06-14])
+m4_define(pcre_minor, [40])
+m4_define(pcre_prerelease, [-RC1])
+m4_define(pcre_date, [2016-06-17])

# 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.

Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2016-06-14 10:27:41 UTC (rev 1657)
+++ code/trunk/pcregrep.c    2016-06-17 17:28:14 UTC (rev 1658)
@@ -1803,6 +1803,12 @@
         match = FALSE;
         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)
           {