summary refs log tree commit diff
path: root/bin/mtags.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mtags.c')
-rw-r--r--bin/mtags.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/bin/mtags.c b/bin/mtags.c
index 1ebfbac5..5c42f343 100644
--- a/bin/mtags.c
+++ b/bin/mtags.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2021  C. McEnroe <june@causal.agency>
+/* Copyright (C) 2021  June McEnroe <june@causal.agency>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -21,7 +21,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sysexits.h>
 #include <unistd.h>
 
 static void escape(FILE *file, const char *str, size_t len) {
@@ -34,23 +33,29 @@ static void escape(FILE *file, const char *str, size_t len) {
 }
 
 int main(int argc, char *argv[]) {
+	int error;
 	bool append = false;
 	const char *path = "tags";
 	for (int opt; 0 < (opt = getopt(argc, argv, "af:"));) {
 		switch (opt) {
 			break; case 'a': append = true;
 			break; case 'f': path = optarg;
-			break; default:  return EX_USAGE;
+			break; default:  return 1;
 		}
 	}
 
 	FILE *tags = fopen(path, (append ? "a" : "w"));
-	if (!tags) err(EX_CANTCREAT, "%s", path);
+	if (!tags) err(1, "%s", path);
+
+#ifdef __OpenBSD__
+	error = pledge("stdio rpath", NULL);
+	if (error) err(1, "pledge");
+#endif
 
 	regex_t makeFile, makeLine;
 	regex_t mdocFile, mdocLine;
 	regex_t shFile, shLine;
-	int error = 0
+	error = 0
 		|| regcomp(&makeFile, "(^|/)Makefile|[.]mk$", REG_EXTENDED | REG_NOSUB)
 		|| regcomp(
 			&makeLine,
@@ -81,7 +86,7 @@ int main(int argc, char *argv[]) {
 		}
 
 		FILE *file = fopen(argv[i], "r");
-		if (!file) err(EX_NOINPUT, "%s", argv[i]);
+		if (!file) err(1, "%s", argv[i]);
 
 		while (0 < getline(&buf, &cap, file)) {
 			regmatch_t match[2];