summaryrefslogtreecommitdiff
path: root/regexp.h
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2016-03-05 22:04:28 +0100
committerYves Orton <demerphq@gmail.com>2016-03-06 14:06:08 +0100
commitd5a00e4af6b155495be31a35728b8fef8e671ebe (patch)
tree562a578c47ebca3abd0f26130e8e9e75cb6702f6 /regexp.h
parent5bd2d46ea3f06ba4e06c713635d5f83a331c4af0 (diff)
downloadperl-d5a00e4af6b155495be31a35728b8fef8e671ebe.tar.gz
Unify GOSTART and GOSUB
GOSTART is a special case of GOSUB, we can remove a lot of offset twiddling, and other special casing by unifying them, at pretty much no cost. GOSUB has 2 arguments, ARG() and ARG2L(), which are interpreted as a U32 and an I32 respectively. ARG() holds the "parno" we will recurse into. ARG2L() holds a signed offset to the relevant start node for the recursion. Prior to this patch the argument to GOSUB would always be >=, and unlike other parts of our logic we would not use 0 to represent "start/end" of pattern, as GOSTART would be used for "recurse to beginning of pattern", after this patch we use 0 to represent "start/end", and a lot of complexity "goes away" along with GOSTART regops.
Diffstat (limited to 'regexp.h')
-rw-r--r--regexp.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/regexp.h b/regexp.h
index ff44df27e7..02258fe176 100644
--- a/regexp.h
+++ b/regexp.h
@@ -833,13 +833,19 @@ typedef struct regmatch_state {
} u;
} regmatch_state;
-#define EVAL_CLOSE_PAREN_IS(cur_eval,expr) \
+#define EVAL_CLOSE_PAREN_IS(st,expr) \
(\
- ( ( cur_eval ) ) && \
- ( ( cur_eval )->u.eval.close_paren ) && \
- ( ( ( cur_eval )->u.eval.close_paren - 1 ) == ( expr ) ) \
+ ( ( st ) ) && \
+ ( ( st )->u.eval.close_paren ) && \
+ ( ( ( st )->u.eval.close_paren - 1 ) == ( expr ) ) \
)
+#define EVAL_CLOSE_PAREN_SET(st,expr) \
+ (st)->u.eval.close_paren = (expr) + 1
+
+#define EVAL_CLOSE_PAREN_CLEAR(st) \
+ (st)->u.eval.close_paren = 0
+
/* how many regmatch_state structs to allocate as a single slab.
* We do it in 4K blocks for efficiency. The "3" is 2 for the next/prev
* pointers, plus 1 for any mythical malloc overhead. */