[Pcre-svn] [832] code/branches/pcre16: Fix back references w…

Startseite
Nachricht löschen
Autor: Subversion repository
Datum:  
To: pcre-svn
Betreff: [Pcre-svn] [832] code/branches/pcre16: Fix back references with zero minimum repeat when the reference is unset.
Revision: 832
          http://vcs.pcre.org/viewvc?view=rev&revision=832
Author:   ph10
Date:     2011-12-27 17:32:22 +0000 (Tue, 27 Dec 2011)


Log Message:
-----------
Fix back references with zero minimum repeat when the reference is unset.

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


Modified: code/branches/pcre16/ChangeLog
===================================================================
--- code/branches/pcre16/ChangeLog    2011-12-27 16:53:09 UTC (rev 831)
+++ code/branches/pcre16/ChangeLog    2011-12-27 17:32:22 UTC (rev 832)
@@ -1,7 +1,7 @@
 ChangeLog for PCRE
 ------------------


-Version 8.22
+Version 8.30
------------

 1.  Renamed "isnumber" as "is_a_number" because in some Mac environments this
@@ -17,6 +17,11 @@
     match a (*MARK), and the match failed at the start of the subject, a 
     reference to memory before the start of the subject could occur. This bug 
     was introduced by fix 17 of release 8.21.
+    
+5.  A reference to an unset group with zero minimum repetition was giving
+    totally wrong answers (in non-JavaScript-compatibility mode). For example,
+    /(another)?(\1?)test/ matched against "hello world test". This bug was 
+    introduced in release 8.13.



Version 8.21 12-Dec-2011

Modified: code/branches/pcre16/pcre_exec.c
===================================================================
--- code/branches/pcre16/pcre_exec.c    2011-12-27 16:53:09 UTC (rev 831)
+++ code/branches/pcre16/pcre_exec.c    2011-12-27 17:32:22 UTC (rev 832)
@@ -2630,9 +2630,13 @@
       }


     /* Handle repeated back references. If the length of the reference is
-    zero, just continue with the main loop. */
+    zero, just continue with the main loop. If the length is negative, it
+    means the reference is unset in non-Java-compatible mode. If the minimum is 
+    zero, we can continue at the same level without recursion. For any other 
+    minimum, carrying on will result in NOMATCH. */


     if (length == 0) continue;
+    if (length < 0 && min == 0) continue;


     /* First, ensure the minimum number of matches are present. We get back
     the length of the reference string explicitly rather than passing the


Modified: code/branches/pcre16/testdata/testinput1
===================================================================
--- code/branches/pcre16/testdata/testinput1    2011-12-27 16:53:09 UTC (rev 831)
+++ code/branches/pcre16/testdata/testinput1    2011-12-27 17:32:22 UTC (rev 832)
@@ -5244,4 +5244,10 @@
     ** Failers
     abpq  


+/(another)?(\1?)test/
+    hello world test
+
+/(another)?(\1+)test/
+    hello world test
+
 /-- End of testinput1 --/


Modified: code/branches/pcre16/testdata/testoutput1
===================================================================
--- code/branches/pcre16/testdata/testoutput1    2011-12-27 16:53:09 UTC (rev 831)
+++ code/branches/pcre16/testdata/testoutput1    2011-12-27 17:32:22 UTC (rev 832)
@@ -8705,4 +8705,14 @@
     abpq  
 No match


+/(another)?(\1?)test/
+    hello world test
+ 0: test
+ 1: <unset>
+ 2: 
+
+/(another)?(\1+)test/
+    hello world test
+No match
+
 /-- End of testinput1 --/