From: Nicholas Clark Date: Sun, 10 Dec 2006 22:31:56 +0000 (+0000) Subject: Downgrading a fixed or floating substring of a pattern whilst matching X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0b3e77ec2e46a23afe97475f6b9bf7880fae85f1;p=p5sagit%2Fp5-mst-13.2.git Downgrading a fixed or floating substring of a pattern whilst matching 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 --- diff --git a/regexec.c b/regexec.c index 2da8bfd..7cd7d5f 100644 --- 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 { diff --git a/t/op/re_tests b/t/op/re_tests index d0f6ae3..48dbb79 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -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