regcomp.c: /l uses the \w, etc. classes
authorKarl Williamson <public@khwilliamson.com>
Sun, 20 Mar 2011 00:37:53 +0000 (18:37 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sun, 20 Mar 2011 01:01:37 +0000 (19:01 -0600)
For non-locale, \d, etc are compiled in with their actual code points they
match, so the class portion of the synthetic start class node is
irrelevant, and should initialized to zero to avoid confusion.  But for
locale it is highly relevant, and should be initialized to all ones, to
indicate matching anything.

regcomp.c

index b247ee2..b48fb57 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -727,7 +727,6 @@ S_cl_anything(const RExC_state_t *pRExC_state, struct regnode_charclass_class *c
     PERL_ARGS_ASSERT_CL_ANYTHING;
 
     ANYOF_BITMAP_SETALL(cl);
-    ANYOF_CLASS_ZERO(cl);      /* all bits set, so class is irrelevant */
     cl->flags = ANYOF_CLASS|ANYOF_EOS|ANYOF_UNICODE_ALL
                |ANYOF_LOC_NONBITMAP_FOLD|ANYOF_NON_UTF8_LATIN1_ALL;
 
@@ -739,8 +738,12 @@ S_cl_anything(const RExC_state_t *pRExC_state, struct regnode_charclass_class *c
      * parts of it may not work properly, it is safest to avoid locale unless
      * necessary. */
     if (RExC_contains_locale) {
+       ANYOF_CLASS_SETALL(cl);     /* /l uses class */
        cl->flags |= ANYOF_LOCALE;
     }
+    else {
+       ANYOF_CLASS_ZERO(cl);       /* Only /l uses class now */
+    }
 }
 
 /* Can match anything (initialization) */