From 3f63b0e5ad2a410fc3056eabf43c29c1d622000e Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 30 Aug 2012 23:06:14 -0700 Subject: [PATCH] Stop calling get-magic twice in pack "u", $utf8 --- pp_pack.c | 2 +- t/op/tie_fetch_count.t | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pp_pack.c b/pp_pack.c index c9d9fcb..c760f69 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -3569,7 +3569,7 @@ extern const double _double_constants[]; from_utf8 = DO_UTF8(fromstr); if (from_utf8) { aend = aptr + fromlen; - fromlen = sv_len_utf8(fromstr); + fromlen = sv_len_utf8_nomg(fromstr); } else aend = NULL; /* Unused, but keep compilers happy */ GROWING(utf8, cat, start, cur, (fromlen+2) / 3 * 4 + (fromlen+len-1)/len * 2); while (fromlen > 0) { diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index 48a070b..7ad375a 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 => 307); + plan (tests => 308); } use strict; @@ -248,6 +248,10 @@ for ([chdir=>''],[chmod=>'0,'],[chown=>'0,0,'],[utime=>'0,0,'], ; check_count 'select $tied_undef, ...'; } +chop(my $u = "\xff\x{100}"); +tie $var, "main", $u; +$dummy = pack "u", $var; check_count 'pack "u", $utf8'; + tie $var, "main", "\x{100}"; pos$var = 0 ; check_count 'lvalue pos $utf8'; $dummy = substr$var,0,1; check_count 'substr $utf8'; -- 2.7.4