From 3c075feabc1b777553a63a5a7d87ef482f2e3d49 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 2 Feb 2014 22:30:10 -0700 Subject: [PATCH] PATCH [perl #121144]: \S, \W, etc fail for above ASCII There were three things wrong with these couple of lines of code.that help generate the synthetic start class (SSC). 1) It used PL_regkind, instead of straight OP. This meant that /u matches were treated the same as /d matches since they both have the same regkind. 2) For what it thought was just for /d, it used the complement of ASCII, which matches 128-INFINITY, whereas it wanted 128-255 only.. 3) It did a union of this complement, instead of a subtract of the non-complement, forgetting that we are about to complement the result, so that if we want the end result to have something, we better have the input not have that something, or the complementing will screw it up. --- regcomp.c | 10 ++++++---- t/re/re_tests | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/regcomp.c b/regcomp.c index bcd159c..884d9cc 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4912,10 +4912,12 @@ PerlIO_printf(Perl_debug_log, "LHS=%"UVdf" RHS=%"UVdf"\n", /* NPOSIXD matches all upper Latin1 code points unless the * target string being matched is UTF-8, which is - * unknowable until match time */ - if (PL_regkind[OP(scan)] == NPOSIXD) { - _invlist_union_complement_2nd(my_invlist, - PL_XPosix_ptrs[_CC_ASCII], &my_invlist); + * unknowable until match time. Since we are going to + * invert, we want to get rid of all of them so that the + * inversion will match all */ + if (OP(scan) == NPOSIXD) { + _invlist_subtract(my_invlist, PL_UpperLatin1, + &my_invlist); } join_posix: diff --git a/t/re/re_tests b/t/re/re_tests index 5033060..d5c66f7 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -1843,5 +1843,10 @@ A+(*PRUNE)BC(?{}) AAABC y $& AAABC # RT #120600: Variable length lookbehind is not variable (?a)(?(?=(?&W))(?<=(?&W)))(?&BB) aa y $& a # test repeated recursive patterns + +# This group is from RT #121144 +/^\S+=/d \x{3a3}=\x{3a0} y $& \x{3a3}= +/^\S+=/u \x{3a3}=\x{3a0} y $& \x{3a3}= + # Keep these lines at the end of the file # vim: softtabstop=0 noexpandtab -- 2.7.4