summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-12-17 18:45:35 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-12-17 18:45:35 +0000
commit361d018b3793c23da7907e99deef4f1159e72f92 (patch)
treef7b25f0255b3cc63f35939a2103db88927557ab0
parent049de3868dfab614357f07d4d25fa4b7c2e4b7f5 (diff)
downloadmandoc-361d018b3793c23da7907e99deef4f1159e72f92.tar.gz
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 <juef at openmailbox dot org> (Crux Linux).
-rw-r--r--main.c11
1 files changed, 6 insertions, 5 deletions
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--;
}