summary refs log tree commit diff
path: root/bin/htagml.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-10-01 23:07:29 +0000
committerJune McEnroe <june@causal.agency>2021-10-01 23:07:57 +0000
commitefebf0f62a815210f249de5f05bc4dd3120bf430 (patch)
treeda364c1289abea0a0d22a5a48cdc374e462485b4 /bin/htagml.c
parentRemove igp (diff)
downloadsrc-efebf0f62a815210f249de5f05bc4dd3120bf430.tar.gz
src-efebf0f62a815210f249de5f05bc4dd3120bf430.zip
Add htagml -m to rename main tag
Diffstat (limited to '')
-rw-r--r--bin/htagml.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/htagml.c b/bin/htagml.c
index b4101b64..033f717a 100644
--- a/bin/htagml.c
+++ b/bin/htagml.c
@@ -80,12 +80,14 @@ static char *hstrstr(const char *haystack, const char *needle) {
 int main(int argc, char *argv[]) {
 	bool pre = false;
 	bool pipe = false;
+	bool main = false;
 	bool index = false;
 	const char *tagsPath = "tags";
-	for (int opt; 0 < (opt = getopt(argc, argv, "f:ipx"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "f:impx"));) {
 		switch (opt) {
 			break; case 'f': tagsPath = optarg;
 			break; case 'i': pipe = true;
+			break; case 'm': main = true;
 			break; case 'p': pre = true;
 			break; case 'x': index = true;
 			break; default:  return EX_USAGE;
@@ -194,6 +196,7 @@ int main(int argc, char *argv[]) {
 		if (!match && tag[0] == 'M') {
 			mlen = 4;
 			match = (pipe ? hstrstr : strstr)(buf, "main");
+			if (main) tag = "main";
 		}
 		if (!match) {
 			mlen = strlen(buf) - 1;