PATCH: [perl #120799] 5.18 regression with [:^ascii] and \x80-\xFF
authorKarl Williamson <public@khwilliamson.com>
Mon, 16 Dec 2013 17:59:36 +0000 (10:59 -0700)
committerKarl Williamson <public@khwilliamson.com>
Mon, 16 Dec 2013 18:25:03 +0000 (11:25 -0700)
Posix classes generally match different sets of characters under /d
rules than otherwise.  This isn't true for [:ascii:], but the handling
for it is shared with the others, so it needs to use the same mechanism
to deal with that.  I forgot this in commit
bb9ee97444732c84b33c2f2432aa28e52e4651dc which created this regression.

Our tests for this only use regexes with a single element, and an
optimization added in 5.18 causes this bug to be bypassed.  These tests
should be enhanced to force both code paths, but not for this commit,
which should be suitable for a maintenance release.

regcomp.c
t/re/re_tests

index 9727900..1bfdff1 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13398,12 +13398,21 @@ parseit:
                     }
                     else
 #endif  /* Not isascii(); just use the hard-coded definition for it */
+                    {
                         _invlist_union_maybe_complement_2nd(
                                 posixes,
                                 PL_Posix_ptrs[_CC_ASCII],
                                 cBOOL(namedclass % 2), /* Complement if odd
                                                           (NASCII) */
                                 &posixes);
+
+                        /* The code points 128-255 added above will be
+                         * subtracted out below under /d, so the flag needs to
+                         * be set */
+                        if (namedclass == ANYOF_NASCII && DEPENDS_SEMANTICS) {
+                            ANYOF_FLAGS(ret) |= ANYOF_NON_UTF8_LATIN1_ALL;
+                        }
+                    }
                 }
                 else {  /* Garden variety class */
 
index 18a34dd..633f561 100644 (file)
@@ -640,6 +640,7 @@ $(?<=^(a))  a       y       $1      a
 ([[:^alpha:]]+)        ABcd01Xy__--  ${nulnul}${ffff}  y       $1      01
 ((?a)[[:^alnum:]]+)    ABcd01Xy__--  ${nulnul}${ffff}  y       $1      __--  ${nulnul}${ffff}
 ([[:^ascii:]]+)        ABcd01Xy__--  ${nulnul}${ffff}  y       $1      ${ffff}
+([:[:^ascii:]]+)       ABcd01Xy__--  ${nulnul}${ffff}  y       $1      ${ffff} RT #120799
 ([[:^cntrl:]]+)        ABcd01Xy__--  ${nulnul}${ffff}  y       $1      ABcd01Xy__--  
 ([[:^digit:]]+)        ABcd01Xy__--  ${nulnul}${ffff}  y       $1      ABcd
 ([[:^lower:]]+)        ABcd01Xy__--  ${nulnul}${ffff}  y       $1      AB