[Pcre-svn] [1301] code/trunk: Fix \K within recursion bug in…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1301] code/trunk: Fix \K within recursion bug in interpreter.
Revision: 1301
          http://www.exim.org/viewvc/pcre2?view=rev&revision=1301
Author:   ph10
Date:     2021-02-18 09:46:08 +0000 (Thu, 18 Feb 2021)
Log Message:
-----------
Fix \K within recursion bug in interpreter.


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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2021-02-12 07:45:12 UTC (rev 1300)
+++ code/trunk/ChangeLog    2021-02-18 09:46:08 UTC (rev 1301)
@@ -35,7 +35,11 @@
 is broken. Later: the requirement for autoconf 2.70 broke some automatic test 
 robots. It doesn't seem to be necessary: trying a reduction to 2.60.


+6. The pattern /a\K.(?0)*/ when matched against "abac" by the interpreter gave
+the answer "bac", whereas Perl and JIT both yield "c". This was because the
+effect of \K was not propagating back from the recursion. This is now fixed.

+
Version 10.36 04-December-2020
------------------------------


Modified: code/trunk/src/pcre2_match.c
===================================================================
--- code/trunk/src/pcre2_match.c    2021-02-12 07:45:12 UTC (rev 1300)
+++ code/trunk/src/pcre2_match.c    2021-02-18 09:46:08 UTC (rev 1301)
@@ -818,10 +818,12 @@


       /* N is now the frame of the recursion; the previous frame is at the
       OP_RECURSE position. Go back there, copying the current subject position
-      and mark, and move on past the OP_RECURSE. */
+      and mark, and the start_match position (\K might have changed it), and
+      then move on past the OP_RECURSE. */


       P->eptr = Feptr;
       P->mark = Fmark;
+      P->start_match = Fstart_match; 
       F = P;
       Fecode += 1 + LINK_SIZE;
       continue;


Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2021-02-12 07:45:12 UTC (rev 1300)
+++ code/trunk/testdata/testinput1    2021-02-18 09:46:08 UTC (rev 1301)
@@ -6429,4 +6429,7 @@
 /a{65536/
     >a{65536<


+/a\K.(?0)*/
+    abac
+
 # End of testinput1 


Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2021-02-12 07:45:12 UTC (rev 1300)
+++ code/trunk/testdata/testoutput1    2021-02-18 09:46:08 UTC (rev 1301)
@@ -10188,4 +10188,8 @@
     >a{65536<
  0: a{65536


+/a\K.(?0)*/
+    abac
+ 0: c
+
 # End of testinput1