From: schwarze Date: Wed, 17 Dec 2014 18:45:00 +0000 (+0000) Subject: Be a bit more lenient in what to accept for section names given X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=afe74b66c9d3a5ef85096f8c4c9fb32f607baf6c;p=openbsd 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). --- diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 28b305f1f57..086fe7acdf7 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.112 2014/12/15 18:04:32 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.113 2014/12/17 18:45:00 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze @@ -103,6 +103,7 @@ main(int argc, char *argv[]) struct manpaths paths; char *auxpaths; char *defos; + unsigned char *uc; struct manpage *res, *resp; char *conf_file, *defpaths; size_t isec, i, sz; @@ -283,11 +284,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--; }