diff options
author | Yves Orton <demerphq@gmail.com> | 2023-01-08 15:49:04 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-01-19 18:44:49 +0800 |
commit | c224bbd5d135fe48f49b4cc25f10a4977d695145 (patch) | |
tree | 5909b6fd666bb025496824a3f8c67715643164a8 /regcomp.h | |
parent | 09b3a407e87f128d7aecd14f9c8d75dcff9aaaf8 (diff) | |
download | perl-c224bbd5d135fe48f49b4cc25f10a4977d695145.tar.gz |
regcomp.c - add optimistic eval (*{ ... }) and (**{ ... })
This adds (*{ ... }) and (**{ ... }) as equivalents to (?{ ... }) and
(??{ ... }). The only difference being that the star variants are
"optimisitic" and are defined to never disable optimisations. This is
especially relevant now that use of (?{ ... }) prevents important
optimisations anywhere in the pattern, instead of the older and inconsistent
rules where it only affected the parts that contained the EVAL.
It is also very useful for injecting debugging style expressions to the
pattern to understand what the regex engine is actually doing. The older
style (?{ ... }) variants would change the regex engines behavior, meaning
this was not as effective a tool as it could have been.
Similarly it is now possible to test that a given regex optimisation
works correctly using (*{ ... }), which was not possible with (?{ ... }).
Diffstat (limited to 'regcomp.h')
-rw-r--r-- | regcomp.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -108,6 +108,7 @@ typedef struct regexp_internal { #define PREGf_ANCH_SBOL 0x00000800 #define PREGf_ANCH_GPOS 0x00001000 #define PREGf_RECURSE_SEEN 0x00002000 +#define PREGf_PESSIMIZE_SEEN 0x00004000 #define PREGf_ANCH \ ( PREGf_ANCH_SBOL | PREGf_ANCH_GPOS | PREGf_ANCH_MBOL ) @@ -976,6 +977,7 @@ ARGp_SET_inline(struct regnode *node, SV *ptr) { #define REG_UNFOLDED_MULTI_SEEN 0x00000400 /* spare */ #define REG_UNBOUNDED_QUANTIFIER_SEEN 0x00001000 +#define REG_PESSIMIZE_SEEN 0x00002000 START_EXTERN_C @@ -1426,6 +1428,9 @@ typedef enum { #include "reginline.h" #endif +#define EVAL_OPTIMISTIC_FLAG 128 +#define EVAL_FLAGS_MASK (EVAL_OPTIMISTIC_FLAG-1) + #endif /* PERL_REGCOMP_H_ */ /* |