mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-22 16:02:32 +02:00
Fix setprogname to strip leading paths from progname
This commit is contained in:
@@ -29,6 +29,8 @@
|
|||||||
Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html)
|
Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <bsd/stdlib.h>
|
#include <bsd/stdlib.h>
|
||||||
|
|
||||||
static const char *__progname = NULL;
|
static const char *__progname = NULL;
|
||||||
@@ -40,7 +42,13 @@ getprogname(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user