diff options
author | June McEnroe <june@causal.agency> | 2019-02-07 00:44:06 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-02-07 00:44:06 -0500 |
commit | 5a9b04a75b5a5c34811878d75e749318b32ba8a1 (patch) | |
tree | 6cc37612980412813627a0e8cae85b9628c19fc0 | |
parent | Use subexpression highlight for system include paths (diff) | |
download | src-5a9b04a75b5a5c34811878d75e749318b32ba8a1.tar.gz src-5a9b04a75b5a5c34811878d75e749318b32ba8a1.zip |
Check subexpressions with hi -c
Diffstat (limited to '')
-rw-r--r-- | bin/hi.c | 15 |
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(®ex); 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(®ex); } } |