Closed p5pRT closed 20 years ago
#! /usr/bin/perl -w
use strict;
my $input = "a{b}c{d}";
On perl 5.6.0 and perl 5.005_03 this produces this (correct) output...
On perl 5.6.1 we get this...
Adding a '\G' to the start of the first regexp fixes the problem.
Here is a run of 'perl -Mre=debug ./test.pl'...
Looks like a possible problem in the regexp optimizer?
Have fun\,
Rich Williams
The bug seems to show up only when using /s in conjunction with /g and C\<.*?>\, so I'd say it's not a show-stopper.
The attached tests fail #1 and #3 with 5.6.1. Does 5.7.1 behave the same way?
I'd be grateful if someone with the tuits can build perl at various points between 5.6.0 and 5.6.1 that changed reg*.[hc] to see which patch introduced the problem. The patches are here:
http://public.ActiveState.com/gsar/APC/5.6.1/diffs/
Thanks.
Sarathy gsar@ActiveState.com
Good work\, thanks.
And then lines 7950-7988 of 8156.gz (again\, just the patch to regexec.c\, and not the bit which deals with some unicode stuff)
Here's the actual change:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-09/msg01297.html
which got checked in as change#7115:
http://public.ActiveState.com/gsar/APC/5.7.1/diffs/7115.gz
"Minor" optimization\, no doubt. ;-)
Sarathy gsar@ActiveState.com
Here's a fix\, over 5.6.1. Not sure if this could be improved by having such patterns upgraded to ROPT_ANCH_GPOS | ROPT_IMPLICIT instead of ROPT_ANCH_SBOL | ROPT_IMPLICIT - I suspect the optimisation predates the existence of GPOS.
Hugo
I've managed to isolate this down to 2 patches\, although I think it's probably just the later one (but it won't patch unless the first patch is applied).
I took a clean 5.6.0 and just applied the lines 31-54 of 7262.gz (just the patch to regexec.c) ...
============================================================ Index: perl/regexec.c
============================================================
And then lines 7950-7988 of 8156.gz (again\, just the patch to regexec.c\, and not the bit which deals with some unicode stuff)
============================================================ Index: perl/regexec.c
============================================================
After these two patches have been applied to 5.6.0\, then tests #1 and #3 in your improved test script fail.
Hope this helps.
Have fun\,
Rich
This simple script demonstrates the problem :-
#! /usr/bin/perl -w
use strict;
my $input = "a{b}c{d}";
while ($input =~ /(.*?)\{(.*?)\}/csg) { print "\$1 = '$1' \$2 = '$2'\n"; } print "Rest = '$1'\n" if $input =~ m/\G(.+)$/csg;
On perl 5.6.0 and perl 5.005_03 this produces this (correct) output...
================================================== $1 = 'a' $2 = 'b' $1 = 'c' $2 = 'd'
On perl 5.6.1 we get this...
================================================== $1 = 'a' $2 = 'b' Rest = 'c{d}'
I tried this in Perl 5.8.2 and 5.8.5\, and it seems to be working as expected again.
@rspier - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#6796 (status was 'resolved')
Searchable as RT6796$