summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/htagml.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/bin/htagml.c b/bin/htagml.c
index 9ab1e1c2..b4101b64 100644
--- a/bin/htagml.c
+++ b/bin/htagml.c
@@ -81,10 +81,10 @@ int main(int argc, char *argv[]) {
 	bool pre = false;
 	bool pipe = false;
 	bool index = false;
-	const char *tagsFile = "tags";
+	const char *tagsPath = "tags";
 	for (int opt; 0 < (opt = getopt(argc, argv, "f:ipx"));) {
 		switch (opt) {
-			break; case 'f': tagsFile = optarg;
+			break; case 'f': tagsPath = optarg;
 			break; case 'i': pipe = true;
 			break; case 'p': pre = true;
 			break; case 'x': index = true;
@@ -94,8 +94,16 @@ int main(int argc, char *argv[]) {
 	if (optind == argc) errx(EX_USAGE, "name required");
 	const char *name = argv[optind];
 
-	FILE *file = fopen(tagsFile, "r");
-	if (!file) err(EX_NOINPUT, "%s", tagsFile);
+	FILE *file = fopen(name, "r");
+	if (!file) err(EX_NOINPUT, "%s", name);
+
+	FILE *tagsFile = fopen(tagsPath, "r");
+	if (!tagsFile) err(EX_NOINPUT, "%s", tagsPath);
+
+#ifdef __OpenBSD__
+	int error = pledge("stdio", NULL);
+	if (error) err(EX_OSERR, "pledge");
+#endif
 
 	size_t len = 0;
 	size_t cap = 256;
@@ -109,7 +117,7 @@ int main(int argc, char *argv[]) {
 
 	char *buf = NULL;
 	size_t bufCap = 0;
-	while (0 < getline(&buf, &bufCap, file)) {
+	while (0 < getline(&buf, &bufCap, tagsFile)) {
 		char *line = buf;
 		char *tag = strsep(&line, "\t");
 		char *file = strsep(&line, "\t");
@@ -142,10 +150,7 @@ int main(int argc, char *argv[]) {
 		}
 		len++;
 	}
-	fclose(file);
-
-	file = fopen(name, "r");
-	if (!file) err(EX_NOINPUT, "%s", name);
+	fclose(tagsFile);
 
 	int num = 0;
 	printf(pre ? "<pre>" : index ? "<ul class=\"index\">\n" : "");
Tarmak4.keylayout?id=f251d7f00c64c1dfc5f065bea72f0ed9fc95b9b7&follow=1'>Remove Tarmak and Colemak keylayoutsJune McEnroe 2018-01-29Generalize hnelJune McEnroe It's like tr for PTYs. 2018-01-29Remove Tarmak remappings from vimJune McEnroe 2018-01-29Switch back to QWERTY on LinuxJune McEnroe I think the only thing I'll miss is N and E on home row (which was Tarmak 1, if I remember correctly). 2018-01-29Take fbclock font in env varJune McEnroe 2018-01-29Support fbclock fonts wider than 8June McEnroe 2018-01-29Take font path on fbclock argvJune McEnroe 2018-01-29Add fbclockJune McEnroe 2018-01-29Remove color from MakefileJune McEnroe 2018-01-29Set t_Co = 8June McEnroe Weirdly with t_Co = 16 yellow and bright white weren't showing up on TERM=linux. 2018-01-29Add :Q command aliasJune McEnroe It seemes I can't take my finger off the shift key fast enough. 2018-01-29Add setuid target for briJune McEnroe 2018-01-28Add init function to fb interfaceJune McEnroe 2018-01-28Add color.cJune McEnroe