summary refs log tree commit diff
path: root/bin/mtags.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-20 18:22:07 -0500
committerJune McEnroe <june@causal.agency>2021-01-20 18:22:07 -0500
commit8f13185e5376c2b7414115bb67dca3a76dc7dec1 (patch)
tree699318e0732ad38d34de7cdcc8a13fc82a69b3a5 /bin/mtags.c
parentAdd messy sh lexer (diff)
downloadsrc-8f13185e5376c2b7414115bb67dca3a76dc7dec1.tar.gz
src-8f13185e5376c2b7414115bb67dca3a76dc7dec1.zip
Generate tags for sh files in mtags
Only matches functions declared at the beginnings of lines, but I'm
fine with that.
Diffstat (limited to 'bin/mtags.c')
-rw-r--r--bin/mtags.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/mtags.c b/bin/mtags.c
index f055b443..282d9f03 100644
--- a/bin/mtags.c
+++ b/bin/mtags.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[]) {
 
 	regex_t makeFile, makeLine;
 	regex_t mdocFile, mdocLine;
+	regex_t shFile, shLine;
 	int error = 0
 		|| regcomp(&makeFile, "(^|/)Makefile|[.]mk$", REG_EXTENDED | REG_NOSUB)
 		|| regcomp(
@@ -57,7 +58,11 @@ int main(int argc, char *argv[]) {
 			REG_EXTENDED
 		)
 		|| regcomp(&mdocFile, "[.][1-9]$", REG_EXTENDED | REG_NOSUB)
-		|| regcomp(&mdocLine, "^[.]S[hs] ([^\t\n]+)", REG_EXTENDED);
+		|| regcomp(&mdocLine, "^[.]S[hs] ([^\t\n]+)", REG_EXTENDED)
+		|| regcomp(
+			&shFile, "(^|/)[.](profile|shrc)|[.]sh$", REG_EXTENDED | REG_NOSUB
+		)
+		|| regcomp(&shLine, "^([_[:alnum:]]+)[[:blank:]]*[(][)]", REG_EXTENDED);
 	assert(!error);
 
 	size_t cap = 0;
@@ -68,6 +73,8 @@ int main(int argc, char *argv[]) {
 			regex = &makeLine;
 		} else if (!regexec(&mdocFile, argv[i], 0, NULL, 0)) {
 			regex = &mdocLine;
+		} else if (!regexec(&shFile, argv[i], 0, NULL, 0)) {
+			regex = &shLine;
 		} else {
 			warnx("skipping unknown file type %s", argv[i]);
 			continue;