From afe74b66c9d3a5ef85096f8c4c9fb32f607baf6c Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 17 Dec 2014 18:45:00 +0000 Subject: [PATCH] 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). --- usr.bin/mandoc/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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--; } -- 2.20.1