Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tools/compat - act more like lib/libc/gen/setprogname.c, and...



details:   https://anonhg.NetBSD.org/src/rev/316d3d6354f0
branches:  trunk
changeset: 520423:316d3d6354f0
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Jan 10 05:35:42 2002 +0000

description:
- act more like lib/libc/gen/setprogname.c, and store the basename of
  the argument to setprogname()
- knf

diffstat:

 tools/compat/setprogname.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r f529436f6818 -r 316d3d6354f0 tools/compat/setprogname.c
--- a/tools/compat/setprogname.c        Thu Jan 10 05:31:07 2002 +0000
+++ b/tools/compat/setprogname.c        Thu Jan 10 05:35:42 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setprogname.c,v 1.1 2001/12/11 21:18:00 tv Exp $       */
+/*     $NetBSD: setprogname.c,v 1.2 2002/01/10 05:35:42 lukem Exp $    */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -41,13 +41,23 @@
 #endif
 
 #ifndef HAVE_SETPROGNAME
+#include <string.h>
+
 static const char *__progname;
 
-void setprogname(const char *progname) {
-       __progname = progname;
+void
+setprogname(const char *progname)
+{
+       __progname = strrchr(progname, '/');
+       if (__progname == NULL)
+               __progname = progname;
+       else
+               __progname++;
 }
 
-const char *getprogname(void) {
+const char *
+getprogname(void)
+{
        return __progname;
 }
 #endif



Home | Main Index | Thread Index | Old Index