[Pcre-svn] [438] code/trunk: Fix internal error for forward …

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [438] code/trunk: Fix internal error for forward reference with [^m] interposing.
Revision: 438
          http://vcs.pcre.org/viewvc?view=rev&revision=438
Author:   ph10
Date:     2009-09-06 21:00:47 +0100 (Sun, 06 Sep 2009)


Log Message:
-----------
Fix internal error for forward reference with [^m] interposing.

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


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2009-09-06 16:34:42 UTC (rev 437)
+++ code/trunk/ChangeLog    2009-09-06 20:00:47 UTC (rev 438)
@@ -97,13 +97,22 @@
     these options useful.


 17. If a caller to the POSIX matching function regexec() passes a non-zero 
-    value for \fInmatch\fP with a NULL value for \fIpmatch\fP, the value of
-    \fInmatch\fP is forced to zero. 
+    value for nmatch with a NULL value for pmatch, the value of
+    nmatch is forced to zero. 


 18. RunGrepTest did not have a test for the availability of the -u option of
     the diff command, as RunTest does. It now checks in the same way as 
     RunTest, and also checks for the -b option.


+19. If an odd number of negated classes containing just a single character
+    interposed, within parentheses, between a forward reference to a named
+    subpattern and the definition of the subpattern, compilation crashed with 
+    an internal error, complaining that it could not find the referenced 
+    subpattern. An example of a crashing pattern is /(?&A)(([^m])(?<A>))/.
+    [The bug was that it was starting one character too far in when skipping 
+    over the character class, thus treating the ] as data rather than 
+    terminating the class. This meant it could skip too much.] 
+    


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

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2009-09-06 16:34:42 UTC (rev 437)
+++ code/trunk/pcre_compile.c    2009-09-06 20:00:47 UTC (rev 438)
@@ -1100,6 +1100,7 @@
       if (name != NULL && lorn == ptr - thisname &&
           strncmp((const char *)name, (const char *)thisname, lorn) == 0)
         return *count;
+      term++;   
       }
     }
   }
@@ -1134,19 +1135,21 @@
     BOOL negate_class = FALSE;
     for (;;)
       {
-      int c = *(++ptr);
-      if (c == CHAR_BACKSLASH)
+      if (ptr[1] == CHAR_BACKSLASH)
         {
-        if (ptr[1] == CHAR_E)
-          ptr++;
-        else if (strncmp((const char *)ptr+1,
+        if (ptr[2] == CHAR_E)
+          ptr+= 2;
+        else if (strncmp((const char *)ptr+2,
                  STR_Q STR_BACKSLASH STR_E, 3) == 0)
-          ptr += 3;
+          ptr += 4;
         else
           break;
         }
-      else if (!negate_class && c == CHAR_CIRCUMFLEX_ACCENT)
+      else if (!negate_class && ptr[1] == CHAR_CIRCUMFLEX_ACCENT)
+        { 
         negate_class = TRUE;
+        ptr++;
+        }  
       else break;
       }



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2009-09-06 16:34:42 UTC (rev 437)
+++ code/trunk/testdata/testinput2    2009-09-06 20:00:47 UTC (rev 438)
@@ -2957,4 +2957,8 @@
     +++ab\P
     +++ab\P\P  


+/(?&word)(?&element)(?(DEFINE)(?<element><[^m][^>]>[^<])(?<word>\w*+))/BZ
+
+/(?&word)(?&element)(?(DEFINE)(?<element><[^\d][^>]>[^<])(?<word>\w*+))/BZ
+
/ End of testinput2 /

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2009-09-06 16:34:42 UTC (rev 437)
+++ code/trunk/testdata/testoutput2    2009-09-06 20:00:47 UTC (rev 438)
@@ -9996,4 +9996,56 @@
     +++ab\P\P  
 Partial match: +ab


+/(?&word)(?&element)(?(DEFINE)(?<element><[^m][^>]>[^<])(?<word>\w*+))/BZ
+------------------------------------------------------------------
+        Bra
+        Once
+        Recurse
+        Ket
+        Once
+        Recurse
+        Ket
+        Cond
+        Cond def
+        CBra 1
+        <
+        [^m]
+        [^>]
+        >
+        [^<]
+        Ket
+        CBra 2
+        \w*+
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
+/(?&word)(?&element)(?(DEFINE)(?<element><[^\d][^>]>[^<])(?<word>\w*+))/BZ
+------------------------------------------------------------------
+        Bra
+        Once
+        Recurse
+        Ket
+        Once
+        Recurse
+        Ket
+        Cond
+        Cond def
+        CBra 1
+        <
+        [\x00-/:-\xff] (neg)
+        [^>]
+        >
+        [^<]
+        Ket
+        CBra 2
+        \w*+
+        Ket
+        Ket
+        Ket
+        End
+------------------------------------------------------------------
+
 / End of testinput2 /