From: Sergey Poznyakoff Date: Fri, 9 Dec 2005 12:28:58 +0000 (+0000) Subject: (__argp_base_name): New function X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0da836338cf9d8c10da7d0b9825bcbceeff57090;p=pspp (__argp_base_name): New function (__argp_short_program_name): Rewrite using __argp_base_name --- diff --git a/lib/argp-help.c b/lib/argp-help.c index 74c8fd8624..7af716c786 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -50,6 +50,7 @@ #include "argp.h" #include "argp-fmtstream.h" #include "argp-namefrob.h" +#include "dirname.h" #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) @@ -1678,13 +1679,21 @@ void __argp_help (const struct argp *argp, FILE *stream, weak_alias (__argp_help, argp_help) #endif +char * +__argp_base_name (char *name) +{ + char *p; + for (p = name + strlen (name); p > name && !ISSLASH (p[-1]); p--) + ; + return p; +} + #if ! (defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME) char * __argp_short_program_name (void) { # if HAVE_DECL_PROGRAM_INVOCATION_NAME - char *name = strrchr (program_invocation_name, '/'); - return name ? name + 1 : program_invocation_name; + return __argp_base_name (program_invocation_name); # else /* FIXME: What now? Miles suggests that it is better to use NULL, but currently the value is passed on directly to fputs_unlocked,