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

Re: Anomalies in parsing regex quantifiers

Thread Previous | Thread Next
From:
hv
Date:
February 14, 2020 03:29
Subject:
Re: Anomalies in parsing regex quantifiers
Message ID:
202002140311.01E3BFP03943@crypt.org
Earlier I wrote:
:Karl Williamson <public@khwilliamson.com> 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

Thread Previous | Thread Next


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