Date: Thu, 28 Mar 2002 20:29:07 +0000 From: markm@freebsd.org To: audit@freebsd.org Subject: __progname cleanups - commit candidate 2 Message-ID: <200203282029.g2SKTDdC005176@greenpeace.grondar.org>
next in thread | raw e-mail | index | archive | help
Index: csu/alpha/Makefile
===================================================================
RCS file: /home/ncvs/src/lib/csu/alpha/Makefile,v
retrieving revision 1.16
diff -u -d -r1.16 Makefile
--- csu/alpha/Makefile 27 Oct 2001 08:29:51 -0000 1.16
+++ csu/alpha/Makefile 26 Mar 2002 12:09:52 -0000
@@ -6,7 +6,8 @@
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o
CFLAGS+= -Wall -Wno-unused \
- -I${.CURDIR}/../common
+ -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
NOMAN= true
NOPIC= true
NOPROFILE= true
Index: csu/alpha/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/alpha/crt1.c,v
retrieving revision 1.10
diff -u -d -r1.10 crt1.c
--- csu/alpha/crt1.c 26 Oct 2001 06:45:10 -0000 1.10
+++ csu/alpha/crt1.c 27 Mar 2002 12:18:32 -0000
@@ -40,6 +40,7 @@
#endif
#include <stdlib.h>
+#include "libc_private.h"
#include "crtbrand.c"
struct Struct_Obj_Entry;
@@ -60,7 +61,7 @@
#endif
char **environ;
-char *__progname = "";
+const char *__progname = "";
/* The entry function. */
void
@@ -72,13 +73,13 @@
int argc;
char **argv;
char **env;
+ const char *s;
argc = * (long *) ap;
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
if(argc > 0 && argv[0] != NULL) {
- char *s;
__progname = argv[0];
for (s = __progname; *s != '\0'; s++)
if (*s == '/')
Index: csu/i386/Makefile
===================================================================
RCS file: /home/ncvs/src/lib/csu/i386/Makefile,v
retrieving revision 1.40
diff -u -d -r1.40 Makefile
--- csu/i386/Makefile 27 Aug 1999 23:57:54 -0000 1.40
+++ csu/i386/Makefile 26 Mar 2002 12:10:19 -0000
@@ -1,7 +1,8 @@
# from: @(#)Makefile 5.6 (Berkeley) 5/22/91
# $FreeBSD: src/lib/csu/i386/Makefile,v 1.40 1999/08/27 23:57:54 peter Exp $
-CFLAGS+= -DLIBC_SCCS -fno-omit-frame-pointer
+CFLAGS+= -DLIBC_SCCS -fno-omit-frame-pointer \
+ -I${.CURDIR}/../../libc/include
OBJS= crt0.o c++rt0.o gcrt0.o scrt0.o sgcrt0.o
CLEANFILES= a.out crt0.o.tmp c++rt0.o.tmp gcrt0.o.tmp scrt0.o.tmp \
sgcrt0.o.tmp
Index: csu/i386/crt0.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/i386/crt0.c,v
retrieving revision 1.36
diff -u -d -r1.36 crt0.c
--- csu/i386/crt0.c 27 Aug 1999 23:57:55 -0000 1.36
+++ csu/i386/crt0.c 27 Mar 2002 12:19:46 -0000
@@ -37,10 +37,13 @@
#ifdef DYNAMIC
#include <sys/types.h>
#include <sys/syscall.h>
-#include <a.out.h>
-#include <string.h>
#include <sys/mman.h>
+
+#include <a.out.h>
#include <link.h>
+#include <string.h>
+
+#include "libc_private.h"
/* !!!
* This is gross, ld.so is a ZMAGIC a.out, but has `sizeof(hdr)' for
@@ -88,8 +91,7 @@
int _callmain();
int errno;
-static char empty[1];
-char *__progname = empty;
+const char *__progname = "";
char **environ;
/* Globals used by dlopen() and related functions in libc */
@@ -144,6 +146,7 @@
register struct kframe *kfp;
register char **targv;
register char **argv;
+ register const char *s;
extern void _mcleanup();
#ifdef DYNAMIC
volatile caddr_t x;
@@ -162,7 +165,6 @@
environ = targv;
if (argv[0]) {
- register char *s;
__progname = argv[0];
for (s=__progname; *s != '\0'; s++)
if (*s == '/')
Index: csu/i386-elf/Makefile
===================================================================
RCS file: /home/ncvs/src/lib/csu/i386-elf/Makefile,v
retrieving revision 1.9
diff -u -d -r1.9 Makefile
--- csu/i386-elf/Makefile 27 Oct 2001 08:30:36 -0000 1.9
+++ csu/i386-elf/Makefile 26 Mar 2002 12:10:02 -0000
@@ -6,7 +6,8 @@
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o
CFLAGS+= -elf -Wall -fkeep-inline-functions \
- -I${.CURDIR}/../common
+ -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
LDFLAGS+= -elf
NOMAN= true
NOPIC= true
Index: csu/i386-elf/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/i386-elf/crt1.c,v
retrieving revision 1.6
diff -u -d -r1.6 crt1.c
--- csu/i386-elf/crt1.c 27 Feb 2002 22:08:05 -0000 1.6
+++ csu/i386-elf/crt1.c 27 Mar 2002 12:18:40 -0000
@@ -29,6 +29,7 @@
#include <stddef.h>
#include <stdlib.h>
+#include "libc_private.h"
#include "crtbrand.c"
typedef void (*fptr)(void);
@@ -57,7 +58,7 @@
#endif
char **environ;
-char *__progname = "";
+const char *__progname = "";
void
_start(char *arguments, ...)
@@ -66,6 +67,7 @@
int argc;
char **argv;
char **env;
+ const char *s;
rtld_cleanup = get_rtld_cleanup();
argv = &arguments;
@@ -73,7 +75,6 @@
env = argv + argc + 1;
environ = env;
if (argc > 0 && argv[0] != NULL) {
- char *s;
__progname = argv[0];
for (s = __progname; *s != '\0'; s++)
if (*s == '/')
Index: csu/ia64/Makefile
===================================================================
RCS file: /home/ncvs/src/lib/csu/ia64/Makefile,v
retrieving revision 1.4
diff -u -d -r1.4 Makefile
--- csu/ia64/Makefile 27 Oct 2001 08:29:03 -0000 1.4
+++ csu/ia64/Makefile 26 Mar 2002 12:10:27 -0000
@@ -6,7 +6,8 @@
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o
CFLAGS+= -Wall -Wno-unused \
- -I${.CURDIR}/../common
+ -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
NOMAN= true
NOPIC= true
NOPROFILE= true
Index: csu/ia64/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/ia64/crt1.c,v
retrieving revision 1.6
diff -u -d -r1.6 crt1.c
--- csu/ia64/crt1.c 23 Mar 2002 18:14:20 -0000 1.6
+++ csu/ia64/crt1.c 27 Mar 2002 12:18:47 -0000
@@ -36,6 +36,7 @@
#endif
#include <stdlib.h>
+#include "libc_private.h"
#include "crtbrand.c"
struct Struct_Obj_Entry;
@@ -56,7 +57,7 @@
#endif
char **environ;
-char *__progname = "";
+const char *__progname = "";
/* The entry function. */
void
@@ -67,6 +68,7 @@
int argc;
char **argv;
char **env;
+ const char *s;
/* Calculate gp */
__asm __volatile(" \
@@ -82,7 +84,6 @@
env = ap + 2 + argc;
environ = env;
if (argc > 0 && argv[0] != NULL) {
- char *s;
__progname = argv[0];
for (s = __progname; *s != '\0'; s++)
if (*s == '/')
Index: csu/powerpc/Makefile
===================================================================
RCS file: /home/ncvs/src/lib/csu/powerpc/Makefile,v
retrieving revision 1.2
diff -u -d -r1.2 Makefile
--- csu/powerpc/Makefile 27 Oct 2001 08:32:07 -0000 1.2
+++ csu/powerpc/Makefile 26 Mar 2002 12:10:33 -0000
@@ -6,7 +6,8 @@
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o
CFLAGS+= -Wall -Wno-unused \
- -I${.CURDIR}/../common
+ -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
NOMAN= true
NOPIC= true
NOPROFILE= true
Index: csu/powerpc/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/powerpc/crt1.c,v
retrieving revision 1.7
diff -u -d -r1.7 crt1.c
--- csu/powerpc/crt1.c 23 Mar 2002 18:14:04 -0000 1.7
+++ csu/powerpc/crt1.c 27 Mar 2002 12:18:59 -0000
@@ -43,6 +43,7 @@
#endif
#include <stdlib.h>
+#include "libc_private.h"
#include "crtbrand.c"
struct Struct_Obj_Entry;
@@ -63,7 +64,7 @@
#endif
char **environ;
-char *__progname = "";
+const char *__progname = "";
struct ps_strings *__ps_strings;
/* The entry function.
@@ -80,11 +81,11 @@
struct ps_strings *ps_strings; /* BSD extension */
{
char *namep;
+ const char *s;
environ = envp;
if (argc > 0 && argv[0] != NULL) {
- char *s;
__progname = argv[0];
for (s = __progname; *s != '\0'; s++)
if (*s == '/')
Index: csu/sparc64/Makefile
===================================================================
RCS file: /home/ncvs/src/lib/csu/sparc64/Makefile,v
retrieving revision 1.3
diff -u -d -r1.3 Makefile
--- csu/sparc64/Makefile 10 Mar 2002 23:33:49 -0000 1.3
+++ csu/sparc64/Makefile 26 Mar 2002 12:10:44 -0000
@@ -5,7 +5,8 @@
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common
+CFLAGS+= -I${.CURDIR}/../common \
+ -I${.CURDIR}/../../libc/include
NOMAN= true
NOPIC= true
NOPROFILE= true
Index: csu/sparc64/crt1.c
===================================================================
RCS file: /home/ncvs/src/lib/csu/sparc64/crt1.c,v
retrieving revision 1.6
diff -u -d -r1.6 crt1.c
--- csu/sparc64/crt1.c 16 Mar 2002 20:38:46 -0000 1.6
+++ csu/sparc64/crt1.c 27 Mar 2002 12:19:09 -0000
@@ -34,6 +34,7 @@
#endif
#include <stdlib.h>
+#include "libc_private.h"
#include "crtbrand.c"
struct Struct_Obj_Entry;
@@ -55,7 +56,7 @@
#endif
char **environ;
-char *__progname = "";
+const char *__progname = "";
/* The entry function. */
/*
@@ -77,6 +78,7 @@
int argc;
char **argv;
char **env;
+ const char *s;
#if 0
void (*term)(void);
@@ -91,7 +93,6 @@
env = ap + 2 + argc;
environ = env;
if (argc > 0 && argv[0] != NULL) {
- char *s;
__progname = argv[0];
for (s = __progname; *s != '\0'; s++)
if (*s == '/')
Index: libc/gen/err.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/err.c,v
retrieving revision 1.12
diff -u -d -r1.12 err.c
--- libc/gen/err.c 22 Mar 2002 21:52:05 -0000 1.12
+++ libc/gen/err.c 27 Mar 2002 11:08:23 -0000
@@ -39,15 +39,14 @@
#include "namespace.h"
#include <err.h>
-#include "un-namespace.h"
#include <errno.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "un-namespace.h"
-#include <stdarg.h>
-
-extern char *__progname; /* Program name, from crt0. */
+#include "libc_private.h"
static FILE *err_file; /* file to use for error output */
static void (*err_exit)(int);
@@ -110,7 +109,7 @@
{
if (err_file == 0)
err_set_file((FILE *)0);
- fprintf(err_file, "%s: ", __progname);
+ fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL) {
vfprintf(err_file, fmt, ap);
fprintf(err_file, ": ");
@@ -138,7 +137,7 @@
{
if (err_file == 0)
err_set_file((FILE *)0);
- fprintf(err_file, "%s: ", __progname);
+ fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL)
vfprintf(err_file, fmt, ap);
fprintf(err_file, "\n");
@@ -183,7 +182,7 @@
{
if (err_file == 0)
err_set_file((FILE *)0);
- fprintf(err_file, "%s: ", __progname);
+ fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL) {
vfprintf(err_file, fmt, ap);
fprintf(err_file, ": ");
@@ -207,7 +206,7 @@
{
if (err_file == 0)
err_set_file((FILE *)0);
- fprintf(err_file, "%s: ", __progname);
+ fprintf(err_file, "%s: ", _getprogname());
if (fmt != NULL)
vfprintf(err_file, fmt, ap);
fprintf(err_file, "\n");
Index: libc/gen/getlogin.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/getlogin.c,v
retrieving revision 1.7
diff -u -d -r1.7 getlogin.c
--- libc/gen/getlogin.c 1 Feb 2002 00:57:29 -0000 1.7
+++ libc/gen/getlogin.c 27 Mar 2002 08:47:31 -0000
@@ -48,7 +48,7 @@
#include <pthread.h>
#include "un-namespace.h"
-#include <libc_private.h>
+#include "libc_private.h"
#define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex)
#define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex)
Index: libc/gen/getprogname.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/getprogname.c,v
retrieving revision 1.3
diff -u -d -r1.3 getprogname.c
--- libc/gen/getprogname.c 1 Feb 2002 00:57:29 -0000 1.3
+++ libc/gen/getprogname.c 27 Mar 2002 11:13:57 -0000
@@ -1,12 +1,16 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/gen/getprogname.c,v 1.3 2002/02/01 00:57:29 obrien Exp $");
+#include "namespace.h"
#include <stdlib.h>
+#include "un-namespace.h"
-extern const char *__progname;
+#include "libc_private.h"
+
+__weak_reference(_getprogname, getprogname);
const char *
-getprogname(void)
+_getprogname(void)
{
return (__progname);
Index: libc/gen/setproctitle.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/setproctitle.c,v
retrieving revision 1.15
diff -u -d -r1.15 setproctitle.c
--- libc/gen/setproctitle.c 1 Feb 2002 00:57:29 -0000 1.15
+++ libc/gen/setproctitle.c 27 Mar 2002 11:13:25 -0000
@@ -18,6 +18,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/gen/setproctitle.c,v 1.15 2002/02/01 00:57:29 obrien Exp $");
+#include "namespace.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/exec.h>
@@ -31,6 +32,9 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include "un-namespace.h"
+
+#include "libc_private.h"
/*
* Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and
@@ -53,7 +57,6 @@
#include <stdarg.h>
#define SPT_BUFSIZE 2048 /* from other parts of sendmail */
-extern char * __progname; /* is this defined in a .h anywhere? */
void
setproctitle(const char *fmt, ...)
@@ -83,7 +86,7 @@
len = 0;
} else {
/* print program name heading for grep */
- (void) snprintf(buf, sizeof(buf), "%s: ", __progname);
+ (void)snprintf(buf, sizeof(buf), "%s: ", _getprogname());
len = strlen(buf);
}
Index: libc/gen/setprogname.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/setprogname.c,v
retrieving revision 1.7
diff -u -d -r1.7 setprogname.c
--- libc/gen/setprogname.c 1 Feb 2002 00:57:29 -0000 1.7
+++ libc/gen/setprogname.c 27 Mar 2002 08:47:31 -0000
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
-extern const char *__progname;
+#include "libc_private.h"
void
setprogname(const char *progname)
Index: libc/gen/syslog.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/syslog.c,v
retrieving revision 1.25
diff -u -d -r1.25 syslog.c
--- libc/gen/syslog.c 9 Mar 2002 11:38:01 -0000 1.25
+++ libc/gen/syslog.c 27 Mar 2002 11:13:09 -0000
@@ -49,6 +49,7 @@
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -60,6 +61,8 @@
#endif
#include "un-namespace.h"
+#include "libc_private.h"
+
static int LogFile = -1; /* fd for log */
static int connected; /* have done connect */
static int opened; /* have done openlog() */
@@ -67,7 +70,6 @@
static const char *LogTag = NULL; /* string to tag the entry with */
static int LogFacility = LOG_USER; /* default facility code */
static int LogMask = 0xff; /* mask of priorities to be logged */
-extern char *__progname; /* Program name, from crt0. */
static void disconnectlog(void); /* disconnect from syslogd */
static void connectlog(void); /* (re)connect to syslogd */
@@ -181,7 +183,7 @@
stdp = tbuf + (sizeof(tbuf) - tbuf_cookie.left);
}
if (LogTag == NULL)
- LogTag = __progname;
+ LogTag = _getprogname();
if (LogTag != NULL)
(void)fprintf(fp, "%s", LogTag);
if (LogStat & LOG_PID)
Index: libc/gmon/gmon.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gmon/gmon.c,v
retrieving revision 1.13
diff -u -d -r1.13 gmon.c
--- libc/gmon/gmon.c 15 Feb 2002 02:37:08 -0000 1.13
+++ libc/gmon/gmon.c 27 Mar 2002 11:14:05 -0000
@@ -43,23 +43,22 @@
#include <sys/gmon.h>
#include <sys/sysctl.h>
-#include "namespace.h"
#include <err.h>
-#include "un-namespace.h"
-#include <stdio.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "un-namespace.h"
+#include "libc_private.h"
+
#if defined(__ELF__) && (defined(i386) || defined(__sparc64__))
extern char *minbrk asm (".minbrk");
#else
extern char *minbrk asm ("minbrk");
#endif
-extern char *__progname;
-
struct gmonparam _gmonparam = { GMON_PROF_OFF };
static int s_scale;
@@ -175,7 +174,7 @@
}
moncontrol(0);
- snprintf(outname, sizeof(outname), "%s.gmon", __progname);
+ snprintf(outname, sizeof(outname), "%s.gmon", _getprogname());
fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd < 0) {
_warn("_mcleanup: %s", outname);
Index: libc/include/libc_private.h
===================================================================
RCS file: /home/ncvs/src/lib/libc/include/libc_private.h,v
retrieving revision 1.4
diff -u -d -r1.4 libc_private.h
--- libc/include/libc_private.h 24 Jan 2001 13:00:08 -0000 1.4
+++ libc/include/libc_private.h 27 Mar 2002 11:14:18 -0000
@@ -63,4 +63,10 @@
#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
+/*
+ * This is a pointer in the C run-time startup code. It is used
+ * by getprogname() and setprogname().
+ */
+extern const char *__progname;
+
#endif /* _LIBC_PRIVATE_H_ */
Index: libc/include/namespace.h
===================================================================
RCS file: /home/ncvs/src/lib/libc/include/namespace.h,v
retrieving revision 1.8
diff -u -d -r1.8 namespace.h
--- libc/include/namespace.h 22 Mar 2002 23:41:48 -0000 1.8
+++ libc/include/namespace.h 27 Mar 2002 11:14:23 -0000
@@ -67,6 +67,7 @@
#define getdirentries _getdirentries
#define getlogin _getlogin
#define getpeername _getpeername
+#define getprogname _getprogname
#define getsockname _getsockname
#define getsockopt _getsockopt
#define ioctl _ioctl
Index: libc/include/un-namespace.h
===================================================================
RCS file: /home/ncvs/src/lib/libc/include/un-namespace.h,v
retrieving revision 1.6
diff -u -d -r1.6 un-namespace.h
--- libc/include/un-namespace.h 11 Nov 2001 02:48:09 -0000 1.6
+++ libc/include/un-namespace.h 27 Mar 2002 11:14:29 -0000
@@ -52,6 +52,7 @@
#undef getdirentries
#undef getlogin
#undef getpeername
+#undef getprogname
#undef getsockname
#undef getsockopt
#undef ioctl
Index: libc/locale/collate.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/locale/collate.c,v
retrieving revision 1.23
diff -u -d -r1.23 collate.c
--- libc/locale/collate.c 22 Mar 2002 21:52:18 -0000 1.23
+++ libc/locale/collate.c 27 Mar 2002 11:14:40 -0000
@@ -41,6 +41,8 @@
#include "collate.h"
#include "setlocale.h"
+#include "libc_private.h"
+
int __collate_load_error = 1;
int __collate_substitute_nontrivial;
char __collate_version[STR_LEN];
@@ -176,11 +178,10 @@
void
__collate_err(int ex, const char *f)
{
- extern char *__progname; /* Program name, from crt0. */
const char *s;
int serrno = errno;
- s = __progname;
+ s = _getprogname();
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, ": ", 2);
s = f;
Index: libc/stdlib/getopt.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdlib/getopt.c,v
retrieving revision 1.5
diff -u -d -r1.5 getopt.c
--- libc/stdlib/getopt.c 22 Mar 2002 21:53:10 -0000 1.5
+++ libc/stdlib/getopt.c 27 Mar 2002 11:14:49 -0000
@@ -37,9 +37,13 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/stdlib/getopt.c,v 1.5 2002/03/22 21:53:10 obrien Exp $");
+#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 @@
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 @@
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 @@
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
- __progname, optopt);
+ _getprogname(), optopt);
return (BADCH);
}
else /* white space */
Index: libc/stdlib/malloc.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/stdlib/malloc.c,v
retrieving revision 1.66
diff -u -d -r1.66 malloc.c
--- libc/stdlib/malloc.c 22 Mar 2002 21:53:10 -0000 1.66
+++ libc/stdlib/malloc.c 27 Mar 2002 11:15:33 -0000
@@ -297,14 +297,12 @@
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 @@
if (malloc_abort)
wrterror(p);
- _malloc_message(__progname, malloc_func, " warning: ", p);
+ _malloc_message(_getprogname(), malloc_func, " warning: ", p);
}
/*
Index: libc_r/uthread/uthread_spinlock.c
===================================================================
RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_spinlock.c,v
retrieving revision 1.9
diff -u -d -r1.9 uthread_spinlock.c
--- libc_r/uthread/uthread_spinlock.c 24 Jan 2001 13:03:36 -0000 1.9
+++ libc_r/uthread/uthread_spinlock.c 25 Mar 2002 19:52:44 -0000
@@ -33,14 +33,16 @@
*
*/
+#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <sched.h>
-#include <unistd.h>
#include <pthread.h>
-#include <string.h>
-#include "pthread_private.h"
+#include <unistd.h>
-extern char *__progname;
+#include <libc_private.h>
+
+#include "pthread_private.h"
/*
* Lock a location for the running thread. Yield to allow other
@@ -91,7 +93,7 @@
cnt++;
if (cnt > 100) {
char str[256];
- snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, curthread, lck, fname, lineno, lck->fname, lck->lineno);
+ snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", _getprogname(), curthread, lck, fname, lineno, lck->fname, lck->lineno);
__sys_write(2,str,strlen(str));
__sleep(1);
cnt = 0;
Index: libfetch/http.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/http.c,v
retrieving revision 1.51
diff -u -d -r1.51 http.c
--- libfetch/http.c 5 Feb 2002 22:13:51 -0000 1.51
+++ libfetch/http.c 25 Mar 2002 19:53:14 -0000
@@ -80,8 +80,6 @@
#include "common.h"
#include "httperr.h"
-extern char *__progname; /* XXX not portable */
-
/* Maximum number of redirects to follow */
#define MAX_REDIRECT 5
@@ -840,7 +838,7 @@
if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
_http_cmd(fd, "User-Agent: %s", p);
else
- _http_cmd(fd, "User-Agent: %s " _LIBFETCH_VER, __progname);
+ _http_cmd(fd, "User-Agent: %s " _LIBFETCH_VER, _getprogname());
if (url->offset)
_http_cmd(fd, "Range: bytes=%lld-", (long long)url->offset);
_http_cmd(fd, "Connection: close");
Index: libncp/ncpl_subr.c
===================================================================
RCS file: /home/ncvs/src/lib/libncp/ncpl_subr.c,v
retrieving revision 1.5
diff -u -d -r1.5 ncpl_subr.c
--- libncp/ncpl_subr.c 30 Sep 2001 22:01:19 -0000 1.5
+++ libncp/ncpl_subr.c 25 Mar 2002 19:53:32 -0000
@@ -51,8 +51,6 @@
/*#include <netncp/ncp_cfg.h>*/
#include "ncp_mod.h"
-extern char *__progname;
-
int sysentoffset;
void
@@ -309,7 +307,7 @@
++ncp_optind;
if (ncp_opterr && *ostr != ':')
(void)fprintf(stderr,
- "%s: illegal option -- %c\n", __progname, ncp_optopt);
+ "%s: illegal option -- %c\n", _getprogname(), ncp_optopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
@@ -327,7 +325,7 @@
if (ncp_opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
- __progname, ncp_optopt);
+ _getprogname(), ncp_optopt);
return (BADCH);
}
else /* white space */
@@ -439,7 +437,7 @@
ncp_error(const char *fmt, int error, ...) {
va_list ap;
- fprintf(stderr, "%s: ", __progname);
+ fprintf(stderr, "%s: ", _getprogname());
va_start(ap, error);
vfprintf(stderr, fmt, ap);
va_end(ap);
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203282029.g2SKTDdC005176>
