[Pcre-svn] [1532] code/trunk: Fix bad compile of patterns li…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [1532] code/trunk: Fix bad compile of patterns like /[A-`]/ i8 where the range contains
Revision: 1532
          http://vcs.pcre.org/viewvc?view=rev&revision=1532
Author:   ph10
Date:     2015-03-06 11:59:39 +0000 (Fri, 06 Mar 2015)


Log Message:
-----------
Fix bad compile of patterns like /[A-`]/i8 where the range contains
characters with multiple other cases and the ranges adjoin.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput6
    code/trunk/testdata/testoutput6


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-03-06 07:44:16 UTC (rev 1531)
+++ code/trunk/ChangeLog    2015-03-06 11:59:39 UTC (rev 1532)
@@ -93,7 +93,12 @@
     existing and future issues, size computation is eliminated from the code,
     and replaced by on-demand memory allocation.


+25. A pattern such as /(?i)[A-`]/, where characters in the other case are
+    adjacent to the end of the range, and the range contained characters with
+    more than one other case, caused incorrect behaviour when compiled in UTF
+    mode. In that example, the range a-j was left out of the class.


+
Version 8.36 26-September-2014
------------------------------


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2015-03-06 07:44:16 UTC (rev 1531)
+++ code/trunk/pcre_compile.c    2015-03-06 11:59:39 UTC (rev 1532)
@@ -4002,7 +4002,7 @@
   /* See if this recursion is on the forward reference list. If so, adjust the
   reference. */


-  for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm; 
+  for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
        hc += LINK_SIZE)
     {
     offset = (int)GET(hc, 0);
@@ -4208,7 +4208,11 @@
       range. Otherwise, use a recursive call to add the additional range. */


       else if (oc < start && od >= start - 1) start = oc; /* Extend downwards */
-      else if (od > end && oc <= end + 1) end = od;       /* Extend upwards */
+      else if (od > end && oc <= end + 1)
+        {
+        end = od;       /* Extend upwards */
+        if (end > classbits_end) classbits_end = (end <= 0xff ? end : 0xff);
+        }
       else n8 += add_to_class(classbits, uchardptr, options, cd, oc, od);
       }
     }
@@ -6052,15 +6056,15 @@
               memcpy(code, previous, IN_UCHARS(len));


               while (cd->hwm > cd->start_workspace + cd->workspace_size -
-                     WORK_SIZE_SAFETY_MARGIN - 
+                     WORK_SIZE_SAFETY_MARGIN -
                      (this_hwm_offset - save_hwm_offset))
                 {
                 *errorcodeptr = expand_workspace(cd);
                 if (*errorcodeptr != 0) goto FAILED;
                 }


-              for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; 
-                   hc < (pcre_uchar *)cd->start_workspace + this_hwm_offset; 
+              for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset;
+                   hc < (pcre_uchar *)cd->start_workspace + this_hwm_offset;
                    hc += LINK_SIZE)
                 {
                 PUT(cd->hwm, 0, GET(hc, 0) + len);
@@ -6133,15 +6137,15 @@
           copying them. */


           while (cd->hwm > cd->start_workspace + cd->workspace_size -
-                 WORK_SIZE_SAFETY_MARGIN - 
+                 WORK_SIZE_SAFETY_MARGIN -
                  (this_hwm_offset - save_hwm_offset))
             {
             *errorcodeptr = expand_workspace(cd);
             if (*errorcodeptr != 0) goto FAILED;
             }


-          for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; 
-               hc < (pcre_uchar *)cd->start_workspace + this_hwm_offset; 
+          for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset;
+               hc < (pcre_uchar *)cd->start_workspace + this_hwm_offset;
                hc += LINK_SIZE)
             {
             PUT(cd->hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));


Modified: code/trunk/testdata/testinput6
===================================================================
--- code/trunk/testdata/testinput6    2015-03-06 07:44:16 UTC (rev 1531)
+++ code/trunk/testdata/testinput6    2015-03-06 11:59:39 UTC (rev 1532)
@@ -1496,4 +1496,7 @@
 /^s?c/mi8
     scat


+/[A-`]/i8
+    abcdefghijklmno
+
 /-- End of testinput6 --/


Modified: code/trunk/testdata/testoutput6
===================================================================
--- code/trunk/testdata/testoutput6    2015-03-06 07:44:16 UTC (rev 1531)
+++ code/trunk/testdata/testoutput6    2015-03-06 11:59:39 UTC (rev 1532)
@@ -2461,4 +2461,8 @@
     scat
  0: sc


+/[A-`]/i8
+    abcdefghijklmno
+ 0: a
+
 /-- End of testinput6 --/