aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-16 19:41:05 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-16 19:41:05 -0700
commit3483cd75cb0a67d50bdcf9d03a15dc5af67a1986 (patch)
treeb5708ad1a0d242d420633368a4b211ecc68caf24
parent1dd89c766a3d89fde1c84813c04061f5465c234c (diff)
Fixed upto for non-matches
-rw-r--r--vm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/vm.c b/vm.c
index 79d8b1c..7b6a04b 100644
--- a/vm.c
+++ b/vm.c
@@ -137,14 +137,16 @@ static match_t *_match(grammar_t *g, const char *str, vm_op_t *op, unsigned int
match_t *p = _match(g, str, op->args.pat, flags, rec);
if (p) {
m->child = p;
- str = p->end;
- break;
+ m->end = p->end;
+ return m;
}
// This isn't in the for() structure because there needs to
// be at least once chance to match the pattern, even if
// we're at the end of the string already (e.g. "..$").
if (*str && (op->multiline || *str != '\n')) ++str;
}
+ destroy_match(&m);
+ return NULL;
} else if (op->multiline) {
while (*str) ++str;
} else {