diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2002-06-26 18:25:51 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-06-26 18:25:51 +0000 |
commit | 4a176938c74b8176b4a677d188d6588d5e88332e (patch) | |
tree | f57943180f8cd708f8030dad1f0f09374754800f | |
parent | d38487415f5c04a655b8d9a86fe64aa945ae1cba (diff) | |
download | perl-4a176938c74b8176b4a677d188d6588d5e88332e.tar.gz |
Further tweaking on the Unicode s///.
p4raw-id: //depot/perl@17366
-rw-r--r-- | pp_hot.c | 10 | ||||
-rwxr-xr-x | t/op/subst.t | 2 |
2 files changed, 8 insertions, 4 deletions
@@ -1983,16 +1983,20 @@ PP(pp_subst) /* known replacement string? */ if (dstr) { - c = SvPV(dstr, clen); - doutf8 = DO_UTF8(dstr); /* replacement needing upgrading? */ if (DO_UTF8(TARG) && !doutf8) { - SV *nsv = sv_2mortal(newSVpvn(c, clen)); + SV *nsv = sv_newmortal(); + SvSetSV(nsv, dstr); if (PL_encoding) sv_recode_to_utf8(nsv, PL_encoding); else sv_utf8_upgrade(nsv); c = SvPV(nsv, clen); + doutf8 = TRUE; + } + else { + c = SvPV(dstr, clen); + doutf8 = DO_UTF8(dstr); } } else { diff --git a/t/op/subst.t b/t/op/subst.t index f691aff957..3fa6a9aef3 100755 --- a/t/op/subst.t +++ b/t/op/subst.t @@ -408,7 +408,7 @@ is($pv1, $pv2); $a = "\x{100}\x{101}"; $a =~ s/\x{101}/\xFF/; like($a, qr/\xFF/); - is(length($a), 2); + is(length($a), 2, "SADAHIRO utf8 s///"); $a = "\x{100}\x{101}"; $a =~ s/\x{101}/"\xFF"/e; |