[Pcre-svn] [1510] code/trunk: Fix bug when there are unset g…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [1510] code/trunk: Fix bug when there are unset groups prior to (*ACCEPT) within a capturing
Revision: 1510
          http://vcs.pcre.org/viewvc?view=rev&revision=1510
Author:   ph10
Date:     2014-11-05 15:08:03 +0000 (Wed, 05 Nov 2014)


Log Message:
-----------
Fix bug when there are unset groups prior to (*ACCEPT) within a capturing
group.

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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2014-10-10 13:03:55 UTC (rev 1509)
+++ code/trunk/ChangeLog    2014-11-05 15:08:03 UTC (rev 1510)
@@ -1,6 +1,18 @@
 ChangeLog for PCRE
 ------------------


+Version 8.37 xx-xxx-201x
+------------------------
+
+1.  When an (*ACCEPT) is triggered inside capturing parentheses, it arranges 
+    for those parentheses to be closed with whatever has been captured so far. 
+    However, it was failing to mark any other groups between the hightest 
+    capture so far and the currrent group as "unset". Thus, the ovector for 
+    those groups contained whatever was previously there. An example is the 
+    pattern /(x)|((*ACCEPT))/ when matched against "abcd".
+
+
+
 Version 8.36 26-September-2014
 ------------------------------



Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2014-10-10 13:03:55 UTC (rev 1509)
+++ code/trunk/pcre_exec.c    2014-11-05 15:08:03 UTC (rev 1510)
@@ -1474,7 +1474,18 @@
       md->offset_vector[offset] =
         md->offset_vector[md->offset_end - number];
       md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
-      if (offset_top <= offset) offset_top = offset + 2;
+
+      /* If this group is at or above the current highwater mark, ensure that
+      any groups between the current high water mark and this group are marked
+      unset and then update the high water mark. */
+
+      if (offset >= offset_top)
+        {
+        register int *iptr = md->offset_vector + offset_top;
+        register int *iend = md->offset_vector + offset;
+        while (iptr < iend) *iptr++ = -1;
+        offset_top = offset + 2;
+        }
       }
     ecode += 1 + IMM2_SIZE;
     break;


Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1    2014-10-10 13:03:55 UTC (rev 1509)
+++ code/trunk/testdata/testinput1    2014-11-05 15:08:03 UTC (rev 1510)
@@ -5720,4 +5720,7 @@
 /[\Q]a\E]+/
     aa]]


+/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
+    1234abcd
+
 /-- End of testinput1 --/


Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1    2014-10-10 13:03:55 UTC (rev 1509)
+++ code/trunk/testdata/testoutput1    2014-11-05 15:08:03 UTC (rev 1510)
@@ -9411,4 +9411,13 @@
     aa]]
  0: aa]]


+/(?:((abcd))|(((?:(?:(?:(?:abc|(?:abcdef))))b)abcdefghi)abc)|((*ACCEPT)))/
+    1234abcd
+ 0: 
+ 1: <unset>
+ 2: <unset>
+ 3: <unset>
+ 4: <unset>
+ 5: 
+
 /-- End of testinput1 --/