From 3483cd75cb0a67d50bdcf9d03a15dc5af67a1986 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 Sep 2020 19:41:05 -0700 Subject: Fixed upto for non-matches --- vm.c | 6 ++++-- 1 file 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 { -- cgit v1.2.3