aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2022-10-27 13:38:19 -0400
committerBruce Hill <bruce@bruce-hill.com>2022-10-27 13:38:19 -0400
commit07f335f36719bcb48a0f2f6a1501054852b53f28 (patch)
treeb86ce53028aa30fca6a12bf25ac472725a635d39
parent3fdd5211d96952989fbd7b0cfacd30628c6ab57c (diff)
Fix for getting @1 from a tagged capture
-rw-r--r--match.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/match.c b/match.c
index 2aa6054..71ab087 100644
--- a/match.c
+++ b/match.c
@@ -923,7 +923,17 @@ static match_t *_get_numbered_capture(match_t *m, int *n)
match_t *get_numbered_capture(match_t *m, int n)
{
if (n <= 0) return m;
- return _get_numbered_capture(m, &n);
+ if (m->pat->type == BP_TAGGED) {
+ if (m->children) {
+ for (int i = 0; m->children[i]; i++) {
+ match_t *cap = _get_numbered_capture(m->children[i], &n);
+ if (cap) return cap;
+ }
+ }
+ return NULL;
+ } else {
+ return _get_numbered_capture(m, &n);
+ }
}
//