diff options
-rw-r--r-- | pp_ctl.c | 6 | ||||
-rwxr-xr-x | t/op/subst.t | 10 |
2 files changed, 10 insertions, 6 deletions
@@ -298,7 +298,6 @@ PP(pp_substcont) { /* Update the pos() information. */ SV * const sv = cx->sb_targ; MAGIC *mg; - I32 i; SvUPGRADE(sv, SVt_PVMG); if (!(mg = mg_find(sv, PERL_MAGIC_regex_global))) { #ifdef PERL_OLD_COPY_ON_WRITE @@ -308,10 +307,7 @@ PP(pp_substcont) mg = sv_magicext(sv, NULL, PERL_MAGIC_regex_global, &PL_vtbl_mglob, NULL, 0); } - i = m - orig; - if (DO_UTF8(sv)) - sv_pos_b2u(sv, &i); - mg->mg_len = i; + mg->mg_len = m - orig; } if (old != rx) (void)ReREFCNT_inc(rx); diff --git a/t/op/subst.t b/t/op/subst.t index 6cf84b7399..06c04e8339 100755 --- a/t/op/subst.t +++ b/t/op/subst.t @@ -7,7 +7,7 @@ BEGIN { } require './test.pl'; -plan( tests => 136 ); +plan( tests => 139 ); $x = 'foo'; $_ = "x"; @@ -583,3 +583,11 @@ is($name, "cis", q[#22351 bug with 'e' substitution modifier]); is($want,$_,"RT#17542"); } +{ + my @tests = ('ABC', "\xA3\xA4\xA5", "\x{410}\x{411}\x{412}"); + foreach (@tests) { + my $id = ord $_; + s/./pos/ge; + is($_, "012", "RT#52104: $id"); + } +} |