From 4cd01193678a79d81b61be31c50b139d7a4c44d4 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Fri, 29 Mar 2002 22:43:43 +0000 Subject: Do not use __progname directly (except in [gs]etprogname(3)). Also, make an internal _getprogname() that is used only inside libc. For libc, getprogname(3) is a weak symbol in case a function of the same name is defined in userland. --- lib/libc/stdlib/getopt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/libc/stdlib/getopt.c') diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index 0f9918d836a7b..4cad1000493e4 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -37,9 +37,13 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; #include __FBSDID("$FreeBSD$"); +#include "namespace.h" #include #include #include +#include "un-namespace.h" + +#include "libc_private.h" int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ @@ -61,7 +65,6 @@ getopt(nargc, nargv, ostr) char * const *nargv; const char *ostr; { - extern char *__progname; static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ @@ -88,8 +91,8 @@ getopt(nargc, nargv, ostr) if (!*place) ++optind; if (opterr && *ostr != ':' && optopt != BADCH) - (void)fprintf(stderr, - "%s: illegal option -- %c\n", __progname, optopt); + (void)fprintf(stderr, "%s: illegal option -- %c\n", + _getprogname(), optopt); return (BADCH); } if (*++oli != ':') { /* don't need argument */ @@ -107,7 +110,7 @@ getopt(nargc, nargv, ostr) if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", - __progname, optopt); + _getprogname(), optopt); return (BADCH); } else /* white space */ -- cgit v1.2.3