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

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

Thread Previous
Ilya Zakharevich
April 28, 2001 12:34
Re: [PATCH bleadperl] [ID 20010426.002] Word boundry regex [...]
Message ID:
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,
> 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

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

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

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.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About