Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #19049] Incorrect $` after replacement

0 views
Skip to first unread message

Andreas J. Koenig

unread,
Nov 4, 2005, 2:17:25 AM11/4/05
to The Perl5 Porters Mailing List
The following patch *kind* of fixes the bug 19049 and another TODO but
it is incorrect in that it breaks tests op/pat 188 and op/subs_amp 2
thru 13.

Maybe somebody with the right regexp-fu could continue on this?

I merely tried reverting parts of patch 2372 which introduced the bug,
so I have to give up at this point.

#### Patch data follows ####
diff -c '../perl-p-5.8.0@25977/regexec.c' 'regexec.c'
Index: ./regexec.c
*** ./regexec.c Thu Nov 3 21:57:16 2005
--- ./regexec.c Fri Nov 4 07:23:03 2005
***************
*** 2177,2183 ****
prog->subbeg = PL_bostr;
prog->sublen = PL_regeol - PL_bostr; /* strend may have been modified */
}
! prog->startp[0] = startpos - PL_bostr;
PL_reginput = startpos;
PL_regstartp = prog->startp;
PL_regendp = prog->endp;
--- 2177,2183 ----
prog->subbeg = PL_bostr;
prog->sublen = PL_regeol - PL_bostr; /* strend may have been modified */
}
! /* prog->startp[0] = startpos - PL_bostr; */
PL_reginput = startpos;
PL_regstartp = prog->startp;
PL_regendp = prog->endp;
***************
*** 2221,2226 ****
--- 2221,2227 ----
#endif
REGCP_SET(lastcp);
if (regmatch(prog->program + 1)) {
+ prog->startp[0] = startpos - PL_bostr;
prog->endp[0] = PL_reginput - PL_bostr;
return 1;
}
diff -c '../perl-p-5.8.0@25977/t/op/pat.t' 't/op/pat.t'
Index: ./t/op/pat.t
*** ./t/op/pat.t Thu Nov 3 21:57:02 2005
--- ./t/op/pat.t Fri Nov 4 08:06:45 2005
***************
*** 3196,3202 ****
# bug #19049
$_="abcdef\n";
@x = m/./g;
! ok("abcde" eq "$`", '# TODO #19049 - global match not setting $`');

ok("123\x{100}" =~ /^.*1.*23\x{100}$/, 'uft8 + multiple floating substr');

--- 3196,3202 ----
# bug #19049
$_="abcdef\n";
@x = m/./g;
! ok("abcde" eq "$`", '#19049 - global match not setting $`');

ok("123\x{100}" =~ /^.*1.*23\x{100}$/, 'uft8 + multiple floating substr');

***************
*** 3390,3396 ****
$s = $1;
$s = $2;
ok($s eq 'cd',
! "# TODO assigning to original string should not corrupt match vars");
}

# last test 1187
--- 3390,3396 ----
$s = $1;
$s = $2;
ok($s eq 'cd',
! "# assigning to original string should not corrupt match vars");
}

# last test 1187
#### End of Patch data ####


--
andreas

Rafael Garcia-Suarez

unread,
Nov 4, 2005, 11:53:59 AM11/4/05
to perl5-...@perl.org
Andreas J. Koenig wrote:
> The following patch *kind* of fixes the bug 19049 and another TODO but
> it is incorrect in that it breaks tests op/pat 188 and op/subs_amp 2
> thru 13.

Thanks, applied as change #25993.

Rafael Garcia-Suarez

unread,
Nov 4, 2005, 2:06:45 PM11/4/05
to perl5-...@perl.org

Yes. I reverted it again with change #25998. If someone wants to
follow-up... It's a bit late for me to continue.

0 new messages