[Pcre-svn] [1353] code/trunk: Fix pcregrep looping bug for …

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1353] code/trunk: Fix pcregrep looping bug for multiline empty string match.
Revision: 1353
          http://vcs.pcre.org/viewvc?view=rev&revision=1353
Author:   ph10
Date:     2013-08-05 17:24:02 +0100 (Mon, 05 Aug 2013)


Log Message:
-----------
Fix pcregrep looping bug for multiline empty string match.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/RunGrepTest
    code/trunk/pcregrep.c
    code/trunk/testdata/grepoutput


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2013-07-29 15:49:21 UTC (rev 1352)
+++ code/trunk/ChangeLog    2013-08-05 16:24:02 UTC (rev 1353)
@@ -57,6 +57,9 @@
     item was recorded. For example, the pattern (?(?=ab)ab) recorded "a" as a
     first data item, and therefore matched "ca" after "c" instead of at the 
     start.
+    
+11. Change 40 for 8.33 (allowing pcregrep to find empty strings) showed up a 
+    bug that caused the command "echo a | ./pcregrep -M '|a'" to loop.



Version 8.33 28-May-2013

Modified: code/trunk/RunGrepTest
===================================================================
--- code/trunk/RunGrepTest    2013-07-29 15:49:21 UTC (rev 1352)
+++ code/trunk/RunGrepTest    2013-08-05 16:24:02 UTC (rev 1353)
@@ -502,7 +502,11 @@
 (cd $srcdir; $valgrind $pcregrep --colour=always "ipsum|" ./testdata/grepinput3) >>testtry 2>&1
 echo "RC=$?" >>testtry


+echo "---------------------------- Test 106 -----------------------------" >>testtry
+(cd $srcdir; echo "a" | $valgrind $pcregrep -M "|a" ) >>testtry 2>&1
+echo "RC=$?" >>testtry

+
# Now compare the results.

$cf $srcdir/testdata/grepoutput testtry

Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2013-07-29 15:49:21 UTC (rev 1352)
+++ code/trunk/pcregrep.c    2013-08-05 16:24:02 UTC (rev 1353)
@@ -1835,7 +1835,7 @@
         {
         char *endmatch = ptr + offsets[1];
         t = ptr;
-        while (t < endmatch)
+        while (t <= endmatch)
           {
           t = end_of_line(t, endptr, &endlinelength);
           if (t < endmatch) linenumber++; else break;


Modified: code/trunk/testdata/grepoutput
===================================================================
--- code/trunk/testdata/grepoutput    2013-07-29 15:49:21 UTC (rev 1352)
+++ code/trunk/testdata/grepoutput    2013-08-05 16:24:02 UTC (rev 1353)
@@ -740,3 +740,6 @@
 ?[1;31m?[00m
 ?[1;31m?[00mtriple:    t7_txt    s1_tag    s_txt    p_tag    p_txt    o_tag    o_txt
 RC=0
+---------------------------- Test 106 -----------------------------
+a
+RC=0