diff options
author | Guillem Jover <guillem@hadrons.org> | 2010-01-30 22:00:18 +0100 |
---|---|---|
committer | Guillem Jover <guillem@hadrons.org> | 2010-01-30 22:00:18 +0100 |
commit | 11f2c32df2722a758f150fb3242d208904ffdacb (patch) | |
tree | eb8961283cf5db99bc2f64ade49816d28a94545b | |
parent | 30c794083f5211ecf82f5c3614f35a16a7e4d354 (diff) | |
download | libbsd-11f2c32df2722a758f150fb3242d208904ffdacb.tar.gz |
Fix setprogname to strip leading paths from progname
-rw-r--r-- | src/progname.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/progname.c b/src/progname.c index a5675c0..ef56144 100644 --- a/src/progname.c +++ b/src/progname.c @@ -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; } |