This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make substr = $utf8 call get-magic once
authorFather Chrysostomos <sprout@cpan.org>
Fri, 28 Sep 2012 15:42:47 +0000 (08:42 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 1 Oct 2012 19:51:55 +0000 (12:51 -0700)
mg.c
t/op/tie_fetch_count.t

diff --git a/mg.c b/mg.c
index 7b13f61..b792b2c 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2271,7 +2271,7 @@ Perl_magic_setsubstr(pTHX_ SV *sv, MAGIC *mg)
        Perl_croak(aTHX_ "substr outside of string");
     oldtarglen = lvlen;
     if (DO_UTF8(sv)) {
-       sv_utf8_upgrade(lsv);
+       sv_utf8_upgrade_nomg(lsv);
        lvoff = sv_pos_u2b_flags(lsv, lvoff, &lvlen, SV_CONST_RETURN);
        sv_insert_flags(lsv, lvoff, lvlen, tmps, len, 0);
        newtarglen = sv_len_utf8(sv);
index 48cc914..b5e4f90 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';
-    plan (tests => 310);
+    plan (tests => 311);
 }
 
 use strict;
@@ -260,6 +260,8 @@ $dummy  = substr$var,0,1; check_count 'substr $utf8';
 my $l   =\substr$var,0,1;
 $dummy  = $$l           ; check_count 'reading lvalue substr($utf8)';
 $$l     = 0             ; check_count 'setting lvalue substr($utf8)';
+tie $var, "main", "a";
+$$l     = "\x{100}"     ; check_count 'assigning $utf8 to lvalue substr';
 
 {
     local $SIG{__WARN__} = sub {};