develooper Front page | perl.perl5.porters | Postings from April 2001

Re: [PATCH bleadperl] [ID 20010426.002] Word boundry regex [...]

Thread Previous
From:
Ilya Zakharevich
Date:
April 28, 2001 12:34
Subject:
Re: [PATCH bleadperl] [ID 20010426.002] Word boundry regex [...]
Message ID:
20010428153412.A21353@math.ohio-state.edu
On Sat, Apr 28, 2001 at 02:23:28PM +0100, Hugo wrote:
> :my $text = "Charles Bronson";
> :
> :$text =~ s/\B\w//g;
> :
> :print "here it is: $text\n\n";
> 
> This correctly returned "C B" on 5.005_03, but "Cals Bosn" on later
> perls. This appears to have been caused by a 1999 patch from Ilya,
> http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-11/msg00286.html,
> which changed the pickup of the previous character from:
>            tmp = (s != startpos) ? UCHARAT(s - 1) : PL_regprev;
> to:
>            tmp = (s != startpos) ? UCHARAT(s - 1) : '\n';
> 
> PL_regprev is still supported, so I don't understand why this change
> was made. Reversing it as in the attached patch fixes the problem, and
> passes all tests here, but I'm slightly concerned that I (and the test
> suite) may be missing the original reason for this change - Ilya, have
> you any memory of this?

The only suggestion I have is that there might have been a case when
this chunk is entered *before* PL_regprev is set.  Can this happen?

Aha, this is s///, not m//; there there is also a case of
substitution-in-place:

 old-perl -wle "$_= q(abcd); s/\b./#/g; print"
 ####

 new-perl -wle "$_= q(abcd); s/\b./#/g; print"
 #bcd

IMO, old-perl is buggy, new-perl is correct.  But maybe the fix is not
related to the patch in question.  The "correct" fix is to pessimize
/\b./ so is it correctly marked as having lookbehind, hence
substitution-in-place is not attempted.

Ilya

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About