Skip to content

Commit

Permalink
make empty string regexp stringify to the same thing regardless of un…
Browse files Browse the repository at this point in the history
…icode flags
  • Loading branch information
demerphq committed Dec 4, 2010
1 parent d6bd454 commit 5b6010b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 4 additions & 5 deletions regcomp.c
Expand Up @@ -4413,8 +4413,10 @@ Perl_re_compile(pTHX_ SV * const pattern, U32 pm_flags)

DEBUG_r(if (!PL_colorset) reginitcolors());

RExC_utf8 = RExC_orig_utf8 = SvUTF8(pattern);

exp = SvPV(pattern, plen);
xend = exp + plen;
/* ignore the utf8ness if the string is 0 length */
RExC_utf8 = RExC_orig_utf8 = plen > 0 && SvUTF8(pattern);

/****************** LONG JUMP TARGET HERE***********************/
/* Longjmp back to here if have to switch in midstream to utf8 */
Expand All @@ -4423,9 +4425,6 @@ Perl_re_compile(pTHX_ SV * const pattern, U32 pm_flags)
}

if (jump_ret == 0) { /* First time through */
exp = SvPV(pattern, plen);
xend = exp + plen;

DEBUG_COMPILE_r({
SV *dsv= sv_newmortal();
RE_PV_QUOTED_DECL(s, RExC_utf8,
Expand Down
13 changes: 12 additions & 1 deletion t/re/pat.t
Expand Up @@ -23,7 +23,7 @@ BEGIN {
}


plan tests => 408; # Update this when adding/deleting tests.
plan tests => 410; # Update this when adding/deleting tests.

run_tests() unless caller;

Expand Down Expand Up @@ -1135,6 +1135,17 @@ sub run_tests {
iseq( eval q#my $r; my $t = "a"; $r = $t =~ s/a//for 1;"eval_ok $r"#, "eval_ok 1", "regex (s///) followed by foreach");
}

{
my $str= "\x{100}";
chop $str;
my $qr= qr/$str/;
iseq( "$qr", "(?^:)", "Empty pattern qr// stringifies to (?^:) with unicode flag enabled - Bug #80212" );
$str= "";
$qr= qr/$str/;
iseq( "$qr", "(?^:)", "Empty pattern qr// stringifies to (?^:) with unicode flag disabled - Bug #80212" )

}

} # End of sub run_tests

1;

0 comments on commit 5b6010b

Please sign in to comment.