[Pcre-svn] [730] code/trunk: Fix non-passing of mark values …

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [730] code/trunk: Fix non-passing of mark values out of recursions.
Revision: 730
          http://www.exim.org/viewvc/pcre2?view=rev&revision=730
Author:   ph10
Date:     2017-04-04 12:37:21 +0100 (Tue, 04 Apr 2017)
Log Message:
-----------
Fix non-passing of mark values out of recursions.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_match.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2017-04-03 18:02:07 UTC (rev 729)
+++ code/trunk/ChangeLog    2017-04-04 11:37:21 UTC (rev 730)
@@ -34,6 +34,8 @@
   (d) Captures in negative assertions that were used as conditions were not
       happening if the assertion matched via (*ACCEPT).   


+  (e) Mark values were not being passed out of recursions. 
+      
 2. Now that pcre2_match() no longer uses recursive function calls (see above),
 the "match limit recursion" value seems misnamed. It still exists, and limits 
 the depth of tree that is searched. To avoid future confusion, it has been 


Modified: code/trunk/src/pcre2_match.c
===================================================================
--- code/trunk/src/pcre2_match.c    2017-04-03 18:02:07 UTC (rev 729)
+++ code/trunk/src/pcre2_match.c    2017-04-04 11:37:21 UTC (rev 730)
@@ -725,7 +725,8 @@
     where we know the starting frame is at the top of the chained frames, in
     this case we have to search back for the relevant frame in case other types
     of group that use chained frames have intervened. Multiple OP_CLOSEs always
-    come innermost first, which matches the chain order. */
+    come innermost first, which matches the chain order. We can ignore this in
+    a recursion, because captures are not passed out of recursions. */


     case OP_CLOSE:
     if (Fcurrent_recurse == RECURSE_UNSET)
@@ -746,15 +747,14 @@
       Fovector[offset+1] = Feptr - mb->start_subject;
       if (offset >= Foffset_top) Foffset_top = offset + 2;
       }
-
     Fecode += PRIV(OP_lengths)[*Fecode];
     break;



     /* ===================================================================== */
-    /* End of the pattern, either real or forced. In an assertion ACCEPT,
-    update the last used pointer and remember the current frame so that the
-    captures can be fished out of it. */
+    /* Real or forced end of the pattern, assertion, or recursion. In an
+    assertion ACCEPT, update the last used pointer and remember the current
+    frame so that the captures can be fished out of it. */


     case OP_ASSERT_ACCEPT:
     if (Feptr > mb->last_used_ptr) mb->last_used_ptr = Feptr;
@@ -761,8 +761,7 @@
     assert_accept_frame = F;
     RRETURN(MATCH_ACCEPT);


-    /* The real end, or top-level (*ACCEPT). If recursing, we have to find the
-    most recent recursion. */
+    /* If recursing, we have to find the most recent recursion. */


     case OP_ACCEPT:
     case OP_END:
@@ -782,10 +781,11 @@
         }


       /* 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 move on past the OP_RECURSE. */
+      OP_RECURSE position. Go back there, copying the current subject position
+      and mark, and move on past the OP_RECURSE. */


       P->eptr = Feptr;
+      P->mark = Fmark;
       F = P;
       Fecode += 1 + LINK_SIZE;
       continue;
@@ -5078,10 +5078,7 @@
         }
       }


-    /* Now run the recursion. If it successfully completes, it re-instates the
-    previous values of the captures and continues, just like a non-capturing
-    bracket. We must leave Fecode unchanged so that the ending code can find
-    out where to continue. */
+    /* Now run the recursion, branch by branch. */


     Lstart_branch = bracode;
     Lframe_type = GF_RECURSE | number;


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2017-04-03 18:02:07 UTC (rev 729)
+++ code/trunk/testdata/testinput2    2017-04-04 11:37:21 UTC (rev 730)
@@ -5005,5 +5005,10 @@
 /^ (?(DEFINE) (..(*ACCEPT)|...) ) (?1)$/x
 \= Expect no match
     abc
+    
+# Perl gives no match for this one


+/(a(*MARK:m)(*ACCEPT)){0}(?1)/mark
+    abc
+
 # End of testinput2 


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2017-04-03 18:02:07 UTC (rev 729)
+++ code/trunk/testdata/testoutput2    2017-04-04 11:37:21 UTC (rev 730)
@@ -15529,7 +15529,14 @@
 \= Expect no match
     abc
 No match
+    
+# Perl gives no match for this one


+/(a(*MARK:m)(*ACCEPT)){0}(?1)/mark
+    abc
+ 0: a
+MK: m
+
 # End of testinput2 
 Error -63: PCRE2_ERROR_BADDATA (unknown error number)
 Error -62: bad serialized data