diff -up perl-5.10.0/t/op/subst.t.pos perl-5.10.0/t/op/subst.t --- perl-5.10.0/t/op/subst.t.pos 2007-12-18 11:47:08.000000000 +0100 +++ perl-5.10.0/t/op/subst.t 2008-07-21 11:01:01.000000000 +0200 @@ -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' s 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"); + } +} diff -up perl-5.10.0/pp_ctl.c.pos perl-5.10.0/pp_ctl.c --- perl-5.10.0/pp_ctl.c.pos 2007-12-18 11:47:08.000000000 +0100 +++ perl-5.10.0/pp_ctl.c 2008-07-21 12:31:50.000000000 +0200 @@ -285,7 +285,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 @@ -295,10 +294,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);