develooper Front page | perl.perl5.porters | Postings from February 2020

Re: Anomalies in parsing regex quantifiers

Thread Previous | Thread Next
February 14, 2020 17:13
Re: Anomalies in parsing regex quantifiers
Message ID:
Karl Williamson <> wrote:
:On 2/13/20 8:11 PM, wrote:
:> Earlier I wrote:
:> :Karl Williamson <> wrote:
:> ::I have been looking at the code in regcomp.c in regpiece() that deals
:> ::with quantifiers.
:> [...]
:> ::Two of the flags WORST and SPSTART do not appear to ever be looked
:> ::at.  Should we remove them, or dig to find out how they used to be used,
:> ::or might they come back again, and we should set them consistently?
:> :
:> :I definitely think there's value in some digging, I'm happy to give that
:> :a go, time permitting. But of those I'm sure at least WORST would be
:> :from Ilya, quite likely SPSTART too, so digging is not guaranteed to
:> :lead to light.
:> That didn't take long. SPSTART does not appear ever to have been used
:> for anything - looks like it was introduced in perl-3, propagated with
:> some new features in perl-4, and never touched thereafter.
:> WORST is slightly different: it is defined as 0, so represents the state
:> where all the other flags (representing something we know) are disabled.
:> I don't know why it is included in:
:>    *flagp = (op != '+') ? (WORST|SPSTART|HASWIDTH) : (WORST|HASWIDTH);
:> .. but that also appears to have been in from the start.
:> So I think SPSTART can go, WORST is probably best replaced with a literal
:> zero in the three other places it is used, with a change of comment -
:> the word "worst" is now misleading, since the flags no longer only
:> represent things that permit more powerful optimizations.
:> Hugo
:Thanks for digging
:Done in, though I'm not sure whether the comments I 
:changed add any value.

I'd have gone for something like "nothing known yet" I think, and added
something correspondingly for the one *flagp=HASWIDTH case.


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