regcomp.c: RT#77414. Initialize flag
authorKarl Williamson <public@khwilliamson.com>
Sun, 20 Mar 2011 00:41:48 +0000 (18:41 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sun, 20 Mar 2011 01:01:37 +0000 (19:01 -0600)
As indicated in the comments, this flag needs to be initialized to
1 or the optimizer loses the fact that something could match a
character that isn't in utf8 and whose bitmap bit isn't set.  This
happens, for example, with Unicode properties.

Thus this fixes #77414.  That ticket had been closed recently because
it went away due to another patch that caused the optimizer to be
bypassed in the cases tested for.  But when that patch was reverted,
and cleaned-up, this bug came back.  Now, I believe I have found the
root cause.

regcomp.c
t/re/pat.t

index b48fb57..8797058 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -728,7 +728,15 @@ S_cl_anything(const RExC_state_t *pRExC_state, struct regnode_charclass_class *c
 
     ANYOF_BITMAP_SETALL(cl);
     cl->flags = ANYOF_CLASS|ANYOF_EOS|ANYOF_UNICODE_ALL
-               |ANYOF_LOC_NONBITMAP_FOLD|ANYOF_NON_UTF8_LATIN1_ALL;
+               |ANYOF_LOC_NONBITMAP_FOLD|ANYOF_NON_UTF8_LATIN1_ALL
+                   /* Even though no bitmap is in use here, we need to set
+                    * the flag below so an AND with a node that does have one
+                    * doesn't lose that one.  The flag should get cleared if
+                    * the other one doesn't; and the code in regexec.c is
+                    * structured so this being set when not needed does no
+                    * harm.  It seemed a little cleaner to set it here than do
+                    * a special case in cl_and() */
+               |ANYOF_NONBITMAP_NON_UTF8;
 
     /* If any portion of the regex is to operate under locale rules,
      * initialization includes it.  The reason this isn't done for all regexes
index b66d939..4ef9663 100644 (file)
@@ -1030,7 +1030,6 @@ sub run_tests {
 
         my $message = '\p property after empty * match';
         {
-            local $::TODO = "Bug 77414";
             like("1", qr/\s*\pN/, $message);
             like("-", qr/\s*\p{Dash}/, $message);
             like(" ", qr/\w*\p{Blank}/, $message);