summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/hi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 7e3a5117..59e6d467 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);
 			}
 		}
0a2d8f5f9b6385ffeb0e0e7b3237cb395b80&follow=1'>Add Fomapan 200 to films listJune McEnroe 2024-09-10Add August 29 picnic photosJune McEnroe 2024-09-08Apply some bold to trips renderingJune McEnroe 2024-09-08Render trips hopefully more efficientlyJune McEnroe 2024-09-08Allow removing bodies and lensesJune McEnroe 2024-09-08Limit body width so it looks less silly on desktopJune McEnroe 2024-09-07Handle no film being loadedJune McEnroe 2024-09-07Fancy up the text a littleJune McEnroe