From 442f80f81a7f05f0669eb9a31c8809ba0949692c Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 10 Feb 2019 17:41:16 -0500 Subject: Skip only one character if a match fails due to parent Really it should skip forward until the parent changes, but this is simpler. --- bin/hi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/hi.c b/bin/hi.c index 7c791909..5b2c17db 100644 --- a/bin/hi.c +++ b/bin/hi.c @@ -238,11 +238,12 @@ static void highlight(struct Language lang, enum Class *hi, const char *str) { ); if (error == REG_NOMATCH) break; if (error) errx(EX_SOFTWARE, "regexec: %d", error); - regmatch_t sub = subs[syn.subexp]; - if (syn.parent) { - if (~syn.parent & SET(hi[offset + sub.rm_so])) continue; + regmatch_t *sub = &subs[syn.subexp]; + if (syn.parent && !(syn.parent & SET(hi[offset + sub->rm_so]))) { + sub->rm_eo = sub->rm_so + 1; + continue; } - for (regoff_t j = sub.rm_so; j < sub.rm_eo; ++j) { + for (regoff_t j = sub->rm_so; j < sub->rm_eo; ++j) { hi[offset + j] = lang.syntax[i].class; } } -- cgit 1.4.1