[Pcre-svn] [940] code/trunk: Previous patch to fix (*COMMIT)…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [940] code/trunk: Previous patch to fix (*COMMIT) in assertions was bad; fix it.
Revision: 940
          http://vcs.pcre.org/viewvc?view=rev&revision=940
Author:   ph10
Date:     2012-02-28 10:30:51 +0000 (Tue, 28 Feb 2012)


Log Message:
-----------
Previous patch to fix (*COMMIT) in assertions was bad; fix it.

Modified Paths:
--------------
    code/trunk/pcre_exec.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2012-02-26 17:21:43 UTC (rev 939)
+++ code/trunk/pcre_exec.c    2012-02-28 10:30:51 UTC (rev 940)
@@ -1575,15 +1575,18 @@
         mstart = md->start_match_ptr;   /* In case \K reset it */
         break;
         }
+      md->mark = save_mark;


-      /* PCRE does not allow THEN or COMMIT to escape beyond an assertion; it
+      /* A COMMIT failure must fail the entire assertion, without trying any 
+      subsequent branches. */
+    
+      if (rrc == MATCH_COMMIT) RRETURN(MATCH_NOMATCH);
+
+      /* PCRE does not allow THEN to escape beyond an assertion; it
       is treated as NOMATCH. */


-      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN &&
-          rrc != MATCH_COMMIT) RRETURN(rrc);
-           
+      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
       ecode += GET(ecode, 1);
-      md->mark = save_mark;
       }
     while (*ecode == OP_ALT);



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2012-02-26 17:21:43 UTC (rev 939)
+++ code/trunk/testdata/testinput2    2012-02-28 10:30:51 UTC (rev 940)
@@ -3733,10 +3733,13 @@
     \r\r\r\P
     \r\r\r\P\P     


-/-- This one is here because Perl does not match: it seems to allow the COMMIT
-to escape from the assertion. --/
+/-- These two are here because Perl does not match: it seems to allow the
+COMMIT to escape from the assertion. --/

 /(?=a(*COMMIT)b|ac)ac|ac/
     ac


+/(?=a(*COMMIT)b|(ac)) ac | (a)c/x
+    ac
+
 /-- End of testinput2 --/


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2012-02-26 17:21:43 UTC (rev 939)
+++ code/trunk/testdata/testoutput2    2012-02-28 10:30:51 UTC (rev 940)
@@ -12271,11 +12271,17 @@
     \r\r\r\P\P     
  0: \x0d\x0d


-/-- This one is here because Perl does not match: it seems to allow the COMMIT
-to escape from the assertion. --/
+/-- These two are here because Perl does not match: it seems to allow the
+COMMIT to escape from the assertion. --/

 /(?=a(*COMMIT)b|ac)ac|ac/
     ac
  0: ac


+/(?=a(*COMMIT)b|(ac)) ac | (a)c/x
+    ac
+ 0: ac
+ 1: <unset>
+ 2: a
+
 /-- End of testinput2 --/