Downgrading a fixed or floating substring of a pattern whilst matching
Nicholas Clark [Sun, 10 Dec 2006 22:31:56 +0000 (22:31 +0000)]
a studied string seems to get to a "should not happen" [bug #41067]
It seems that Perl_regexec_flags() assumes that if the pre-downgraded
substring is FBM compiled, then the downgraded version will be too,
hence changing the downgrade and upgrade routines to FBM compile seems
to be a correct fix.

p4raw-id: //depot/perl@29502

regexec.c
t/op/re_tests

index 2da8bfd..7cd7d5f 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -5621,6 +5621,8 @@ S_to_utf8_substr(pTHX_ register regexp *prog)
        SV* const sv = newSVsv(prog->float_substr);
        prog->float_utf8 = sv;
        sv_utf8_upgrade(sv);
+       if (SvVALID(prog->float_substr))
+           fbm_compile(sv, 0);
        if (SvTAIL(prog->float_substr))
            SvTAIL_on(sv);
        if (prog->float_substr == prog->check_substr)
@@ -5630,6 +5632,8 @@ S_to_utf8_substr(pTHX_ register regexp *prog)
        SV* const sv = newSVsv(prog->anchored_substr);
        prog->anchored_utf8 = sv;
        sv_utf8_upgrade(sv);
+       if (SvVALID(prog->anchored_substr))
+           fbm_compile(sv, 0);
        if (SvTAIL(prog->anchored_substr))
            SvTAIL_on(sv);
        if (prog->anchored_substr == prog->check_substr)
@@ -5645,6 +5649,8 @@ S_to_byte_substr(pTHX_ register regexp *prog)
        SV* sv = newSVsv(prog->float_utf8);
        prog->float_substr = sv;
        if (sv_utf8_downgrade(sv, TRUE)) {
+           if (SvVALID(prog->float_utf8))
+               fbm_compile(sv, 0);
            if (SvTAIL(prog->float_utf8))
                SvTAIL_on(sv);
        } else {
@@ -5658,6 +5664,8 @@ S_to_byte_substr(pTHX_ register regexp *prog)
        SV* sv = newSVsv(prog->anchored_utf8);
        prog->anchored_substr = sv;
        if (sv_utf8_downgrade(sv, TRUE)) {
+           if (SvVALID(prog->anchored_utf8))
+               fbm_compile(sv, 0);
            if (SvTAIL(prog->anchored_utf8))
                SvTAIL_on(sv);
        } else {
index d0f6ae3..48dbb79 100644 (file)
@@ -1013,6 +1013,7 @@ X(?<=foo.)[YZ]    ..XfooXY..      y       pos     8
 ^(??{q(.+)})\x{100}    \x{100}\x{100}  y       $&      \x{100}\x{100}
 ^(??{q(.)})\x{100}     \x{100}\x{100}  y       $&      \x{100}\x{100}
 ^(??{chr 0x100})\xbb   \x{100}\x{bb}   y       $&      \x{100}\x{bb}
+\x{100}?(??{""})xxx    xxx     y       $&      xxx
 ^(.)(??{"(.)(.)"})(.)$ abcd    y       $1-$2   a-d
 ^(.)(??{"(bz+|.)(.)"})(.)$     abcd    y       $1-$2   a-d
 ^(.)((??{"(.)(cz+)"})|.)       abcd    y       $1-$2   a-b