summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2002-03-29 22:43:43 +0000
committermarkm <markm@FreeBSD.org>2002-03-29 22:43:43 +0000
commit76fe441a7bf75d73962641b785f158b5cc9dc7f8 (patch)
tree4e267e060bfb6d96f46ab0d79c49b277402c0dd0 /lib/libc/stdlib
parent6085f75ded37ec415ded7d6373ecd09bcb088ac4 (diff)
downloadFreeBSD-src-76fe441a7bf75d73962641b785f158b5cc9dc7f8.zip
FreeBSD-src-76fe441a7bf75d73962641b785f158b5cc9dc7f8.tar.gz
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.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/getopt.c11
-rw-r--r--lib/libc/stdlib/malloc.c6
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c
index 0f9918d..4cad100 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "namespace.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#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 */
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 202ac69..43aad2d 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -297,14 +297,12 @@ wrtmessage(char *p1, char *p2, char *p3, char *p4)
void (*_malloc_message)(char *p1, char *p2, char *p3, char *p4) = wrtmessage;
-extern char *__progname;
-
static void
wrterror(char *p)
{
suicide = 1;
- _malloc_message(__progname, malloc_func, " error: ", p);
+ _malloc_message(_getprogname(), malloc_func, " error: ", p);
abort();
}
@@ -314,7 +312,7 @@ wrtwarning(char *p)
if (malloc_abort)
wrterror(p);
- _malloc_message(__progname, malloc_func, " warning: ", p);
+ _malloc_message(_getprogname(), malloc_func, " warning: ", p);
}
/*
OpenPOWER on IntegriCloud