summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2017-02-16 10:55:57 +0000
committerschwarze <schwarze@openbsd.org>2017-02-16 10:55:57 +0000
commitc93abf39053516064e6aa53f6510bdd57d9ee878 (patch)
tree720a417c8888351b535d25d0aecc0d53a20115f8
parentStyle nits. (diff)
downloadwireguard-openbsd-c93abf39053516064e6aa53f6510bdd57d9ee878.tar.xz
wireguard-openbsd-c93abf39053516064e6aa53f6510bdd57d9ee878.zip
Fix rev. 1.183: -O syntax is different in default apropos(1) output
mode and in other output modes, so do not error out prematurely. Also sort local variables in main() while here.
-rw-r--r--usr.bin/mandoc/main.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index d46edf42a0c..8dc2fe4dbc6 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.185 2017/02/10 15:44:31 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.186 2017/02/16 10:55:57 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -107,17 +107,14 @@ int
main(int argc, char *argv[])
{
struct manconf conf;
- struct curparse curp;
struct mansearch search;
+ struct curparse curp;
struct tag_files *tag_files;
- const char *progname;
- char *auxpaths;
- char *defos;
- unsigned char *uc;
struct manpage *res, *resp;
- char *conf_file, *defpaths;
- const char *sec;
- const char *thisarg;
+ const char *progname, *sec, *thisarg;
+ char *conf_file, *defpaths, *auxpaths;
+ char *defos, *oarg;
+ unsigned char *uc;
size_t i, sz;
int prio, best_prio;
enum outmode outmode;
@@ -145,6 +142,7 @@ main(int argc, char *argv[])
memset(&search, 0, sizeof(struct mansearch));
search.outkey = "Nd";
+ oarg = NULL;
if (strcmp(progname, "man") == 0)
search.argmode = ARG_NAME;
@@ -223,15 +221,7 @@ main(int argc, char *argv[])
auxpaths = optarg;
break;
case 'O':
- search.outkey = optarg;
- while (optarg != NULL) {
- thisarg = optarg;
- if (manconf_output(&conf.output,
- strsep(&optarg, ","), 0) == 0)
- continue;
- warnx("-O %s: Bad argument", thisarg);
- return (int)MANDOCLEVEL_BADARG;
- }
+ oarg = optarg;
break;
case 'S':
search.arch = optarg;
@@ -276,6 +266,21 @@ main(int argc, char *argv[])
}
}
+ if (oarg != NULL) {
+ if (outmode == OUTMODE_LST)
+ search.outkey = oarg;
+ else {
+ while (oarg != NULL) {
+ thisarg = oarg;
+ if (manconf_output(&conf.output,
+ strsep(&oarg, ","), 0) == 0)
+ continue;
+ warnx("-O %s: Bad argument", thisarg);
+ return (int)MANDOCLEVEL_BADARG;
+ }
+ }
+ }
+
if (outmode == OUTMODE_FLN ||
outmode == OUTMODE_LST ||
!isatty(STDOUT_FILENO))