From: Father Chrysostomos Date: Fri, 31 Aug 2012 06:27:43 +0000 (-0700) Subject: Stop calling get-magic twice in sprintf "%.1s", $utf8 X-Git-Tag: upstream/5.20.0~5536 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d8f2f09061a707a280cb8024276ef56e41b07684;p=platform%2Fupstream%2Fperl.git Stop calling get-magic twice in sprintf "%.1s", $utf8 --- diff --git a/sv.c b/sv.c index fa0fb23..497417c 100644 --- a/sv.c +++ b/sv.c @@ -10517,10 +10517,10 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p if (DO_UTF8(argsv)) { STRLEN old_precis = precis; if (has_precis && precis < elen) { - STRLEN ulen = sv_len_utf8(argsv); - I32 p = precis > ulen ? ulen : precis; - sv_pos_u2b(argsv, &p, 0); /* sticks at end */ - precis = p; + STRLEN ulen = sv_len_utf8_nomg(argsv); + STRLEN p = precis > ulen ? ulen : precis; + precis = sv_pos_u2b_flags(argsv, p, 0, 0); + /* sticks at end */ } if (width) { /* fudge width (can't fudge elen) */ if (has_precis && precis < elen) diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index 50671d9..48cc914 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -7,7 +7,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan (tests => 309); + plan (tests => 310); } use strict; @@ -255,6 +255,7 @@ $dummy = pack "u", $var; check_count 'pack "u", $utf8'; tie $var, "main", "\x{100}"; pos$var = 0 ; check_count 'lvalue pos $utf8'; $dummy=sprintf"%1s",$var; check_count 'sprintf "%1s", $utf8'; +$dummy=sprintf"%.1s",$var; check_count 'sprintf "%.1s", $utf8'; $dummy = substr$var,0,1; check_count 'substr $utf8'; my $l =\substr$var,0,1; $dummy = $$l ; check_count 'reading lvalue substr($utf8)';