[pcre-dev] [Bug 1848] pcregrep outputs duplicate matches

Top Page
Delete this message
Author: admin
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 1848] pcregrep outputs duplicate matches
https://bugs.exim.org/show_bug.cgi?id=1848

Philip Hazel <ph10@???> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED


--- Comment #1 from Philip Hazel <ph10@???> ---

Thank you for this report, which showed up a bad interaction between -o and -M
in pcregrep. It was looking for more matches "on the same line" - only after a
multiline match it hadn't realized it didn't need to. I have committed a patch
that fixes this - but sadly it was too late for the 8.39 release that came out
a few days ago. It will be some time before the next release, so I'm quoting
the patch below. The same bug was present in PCRE2, and I have fixed that as
well in the repository.

--- pcregrep.c  (revision 1647)
+++ pcregrep.c  (working copy)
@@ -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)
           {


--
You are receiving this mail because:
You are on the CC list for the bug.