summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-02-07 00:44:06 -0500
committerJune McEnroe <june@causal.agency>2019-02-07 00:44:06 -0500
commite9d5b41888e591a5a25b2cf9a1cf4fab7ac5e7d2 (patch)
tree7a3b13ee453cc628d787e11ae26477fd59282842 /bin
parentUse subexpression highlight for system include paths (diff)
downloadsrc-e9d5b41888e591a5a25b2cf9a1cf4fab7ac5e7d2.tar.gz
src-e9d5b41888e591a5a25b2cf9a1cf4fab7ac5e7d2.zip
Check subexpressions with hi -c
Diffstat (limited to '')
-rw-r--r--bin/hi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 5acca9b2..40f873d0 100644
--- a/bin/hi.c
+++ b/bin/hi.c
@@ -246,7 +246,20 @@ int main(int argc, char *argv[]) {
 			regex_t regex = compile(Languages[i].pattern, REG_NOSUB);
 			regfree(&regex);
 			for (size_t j = 0; j < Languages[i].len; ++j) {
-				regex = compile(Languages[i].syntax[j].pattern, REG_NOSUB);
+				struct Syntax syn = Languages[i].syntax[j];
+				regex = compile(syn.pattern, 0);
+				if (regex.re_nsub >= SubsLen) {
+					errx(
+						EX_SOFTWARE,
+						"too many subexpressions: %s", syn.pattern
+					);
+				}
+				if (syn.subexp > regex.re_nsub) {
+					errx(
+						EX_SOFTWARE,
+						"no subexpression %zu: %s", syn.subexp, syn.pattern
+					);
+				}
 				regfree(&regex);
 			}
 		}
rl/commit/ui.c?h=enroll&id=b36a1347022965fdbe1b61298dc6a05be2d2a34d&follow=1'>Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe Ridiculous. 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe