[Pcre-svn] [446] code/trunk: Correct returned capture count …

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [446] code/trunk: Correct returned capture count after recursion has matched more than outer .
Revision: 446
          http://vcs.pcre.org/viewvc?view=rev&revision=446
Author:   ph10
Date:     2009-09-15 11:49:50 +0100 (Tue, 15 Sep 2009)


Log Message:
-----------
Correct returned capture count after recursion has matched more than outer.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_exec.c
    code/trunk/pcre_internal.h


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2009-09-13 16:44:49 UTC (rev 445)
+++ code/trunk/ChangeLog    2009-09-15 10:49:50 UTC (rev 446)
@@ -118,6 +118,11 @@
     to have an empty string match not at the start, even when the pattern is
     anchored. Updated pcretest and pcredemo to use this option.  


+21. If the maximum number of capturing subpatterns in a recursion was greater
+    than the maximum at the outer level, the higher number was returned, but 
+    with unset values at the outer level. The correct (outer level) value is 
+    now given.
+    


Version 7.9 11-Apr-09
---------------------

Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2009-09-13 16:44:49 UTC (rev 445)
+++ code/trunk/pcre_exec.c    2009-09-15 10:49:50 UTC (rev 446)
@@ -924,6 +924,7 @@
       md->recursive = rec->prevrec;
       memmove(md->offset_vector, rec->offset_save,
         rec->saved_max * sizeof(int));
+      offset_top = rec->offset_top;   
       mstart = rec->save_start;
       ims = original_ims;
       ecode = rec->after_call;
@@ -1115,6 +1116,7 @@
       memcpy(new_recursive.offset_save, md->offset_vector,
             new_recursive.saved_max * sizeof(int));
       new_recursive.save_start = mstart;
+      new_recursive.offset_top = offset_top; 
       mstart = eptr;


       /* OK, now we can do the recursion. For each top-level alternative we
@@ -1313,7 +1315,7 @@
       {
       number = GET2(prev, 1+LINK_SIZE);
       offset = number << 1;
-
+      
 #ifdef DEBUG
       printf("end bracket %d", number);
       printf("\n");
@@ -1339,6 +1341,7 @@
         mstart = rec->save_start;
         memcpy(md->offset_vector, rec->offset_save,
           rec->saved_max * sizeof(int));
+        offset_top = rec->offset_top;   
         ecode = rec->after_call;
         ims = original_ims;
         break;
@@ -5408,7 +5411,7 @@
   too many to fit into the vector. */


rc = md->offset_overflow? 0 : md->end_offset_top/2;
-
+
/* If there is space, set up the whole thing as substring 0. The value of
md->start_match_ptr might be modified if \K was encountered on the success
matching path. */

Modified: code/trunk/pcre_internal.h
===================================================================
--- code/trunk/pcre_internal.h    2009-09-13 16:44:49 UTC (rev 445)
+++ code/trunk/pcre_internal.h    2009-09-15 10:49:50 UTC (rev 446)
@@ -1568,6 +1568,7 @@
   USPTR save_start;             /* Old value of mstart */
   int *offset_save;             /* Pointer to start of saved offsets */
   int saved_max;                /* Number of saved offsets */
+  int offset_top;               /* Current value of offset_top */ 
 } recursion_info;


/* Structure for building a chain of data for holding the values of the subject