diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-17 18:45:35 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-17 18:45:35 +0000 |
commit | afa59522d01b789f749148991b7d2118023c0285 (patch) | |
tree | b6040dd9169f9282b512cd38b17738ab1f4648da /main.c | |
parent | da9096c534bd288ffa8acf2aea3a0611c1c6ecd2 (diff) | |
download | mandoc-afa59522d01b789f749148991b7d2118023c0285.tar.gz mandoc-afa59522d01b789f749148991b7d2118023c0285.tar.zst mandoc-afa59522d01b789f749148991b7d2118023c0285.zip |
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).
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.206 2014/12/15 18:05:57 schwarze Exp $ */ +/* $Id: main.c,v 1.207 2014/12/17 18:45:35 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -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--; } |