regcomp.c: Optimizer could lose some info
authorKarl Williamson <public@khwilliamson.com>
Sun, 20 Mar 2011 00:33:17 +0000 (18:33 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sun, 20 Mar 2011 01:01:37 +0000 (19:01 -0600)
When ORing two nodes together for the synthetic start class, and one
matches outside the 256-char bitmap, we currently don't know what it
matches.  In some cases it could be some or all of those 256 characters.
If so, we have to assume it's all of them.

regcomp.c

index d6701ce..b247ee2 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -945,12 +945,19 @@ S_cl_or(const RExC_state_t *pRExC_state, struct regnode_charclass_class *cl, con
             * outside the bitmap, but what they match outside is not the same
             * pointer, and hence not easily compared until XXX we extend
             * inversion lists this far), give up and allow the start class to
-            * match everything outside the bitmap */
+            * match everything outside the bitmap.  If that stuff is all above
+            * 255, can just set UNICODE_ALL, otherwise caould be anything. */
            if (! ANYOF_NONBITMAP(cl)) {
                ARG_SET(cl, ARG(or_with));
            }
            else if (ARG(cl) != ARG(or_with)) {
-               cl->flags |= ANYOF_UNICODE_ALL;
+
+               if ((or_with->flags & ANYOF_NONBITMAP_NON_UTF8)) {
+                   cl_anything(pRExC_state, cl);
+               }
+               else {
+                   cl->flags |= ANYOF_UNICODE_ALL;
+               }
            }
 
         /* Take the union */