summaryrefslogtreecommitdiff
path: root/regnodes.h
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2023-01-09 22:34:13 +0100
committerYves Orton <demerphq@gmail.com>2023-03-13 21:26:08 +0800
commitacababb42be12ff2986b73c1bfa963b70bb5d54e (patch)
treedc8cc4980e6fe3de0c686cc641dbbe37d1e8e961 /regnodes.h
parent05b13cf680588a26de64f13d2b3be385e17624bc (diff)
downloadperl-acababb42be12ff2986b73c1bfa963b70bb5d54e.tar.gz
regexec.c - teach BRANCH and BRANCHJ nodes to reset capture buffers
In /((a)(b)|(a))+/ we should not end up with $2 and $4 being set at the same time. When a branch fails it should reset any capture buffers that might be touched by its branch. We change BRANCH and BRANCHJ to store the number of parens before the branch, and the number of parens after the branch was completed. When a BRANCH operation fails, we clear the buffers it contains before we continue on. It is a bit more complex than it should be because we have BRANCHJ and BRANCH. (One of these days we should merge them together.) This is also made somewhat more complex because TRIE nodes are actually branches, and may need to track capture buffers also, at two levels. The overall TRIE op, and for jump tries especially where we emulate the behavior of branches. So we have to do the same clearing logic if a trie branch fails as well.
Diffstat (limited to 'regnodes.h')
-rw-r--r--regnodes.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/regnodes.h b/regnodes.h
index b45c1261f5..321a841989 100644
--- a/regnodes.h
+++ b/regnodes.h
@@ -29,8 +29,8 @@ typedef struct regnode tregnode_BOUND;
typedef struct regnode tregnode_BOUNDA;
typedef struct regnode tregnode_BOUNDL;
typedef struct regnode tregnode_BOUNDU;
-typedef struct regnode tregnode_BRANCH;
-typedef struct regnode_1 tregnode_BRANCHJ;
+typedef struct regnode_1 tregnode_BRANCH;
+typedef struct regnode_2L tregnode_BRANCHJ;
typedef struct regnode_1 tregnode_CLOSE;
typedef struct regnode tregnode_CLUMP;
typedef struct regnode_1 tregnode_COMMIT;
@@ -2026,7 +2026,7 @@ EXTCONST struct regnode_meta PL_regnode_info[] = {
{
/* #40 op BRANCH */
.type = BRANCH,
- .arg_len = 0,
+ .arg_len = EXTRA_SIZE(tregnode_BRANCH),
.arg_len_varies = 0,
.off_by_arg = 0
},