summaryrefslogtreecommitdiff
path: root/regcomp.h
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-02-21 07:14:52 +0100
committerKarl Williamson <khw@cpan.org>2022-02-23 10:40:52 -0700
commit3c92cb142a9eee345370ce910513ccddbcccb93a (patch)
tree06c9968e029aff6d639c549b57e9c9467e8fe709 /regcomp.h
parent5070f532622b3fabf067638f9a15ca2e515ed50d (diff)
downloadperl-3c92cb142a9eee345370ce910513ccddbcccb93a.tar.gz
regcomp.c: consistent NOTHING/OPFAIL optimizations for lookaround
Add funcs to parse empty constructs which boil down to OPFAIL or NOTHING, and then consistently use them while parsing lookahead and lookbehind. This allows us to eliminate duplicated code and optimize the various cases which boil down to these constructs. Eg. (?!) and (?<!) are equivalent to OPFAIL ops, and (?=) and (?<=) are equivalent to NOTHING ops. This patch does not deal with the (* ... ) forms, that will come in a follow up. One advantage of this optimization is it does not need to set the various special flags related to lookaround as they aren't really lookaround ops. As a bonus this also improves the error messages from incomplete patterns, and add tests for various error messages. Note the functions are given awkward but shortish names so they are not always forced to be line broken. I would prefer to name them something more descriptive, but that would make their use harder to read by forcing line breaks. So I chose to use an abbreviation.
Diffstat (limited to 'regcomp.h')
-rw-r--r--regcomp.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/regcomp.h b/regcomp.h
index 2705463474..95b6d564b3 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -744,6 +744,8 @@ struct regnode_ssc {
#define REG_ZERO_LEN_SEEN 0x00000001
#define REG_LOOKBEHIND_SEEN 0x00000002
+/* add a short form alias to keep the line length police happy */
+#define REG_LB_SEEN REG_LOOKBEHIND_SEEN
#define REG_GPOS_SEEN 0x00000004
/* spare */
#define REG_RECURSE_SEEN 0x00000020