[Pcre-svn] [511] code/trunk: Make (*ACCEPT) work inside an a…

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [511] code/trunk: Make (*ACCEPT) work inside an atomic group.
Revision: 511
          http://vcs.pcre.org/viewvc?view=rev&revision=511
Author:   ph10
Date:     2010-03-29 10:25:38 +0100 (Mon, 29 Mar 2010)


Log Message:
-----------
Make (*ACCEPT) work inside an atomic group.

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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-03-27 17:45:29 UTC (rev 510)
+++ code/trunk/ChangeLog    2010-03-29 09:25:38 UTC (rev 511)
@@ -6,6 +6,8 @@


 1.  Added support for (*MARK:ARG) and for ARG additions to PRUNE, SKIP, and 
     THEN.
+    
+2.  (*ACCEPT) was not working when inside an atomic group. 



Version 8.02 19-Mar-2010

Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2010-03-27 17:45:29 UTC (rev 510)
+++ code/trunk/pcre_exec.c    2010-03-29 09:25:38 UTC (rev 511)
@@ -71,11 +71,12 @@
 /* Special internal returns from the match() function. Make them sufficiently
 negative to avoid the external error codes. */


-#define MATCH_COMMIT       (-999)
-#define MATCH_PRUNE        (-998)
-#define MATCH_SKIP         (-997)
-#define MATCH_SKIP_ARG     (-996)
-#define MATCH_THEN         (-995)
+#define MATCH_ACCEPT       (-999)
+#define MATCH_COMMIT       (-998)
+#define MATCH_PRUNE        (-997)
+#define MATCH_SKIP         (-996)
+#define MATCH_SKIP_ARG     (-995)
+#define MATCH_THEN         (-994)


/* This is a convenience macro for code that occurs many times. */

@@ -1157,7 +1158,7 @@
     md->end_match_ptr = eptr;           /* Record where we ended */
     md->end_offset_top = offset_top;    /* and how many extracts were taken */
     md->start_match_ptr = mstart;       /* and the start (\K can modify) */
-    MRRETURN(MATCH_MATCH);
+    MRRETURN(((op == OP_END)? MATCH_MATCH : MATCH_ACCEPT));


     /* Change option settings */


@@ -1179,7 +1180,7 @@
       {
       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
         RM4);
-      if (rrc == MATCH_MATCH)
+      if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
         {
         mstart = md->start_match_ptr;   /* In case \K reset it */
         break;
@@ -1212,7 +1213,7 @@
       {
       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
         RM5);
-      if (rrc == MATCH_MATCH) MRRETURN(MATCH_NOMATCH);
+      if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);
       if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
         {
         do ecode += GET(ecode,1); while (*ecode == OP_ALT);
@@ -1347,7 +1348,7 @@
         {
         RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
           md, ims, eptrb, flags, RM6);
-        if (rrc == MATCH_MATCH)
+        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
           {
           DPRINTF(("Recursion matched\n"));
           md->recursive = new_recursive.prevrec;
@@ -1393,7 +1394,7 @@
     do
       {
       RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
-      if (rrc == MATCH_MATCH)
+      if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
         {
         mstart = md->start_match_ptr;
         break;
@@ -5823,7 +5824,7 @@


ENDLOOP:

-if (rc == MATCH_MATCH)
+if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
   {
   if (using_temporary_offsets)
     {


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2010-03-27 17:45:29 UTC (rev 510)
+++ code/trunk/testdata/testinput2    2010-03-29 09:25:38 UTC (rev 511)
@@ -3438,5 +3438,19 @@


 /^(ab (c+(*FAIL)cd) | xyz)/x
     abcccd  
+    
+/--- Perl 5.11 gets some of these wrong ---/ 


+/(?>.(*ACCEPT))*?5/
+    abcde
+
+/(.(*ACCEPT))*?5/
+    abcde
+
+/(.(*ACCEPT))5/
+    abcde
+
+/(.(*ACCEPT))*5/
+    abcde
+
 /-- End of testinput2 --/


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2010-03-27 17:45:29 UTC (rev 510)
+++ code/trunk/testdata/testoutput2    2010-03-29 09:25:38 UTC (rev 511)
@@ -10981,5 +10981,26 @@
 /^(ab (c+(*FAIL)cd) | xyz)/x
     abcccd  
 No match
+    
+/--- Perl 5.11 gets some of these wrong ---/ 


+/(?>.(*ACCEPT))*?5/
+    abcde
+ 0: a
+
+/(.(*ACCEPT))*?5/
+    abcde
+ 0: a
+ 1: a
+
+/(.(*ACCEPT))5/
+    abcde
+ 0: a
+ 1: a
+
+/(.(*ACCEPT))*5/
+    abcde
+ 0: a
+ 1: a
+
 /-- End of testinput2 --/