=================================================================== RCS file: /cvs/mandoc/main.c,v retrieving revision 1.281 retrieving revision 1.284 diff -u -p -r1.281 -r1.284 --- mandoc/main.c 2017/02/10 15:45:28 1.281 +++ mandoc/main.c 2017/02/22 14:58:48 1.284 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.281 2017/02/10 15:45:28 schwarze Exp $ */ +/* $Id: main.c,v 1.284 2017/02/22 14:58:48 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze @@ -100,7 +100,7 @@ static void parse(struct curparse *, int, const cha static void passthrough(const char *, int, int); static pid_t spawn_pager(struct tag_files *); static int toptions(struct curparse *, char *); -static void usage(enum argmode) __attribute__((noreturn)); +static void usage(enum argmode) __attribute__((__noreturn__)); static int woptions(struct curparse *, char *); static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; @@ -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; @@ -152,7 +149,7 @@ main(int argc, char *argv[]) return mandocdb(argc, argv); #if HAVE_PLEDGE - if (pledge("stdio rpath tmppath tty proc exec flock", NULL) == -1) + if (pledge("stdio rpath tmppath tty proc exec", NULL) == -1) err((int)MANDOCLEVEL_SYSERR, "pledge"); #endif @@ -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)) @@ -307,7 +312,7 @@ main(int argc, char *argv[]) #if HAVE_PLEDGE if (!use_pager) - if (pledge("stdio rpath flock", NULL) == -1) + if (pledge("stdio rpath", NULL) == -1) err((int)MANDOCLEVEL_SYSERR, "pledge"); #endif