diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-03-20 14:32:24 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-03-20 14:32:24 +0000 |
commit | e1da0024fc38f377da566ffdc8079e70da00de82 (patch) | |
tree | 5d55d3f7732ac02d151baa8a2e8f32c35775236f /main.c | |
parent | 547f4706fea1be6eb30dfe359e17783843dbcede (diff) | |
download | mandoc-e1da0024fc38f377da566ffdc8079e70da00de82.tar.gz mandoc-e1da0024fc38f377da566ffdc8079e70da00de82.tar.zst mandoc-e1da0024fc38f377da566ffdc8079e70da00de82.zip |
Silently ignore invalid -m input formats rather than erroring out.
As observed by Jan Stary <hans at stare dot cz>, this is useful such
that after 'alias man="man -m $HOME/man"', 'man -l foo.1' still works.
Simplify and shorten the description of -m, and use .Ic for macros.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.285 2017/03/03 14:23:23 schwarze Exp $ */ +/* $Id: main.c,v 1.286 2017/03/20 14:32:24 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -93,7 +93,7 @@ static void fs_search(const struct mansearch *, const struct manpaths *, int, char**, struct manpage **, size_t *); static int koptions(int *, char *); -static int moptions(int *, char *); +static void moptions(int *, char *); static void mmsg(enum mandocerr, enum mandoclevel, const char *, int, int, const char *); static void outdata_alloc(struct curparse *); @@ -442,8 +442,8 @@ main(int argc, char *argv[]) } #endif - if (search.argmode == ARG_FILE && ! moptions(&options, auxpaths)) - return (int)MANDOCLEVEL_BADARG; + if (search.argmode == ARG_FILE) + moptions(&options, auxpaths); mchars_alloc(); curp.mp = mparse_alloc(options, curp.wlevel, mmsg, defos); @@ -919,24 +919,16 @@ koptions(int *options, char *arg) return 1; } -static int +static void moptions(int *options, char *arg) { if (arg == NULL) - /* nothing to do */; - else if (0 == strcmp(arg, "doc")) + return; + if (strcmp(arg, "doc") == 0) *options |= MPARSE_MDOC; - else if (0 == strcmp(arg, "andoc")) - /* nothing to do */; - else if (0 == strcmp(arg, "an")) + else if (strcmp(arg, "an") == 0) *options |= MPARSE_MAN; - else { - warnx("-m %s: Bad argument", arg); - return 0; - } - - return 1; } static int |