[Pcre-svn] [1397] code/trunk: Fix \K bug in possessively rep…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1397] code/trunk: Fix \K bug in possessively repeated groups.
Revision: 1397
          http://vcs.pcre.org/viewvc?view=rev&revision=1397
Author:   ph10
Date:     2013-11-11 18:33:23 +0000 (Mon, 11 Nov 2013)


Log Message:
-----------
Fix \K bug in possessively repeated groups.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_exec.c
    code/trunk/testdata/testinput1
    code/trunk/testdata/testoutput1


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2013-11-10 19:04:34 UTC (rev 1396)
+++ code/trunk/ChangeLog    2013-11-11 18:33:23 UTC (rev 1397)
@@ -177,6 +177,9 @@
 37. In extended mode, Perl ignores spaces before a + that indicates a 
     possessive quantifier. PCRE allowed a space before the quantifier, but not 
     before the possessive +. It now does.
+    
+38. The use of \K (reset reported match start) within a repeated possessive
+    group such as (a\Kb)*+ was not working.



Version 8.33 28-May-2013

Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2013-11-10 19:04:34 UTC (rev 1396)
+++ code/trunk/pcre_exec.c    2013-11-11 18:33:23 UTC (rev 1397)
@@ -1173,6 +1173,7 @@
           ecode = md->start_code + code_offset;
           save_capture_last = md->capture_last;
           matched_once = TRUE;
+          mstart = md->start_match_ptr;    /* In case \K changed it */
           continue;
           }


@@ -1245,6 +1246,7 @@
         eptr = md->end_match_ptr;
         ecode = md->start_code + code_offset;
         matched_once = TRUE;
+        mstart = md->start_match_ptr;   /* In case \K reset it */
         continue;
         }


@@ -2007,6 +2009,7 @@

     if (*ecode == OP_KETRPOS)
       {
+      md->start_match_ptr = mstart;    /* In case \K reset it */
       md->end_match_ptr = eptr;
       md->end_offset_top = offset_top;
       RRETURN(MATCH_KETRPOS);


Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2013-11-10 19:04:34 UTC (rev 1396)
+++ code/trunk/testdata/testinput1    2013-11-11 18:33:23 UTC (rev 1397)
@@ -5651,4 +5651,19 @@
 / ^ ( a + ) + + \w $ /x
     aaaab 


+/(?:a\Kb)*+/+
+    ababc
+
+/(?>a\Kb)*/+
+    ababc
+
+/(?:a\Kb)*/+
+    ababc
+
+/(a\Kb)*+/+
+    ababc
+
+/(a\Kb)*/+
+    ababc
+
 /-- End of testinput1 --/


Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2013-11-10 19:04:34 UTC (rev 1396)
+++ code/trunk/testdata/testoutput1    2013-11-11 18:33:23 UTC (rev 1397)
@@ -9286,4 +9286,31 @@
  0: aaaab
  1: aaaa


+/(?:a\Kb)*+/+
+    ababc
+ 0: b
+ 0+ c
+
+/(?>a\Kb)*/+
+    ababc
+ 0: b
+ 0+ c
+
+/(?:a\Kb)*/+
+    ababc
+ 0: b
+ 0+ c
+
+/(a\Kb)*+/+
+    ababc
+ 0: b
+ 0+ c
+ 1: ab
+
+/(a\Kb)*/+
+    ababc
+ 0: b
+ 0+ c
+ 1: ab
+
 /-- End of testinput1 --/