From 0b6c3d1f74b3bc4247a70775f078e90c11f771c8 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 22 Aug 2014 18:07:15 +0000 Subject: implement man(1) quirk: section argument without -s --- main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.c b/main.c index 72056d2d..d547c113 100644 --- a/main.c +++ b/main.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -227,6 +228,8 @@ main(int argc, char *argv[]) if (show_usage) usage(search.argmode); + /* Postprocess options. */ + if (outmode == OUTMODE_DEF) { switch (search.argmode) { case ARG_FILE: @@ -242,12 +245,25 @@ main(int argc, char *argv[]) } } + /* Parse arguments. */ + argc -= optind; argv += optind; #if HAVE_SQLITE3 auxargv = NULL; #endif + /* Quirk for a man(1) section argument without -s. */ + + if (search.argmode == ARG_NAME && + argv[0] != NULL && + isdigit((unsigned char)argv[0][0]) && + (argv[0][1] == '\0' || !strcmp(argv[0], "3p"))) { + search.sec = argv[0]; + argv++; + argc--; + } + rc = MANDOCLEVEL_OK; /* man(1), whatis(1), apropos(1) */ -- cgit