summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-02-10 17:41:16 -0500
committerJune McEnroe <june@causal.agency>2019-02-10 17:41:16 -0500
commit5c72122bf4361d2811201aa5205d2cb1d172b215 (patch)
tree3398f39c981e05829779dc0ade38c29d5448726c /bin
parentRemove pattend from hi (diff)
downloadsrc-5c72122bf4361d2811201aa5205d2cb1d172b215.tar.gz
src-5c72122bf4361d2811201aa5205d2cb1d172b215.zip
Skip only one character if a match fails due to parent
Really it should skip forward until the parent changes, but this is
simpler.
Diffstat (limited to 'bin')
-rw-r--r--bin/hi.c9
1 files changed, 5 insertions, 4 deletions
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;
 			}
 		}