summary refs log tree commit diff
path: root/config.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-10 13:49:57 -0500
committerJune McEnroe <june@causal.agency>2021-01-11 18:52:46 -0500
commit6e311fab52a3544776f35068a9f07f66a8780812 (patch)
treecc1889cb1eb003528236fff0d3da562a42e0afdc /config.c
parentSend CAP END if CAP LS response is empty (diff)
downloadpounce-6e311fab52a3544776f35068a9f07f66a8780812.tar.gz
pounce-6e311fab52a3544776f35068a9f07f66a8780812.zip
Allow interspersing flags and config files
Don't wait for getopt_long to move all the arguments to the end. This
allows overriding options set by config files by placing flags after
them on the command line.
Diffstat (limited to 'config.c')
-rw-r--r--config.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/config.c b/config.c
index 958ee45..1835ef1 100644
--- a/config.c
+++ b/config.c
@@ -54,21 +54,17 @@ int getopt_config(
 	const char *optstring, const struct option *longopts, int *longindex
 ) {
 	static int opt;
-	if (opt >= 0) {
-		opt = getopt_long(argc, argv, optstring, longopts, longindex);
-	}
-	if (opt >= 0) return opt;
-
 	for (;;) {
 		if (!file) {
-			if (optind < argc) {
-				num = 0;
-				path = argv[optind++];
-				file = configOpen(path, "r");
-				if (!file) return clean('?');
-			} else {
-				return clean(-1);
+			if (optind == argc) return clean(-1);
+			if (opt >= 0 && argv[optind][0] == '-') {
+				opt = getopt_long(argc, argv, optstring, longopts, longindex);
+				if (opt >= 0 || optind == argc) return clean(opt);
 			}
+			num = 0;
+			path = argv[optind++];
+			file = configOpen(path, "r");
+			if (!file) return clean('?');
 		}
 
 		for (;;) {
class='logsubject'>Remove hacky tagging from hilexJune McEnroe God that makes the lexers so much simpler. 2021-01-12Add htagml -iJune McEnroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe This simplifies some things, adds support for line number tag definitions, and should enable combining htagml with other preprocessors in the future. 2021-01-12Split fields by tab onlyJune McEnroe Also don't fail hard on non-forward-search definitions. 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe neovim is laggy as hell in my OpenBSD VM, so I switched to vi so I could type without getting frustrated. 2021-01-09Add c -t flag to print expression typeJune McEnroe Also add missing float case. 2021-01-05Update taglineJune McEnroe