=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/main.c,v retrieving revision 1.161 retrieving revision 1.162 diff -u -r1.161 -r1.162 --- src/usr.bin/mandoc/main.c 2015/10/22 21:53:49 1.161 +++ src/usr.bin/mandoc/main.c 2015/11/06 16:27:13 1.162 @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.161 2015/10/22 21:53:49 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.162 2015/11/06 16:27:13 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze @@ -92,8 +92,6 @@ static void usage(enum argmode) __attribute__((noreturn)); static int woptions(struct curparse *, char *); -extern char *__progname; - static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; static char help_arg[] = "help"; static char *help_argv[] = {help_arg, NULL}; @@ -107,6 +105,7 @@ struct curparse curp; struct mansearch search; struct tag_files *tag_files; + const char *progname; char *auxpaths; char *defos; unsigned char *uc; @@ -123,8 +122,9 @@ int use_pager; int c; - if (0 == strncmp(__progname, "mandocdb", 8) || - 0 == strncmp(__progname, "makewhatis", 10)) + progname = getprogname(); + if (strncmp(progname, "mandocdb", 8) == 0 || + strncmp(progname, "makewhatis", 10) == 0) return mandocdb(argc, argv); if (pledge("stdio rpath tmppath proc exec flock", NULL) == -1) @@ -139,13 +139,13 @@ memset(&search, 0, sizeof(struct mansearch)); search.outkey = "Nd"; - if (strcmp(__progname, "man") == 0) + if (strcmp(progname, "man") == 0) search.argmode = ARG_NAME; - else if (strncmp(__progname, "apropos", 7) == 0) + else if (strncmp(progname, "apropos", 7) == 0) search.argmode = ARG_EXPR; - else if (strncmp(__progname, "whatis", 6) == 0) + else if (strncmp(progname, "whatis", 6) == 0) search.argmode = ARG_WORD; - else if (strncmp(__progname, "help", 4) == 0) + else if (strncmp(progname, "help", 4) == 0) search.argmode = ARG_NAME; else search.argmode = ARG_FILE; @@ -286,7 +286,7 @@ */ if (search.argmode == ARG_NAME) { - if (*__progname == 'h') { + if (*progname == 'h') { if (argc == 0) { argv = help_argv; argc = 1; @@ -907,7 +907,7 @@ { const char *mparse_msg; - fprintf(stderr, "%s: %s:", __progname, file); + fprintf(stderr, "%s: %s:", getprogname(), file); if (line) fprintf(stderr, "%d:%d:", line, col + 1);