From: Ben Gras Date: Sun, 20 Jun 2010 00:24:35 +0000 (+0000) Subject: lib: getproname: only return last path component X-Git-Tag: v3.1.8~435 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.html?a=commitdiff_plain;h=6c0fcd575e223b5c583af8b14e0b47ac3c2cd567;p=minix.git lib: getproname: only return last path component --- diff --git a/lib/libc/other/getprogname.c b/lib/libc/other/getprogname.c index c9b52ae8c..9eed738d3 100644 --- a/lib/libc/other/getprogname.c +++ b/lib/libc/other/getprogname.c @@ -42,6 +42,7 @@ __RCSID("$NetBSD: getprogname.c,v 1.3 2003/07/26 19:24:42 salo Exp $"); #include "namespace.h" #include +#include extern const char **__prognamep; /* Copy of argv[]. */ extern int __argc; /* Copy of argc. */ @@ -49,7 +50,13 @@ extern int __argc; /* Copy of argc. */ const char * getprogname(void) { + const char *pn = NULL, *component; if(__argc > 0 && __prognamep) - return __prognamep[0]; - return NULL; + pn = __prognamep[0]; + else + return NULL; + + if((component=strrchr(pn, '/'))) + return component+1; + return pn; }