aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-16 10:56:07 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-16 10:56:07 +0000
commitbd8ae2e9c7b3b6677cfb59eecd2620e3819c3d99 (patch)
tree2312f4a0c38e3d69fe3005bddd6512ab35913d8a /main.c
parentaabe46b7c8c0f9da0079b71a1eb350536961bc3f (diff)
downloadmandoc-bd8ae2e9c7b3b6677cfb59eecd2620e3819c3d99.tar.gz
mandoc-bd8ae2e9c7b3b6677cfb59eecd2620e3819c3d99.tar.zst
mandoc-bd8ae2e9c7b3b6677cfb59eecd2620e3819c3d99.zip
Fix rev. 1.280: -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.
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/main.c b/main.c
index 460fd05d..613bae76 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.281 2017/02/10 15:45:28 schwarze Exp $ */
+/* $Id: main.c,v 1.282 2017/02/16 10:56:07 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -113,17 +113,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;
@@ -169,6 +166,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;
@@ -247,15 +245,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;
@@ -300,6 +290,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))