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

Re: Anomalies in parsing regex quantifiers

Thread Previous | Thread Next
From:
Karl Williamson
Date:
February 14, 2020 16:41
Subject:
Re: Anomalies in parsing regex quantifiers
Message ID:
b93be8ec-f670-3c13-af8e-9b93de363954@khwilliamson.com
On 2/13/20 8:11 PM, hv@crypt.org wrote:
> 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
> 

Thanks for digging

Done in https://git.io/JvlRe, though I'm not sure whether the comments I 
changed add any value.

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