From 361d018b3793c23da7907e99deef4f1159e72f92 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 17 Dec 2014 18:45:35 +0000 Subject: Be a bit more lenient in what to accept for section names given as the first man(1) command line argument without -s: Accept digits like "1", "2"; digit+letter like "3p", "1X"; and "n". Issue reported by Svyatoslav Mishyn (Crux Linux). --- main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 87afb45e..16dbfc3a 100644 --- a/main.c +++ b/main.c @@ -114,6 +114,7 @@ main(int argc, char *argv[]) struct manpaths paths; char *auxpaths; char *defos; + unsigned char *uc; #if HAVE_SQLITE3 struct manpage *res, *resp; char *conf_file, *defpaths; @@ -309,11 +310,11 @@ main(int argc, char *argv[]) argv = help_argv; argc = 1; } - } else if (argv[0] != NULL && ( - (isdigit((unsigned char)argv[0][0]) && - (argv[0][1] == '\0' || !strcmp(argv[0], "3p"))) || - (argv[0][0] == 'n' && argv[0][1] == '\0'))) { - search.sec = argv[0]; + } else if (((uc = argv[0]) != NULL) && + ((isdigit(uc[0]) && (uc[1] == '\0' || + (isalpha(uc[1]) && uc[2] == '\0'))) || + (uc[0] == 'n' && uc[1] == '\0'))) { + search.sec = uc; argv++; argc--; } -- cgit