From: Gurusamy Sarathy Date: Sun, 7 May 2000 05:52:02 +0000 (+0000) Subject: repeat operator (x) doesn't preserve utf8-ness X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dfcb284a2bcae98854733134f50bc110c487b8a3;p=p5sagit%2Fp5-mst-13.2.git repeat operator (x) doesn't preserve utf8-ness p4raw-id: //depot/perl@6085 --- diff --git a/pp.c b/pp.c index d2a8c64..03ced37 100644 --- a/pp.c +++ b/pp.c @@ -1076,10 +1076,10 @@ PP(pp_repeat) SP -= items; } else { /* Note: mark already snarfed by pp_list */ - SV *tmpstr; + SV *tmpstr = POPs; STRLEN len; + bool isutf = SvUTF8(tmpstr) ? TRUE : FALSE; - tmpstr = POPs; SvSetSV(TARG, tmpstr); SvPV_force(TARG, len); if (count != 1) { @@ -1092,7 +1092,10 @@ PP(pp_repeat) } *SvEND(TARG) = '\0'; } - (void)SvPOK_only(TARG); + if (isutf) + (void)SvPOK_only_UTF8(TARG); + else + (void)SvPOK_only(TARG); PUSHTARG; } RETURN; diff --git a/t/op/substr.t b/t/op/substr.t index 6180acc..a67eae5 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -275,8 +275,9 @@ ok 125, $a eq 'xxxxefgh'; ok 126, length($x) eq 3; $x = substr($x,1,1); ok 127, $x eq "\x{263a}"; - ok 128, length($x) eq 1; + $x = $x x 2; + ok 128, length($x) eq 2; substr($x,0,1) = "abcd"; - ok 129, $x eq "abcd"; - ok 130, length($x) eq 4; + ok 129, $x eq "abcd\x{263a}"; + ok 130, length($x) eq 5; }