From e1da0024fc38f377da566ffdc8079e70da00de82 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 20 Mar 2017 14:32:24 +0000 Subject: Silently ignore invalid -m input formats rather than erroring out. As observed by Jan Stary , 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. --- main.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 22b82530..bbe18abd 100644 --- a/main.c +++ b/main.c @@ -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 * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze @@ -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 -- cgit v1.2.3-56-ge451