[Pcre-svn] [1048] code/trunk: Fix bugs in new caseless suppo…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1048] code/trunk: Fix bugs in new caseless support code in the auto-possessifying function.
Revision: 1048
          http://vcs.pcre.org/viewvc?view=rev&revision=1048
Author:   ph10
Date:     2012-09-28 17:03:14 +0100 (Fri, 28 Sep 2012)


Log Message:
-----------
Fix bugs in new caseless support code in the auto-possessifying function.

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


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2012-09-28 15:06:38 UTC (rev 1047)
+++ code/trunk/pcre_compile.c    2012-09-28 16:03:14 UTC (rev 1048)
@@ -3036,7 +3036,8 @@
 check_auto_possessive(const pcre_uchar *previous, BOOL utf,
   const pcre_uchar *ptr, int options, compile_data *cd)
 {
-pcre_int32 c, next;
+pcre_int32 c = NOTACHAR;
+pcre_int32 next;
 int op_code = *previous++;


/* Skip whitespace and comments in extended mode */
@@ -3123,16 +3124,18 @@
}

/* Now compare the next item with the previous opcode. First, handle cases when
-the next item is a character. For a caseless UTF match, the next character may
-have more than one other case; convert this to a special property. */
+the next item is a character. */

 if (next >= 0)
   {
+  /* For a caseless UTF match, the next character may have more than one other
+  case, which maps to the special PT_CLIST property. Check this first. */
+ 
 #ifdef SUPPORT_UCP
-  if (utf && (options & PCRE_CASELESS) != 0)
+  if (utf && (unsigned int)c != NOTACHAR && (options & PCRE_CASELESS) != 0)
     {
     int ocs = UCD_CASESET(next);
-    if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, FALSE);
+    if (ocs > 0) return check_char_prop(c, PT_CLIST, ocs, op_code >= OP_NOT);
     }
 #endif



Modified: code/trunk/testdata/testinput7
===================================================================
--- code/trunk/testdata/testinput7    2012-09-28 15:06:38 UTC (rev 1047)
+++ code/trunk/testdata/testinput7    2012-09-28 16:03:14 UTC (rev 1048)
@@ -647,4 +647,10 @@
     ** Failers
     \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}


+/\x{3a3}*\x{3c2}/8iBZ
+
+/[^\x{3a3}]*\x{3c2}/8iBZ
+
+/[^a]*\x{3c2}/8iBZ
+
/-- End of testinput7 --/

Modified: code/trunk/testdata/testoutput7
===================================================================
--- code/trunk/testdata/testoutput7    2012-09-28 15:06:38 UTC (rev 1047)
+++ code/trunk/testdata/testoutput7    2012-09-28 16:03:14 UTC (rev 1048)
@@ -1413,4 +1413,31 @@
     \x{3a3}\x{3c3}\x{3c2}\x{3a3}\x{3c3}\x{3c2}
 No match


+/\x{3a3}*\x{3c2}/8iBZ
+------------------------------------------------------------------
+        Bra
+        clist 03a3 03c2 03c3 *
+        clist 03a3 03c2 03c3
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^\x{3a3}]*\x{3c2}/8iBZ
+------------------------------------------------------------------
+        Bra
+        not clist 03a3 03c2 03c3 *+
+        clist 03a3 03c2 03c3
+        Ket
+        End
+------------------------------------------------------------------
+
+/[^a]*\x{3c2}/8iBZ
+------------------------------------------------------------------
+        Bra
+     /i [^a]*
+        clist 03a3 03c2 03c3
+        Ket
+        End
+------------------------------------------------------------------
+
 /-- End of testinput7 --/