From 5c72122bf4361d2811201aa5205d2cb1d172b215 Mon Sep 17 00:00:00 2001 From: Curtis 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 fd3dd0a3..e7b826f8 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