[Pcre-svn] [1372] code/trunk: Fix auto-callout with PCRE_UCP…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1372] code/trunk: Fix auto-callout with PCRE_UCP, which was compiling rubbish.
Revision: 1372
          http://vcs.pcre.org/viewvc?view=rev&revision=1372
Author:   ph10
Date:     2013-10-11 18:05:19 +0100 (Fri, 11 Oct 2013)


Log Message:
-----------
Fix auto-callout with PCRE_UCP, which was compiling rubbish.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput7
    code/trunk/testdata/testoutput7


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2013-10-11 10:59:41 UTC (rev 1371)
+++ code/trunk/ChangeLog    2013-10-11 17:05:19 UTC (rev 1372)
@@ -122,6 +122,10 @@
     but just skip it when running all tests. This make it awkward to run ranges 
     of tests when one of them was inappropriate. Now it just skips any 
     inappropriate tests, as it always did when running all tests.  
+    
+25. If PCRE_AUTO_CALLOUT and PCRE_UCP were set for a pattern that contained 
+    character types such as \d or \w, too many callouts were inserted, and the 
+    data that they returned was rubbish.  





Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2013-10-11 10:59:41 UTC (rev 1371)
+++ code/trunk/pcre_compile.c    2013-10-11 17:05:19 UTC (rev 1372)
@@ -4254,14 +4254,14 @@
       }
     }


-  /* Fill in length of a previous callout, except when the next thing is
-  a quantifier. */
-
   is_quantifier =
     c == CHAR_ASTERISK || c == CHAR_PLUS || c == CHAR_QUESTION_MARK ||
     (c == CHAR_LEFT_CURLY_BRACKET && is_counted_repeat(ptr+1));


-  if (!is_quantifier && previous_callout != NULL &&
+  /* Fill in length of a previous callout, except when the next thing is a
+  quantifier or when processing a property substitution string in UCP mode. */
+
+  if (!is_quantifier && previous_callout != NULL && nestptr == NULL &&
        after_manual_callout-- <= 0)
     {
     if (lengthptr == NULL)      /* Don't attempt in pre-compile phase */
@@ -4292,9 +4292,10 @@
       }
     }


- /* No auto callout for quantifiers. */
+ /* No auto callout for quantifiers, or while processing property strings that
+ are substituted for \w etc in UCP mode. */

-  if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier)
+  if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier && nestptr == NULL)
     {
     previous_callout = code;
     code = auto_callout(code, ptr, cd);


Modified: code/trunk/testdata/testinput7
===================================================================
--- code/trunk/testdata/testinput7    2013-10-11 10:59:41 UTC (rev 1371)
+++ code/trunk/testdata/testinput7    2013-10-11 17:05:19 UTC (rev 1372)
@@ -812,4 +812,7 @@


/-- End auto-possessification tests --/

+/\w+/8CWBZ
+    abcd
+
 /-- End of testinput7 --/


Modified: code/trunk/testdata/testoutput7
===================================================================
--- code/trunk/testdata/testoutput7    2013-10-11 10:59:41 UTC (rev 1371)
+++ code/trunk/testdata/testoutput7    2013-10-11 17:05:19 UTC (rev 1372)
@@ -2121,4 +2121,19 @@


/-- End auto-possessification tests --/

+/\w+/8CWBZ
+------------------------------------------------------------------
+        Bra
+        Callout 255 0 3
+        prop Xwd ++
+        Callout 255 3 0
+        Ket
+        End
+------------------------------------------------------------------
+    abcd
+--->abcd
+ +0 ^        \w+
+ +3 ^   ^    
+ 0: abcd
+
 /-- End of testinput7 --/