aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-16 16:19:16 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-16 16:19:16 +0000
commitcc516034d1b0b7355caa69983d070dcd2aa5065c (patch)
treebdef8967ca393523f4fe608d3540c677cb63aadb
parent4f0f4a988fbe14105c51304b1139fe5a1534a88e (diff)
downloadmandoc-cc516034d1b0b7355caa69983d070dcd2aa5065c.tar.gz
mandoc-cc516034d1b0b7355caa69983d070dcd2aa5065c.tar.zst
mandoc-cc516034d1b0b7355caa69983d070dcd2aa5065c.zip
merge revision 1.282: fix apropos -O
-rw-r--r--main.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/main.c b/main.c
index 8a765cc0..edfa6089 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.273.2.6 2017/02/10 15:57:47 schwarze Exp $ */
+/* $Id: main.c,v 1.273.2.7 2017/02/16 16:19:16 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -115,17 +115,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;
@@ -173,6 +170,7 @@ main(int argc, char *argv[])
memset(&search, 0, sizeof(struct mansearch));
search.outkey = "Nd";
+ oarg = NULL;
if (strcmp(progname, BINM_MAN) == 0)
search.argmode = ARG_NAME;
@@ -251,15 +249,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;
@@ -304,6 +294,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))