From: Jarkko Hietaniemi Date: Wed, 26 Jun 2002 18:25:51 +0000 (+0000) Subject: Further tweaking on the Unicode s///. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a176938c74b8176b4a677d188d6588d5e88332e;p=p5sagit%2Fp5-mst-13.2.git Further tweaking on the Unicode s///. p4raw-id: //depot/perl@17366 --- diff --git a/pp_hot.c b/pp_hot.c index 7837f64..ae1b1c2 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -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 f691aff..3fa6a9a 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;