]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Fix setprogname to strip leading paths from progname
authorGuillem Jover <guillem@hadrons.org>
Sat, 30 Jan 2010 21:00:18 +0000 (22:00 +0100)
committerGuillem Jover <guillem@hadrons.org>
Sat, 30 Jan 2010 21:00:18 +0000 (22:00 +0100)
src/progname.c

index a5675c01e913c051e75348a223cf88108f56f0ab..ef56144d8ad3a4f5d398bec4b1e5a47db1a0d7b8 100644 (file)
@@ -29,6 +29,8 @@
   Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html)
 */
 
+#include <string.h>
+
 #include <bsd/stdlib.h>
 
 static const char *__progname = NULL;
@@ -40,7 +42,13 @@ getprogname(void)
 }
 
 void
-setprogname(const char *new)
+setprogname(const char *progname)
 {
-       __progname = new;
+       const char *last_slash;
+
+       last_slash = strrchr(progname, '/');
+       if (last_slash == NULL)
+               __progname = progname;
+       else
+               __progname = last_slash + 1;
 }