regcomp.c: Process all POSIXes in [...] under /l
authorKarl Williamson <public@khwilliamson.com>
Wed, 29 Jan 2014 21:38:00 +0000 (14:38 -0700)
committerKarl Williamson <public@khwilliamson.com>
Wed, 29 Jan 2014 21:51:55 +0000 (14:51 -0700)
Commit 31f05a37 introduced a regression in which if you have something
like /[\s\d[:punct:]/, all but the final class were ignored.  This was
due to initialization happening every time through the loop, instead of
the first time needed.

regcomp.c
t/run/locale.t

index e4f6c86..dfbaec8 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13581,6 +13581,11 @@ parseit:
                 else {
                     RExC_emit += ANYOF_POSIXL_FOLD_SKIP - ANYOF_SKIP;
                 }
+
+                /* We need to initialize this here because this node type has
+                 * this field, and will skip getting initialized when we get to
+                 * a posix class since are doing it here */
+                ANYOF_POSIXL_ZERO(ret);
             }
             if (ANYOF_LOCALE == ANYOF_POSIXL
                 || (namedclass > OOB_NAMEDCLASS
@@ -13594,8 +13599,8 @@ parseit:
                     else {
                         RExC_emit += ANYOF_POSIXL_SKIP - ANYOF_SKIP;
                     }
+                    ANYOF_POSIXL_ZERO(ret);
                 }
-                ANYOF_POSIXL_ZERO(ret);
                 ANYOF_FLAGS(ret) |= ANYOF_POSIXL;
             }
         }
index fadb5d4..5e27e5b 100644 (file)
@@ -267,7 +267,19 @@ EOF
             1, {}, "/il matching of [bracketed] doesn't skip POSIX class if fails individ char");
     }
 
+    {
+        fresh_perl_is(<<"EOF",
+                use locale;
+                use POSIX;
+                POSIX::setlocale(POSIX::LC_CTYPE(),"C");
+                print "0" =~ /[\\d[:punct:]]/l || 0;
+                print "\\n";
+EOF
+            1, {}, "/l matching of [bracketed] doesn't skip non-first POSIX class");
+
+    }
+
 
 } # SKIP
 
-sub last { 16 }
+sub last { 17 }