summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-07-30 19:29:43 +0200
committerYves Orton <demerphq@gmail.com>2022-08-03 11:07:09 +0200
commit6f83e0eceec58363a6a1027ef9a408c9cf4f28b9 (patch)
tree944387a1fd4ec3b018c596aa111c541302701177 /regcomp.c
parentf37e1724fa45c62f80fd0d1f084a4678740627ed (diff)
downloadperl-6f83e0eceec58363a6a1027ef9a408c9cf4f28b9.tar.gz
regcomp.c - initial support for EXACTish nodes in regnode_after()
This is a first step, we add the support for EXACTish nodes here, but we do not use it. In a following commit we will move it to a new file. This patch is just to keep the move clean.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/regcomp.c b/regcomp.c
index 751a41ade7..736dbe18ec 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -22966,27 +22966,28 @@ Perl_regnext(pTHX_ regnode *p)
}
/*
- - regnode_after - find the next node after this one.
+ - regnode_after - find the node physically following p in memory,
+ taking into account the size of p as determined by OP(p), our
+ sizing data, and possibly the STR_SZ() macro.
*/
regnode *
-Perl_regnode_after(pTHX_ regnode *p)
+Perl_regnode_after(pTHX_ const regnode *p)
{
- if (!p) {
- return NULL;
- }
+ assert(p);
const U8 op = OP(p);
-
- if (op > REGNODE_MAX) { /* regnode.type is unsigned */
- return NULL;
- }
-
- return (p + NODE_STEP_REGNODE + PL_regnode_arg_len[op]);
+ assert(op < REGNODE_MAX);
+ const regnode *ret = p + NODE_STEP_REGNODE + PL_regnode_arg_len[op];
+ if (PL_regnode_arg_len_varies[op])
+ ret += STR_SZ(STR_LEN(p));
+ return (regnode *)ret;
}
+/* validate that the passed in node and extra length would match that
+ * returned by regnode_after() */
bool
Perl_check_regnode_after(pTHX_ const regnode *p, const STRLEN extra)
{
- const regnode *nextoper= regnode_after((regnode *)p);
+ const regnode *nextoper = regnode_after((regnode *)p,FALSE);
/* this should be the ONLY place that REGNODE_AFTER_PLUS is used outside
* of regcomp.h */
const regnode *other= REGNODE_AFTER_PLUS(p, extra);
@@ -22995,8 +22996,6 @@ Perl_check_regnode_after(pTHX_ const regnode *p, const STRLEN extra)
}
return TRUE;
}
-
-
#endif
STATIC void