aboutsummaryrefslogtreecommitdiff
path: root/argp/argp-parse.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-10-02 22:55:10 +0000
committerUlrich Drepper <drepper@redhat.com>2003-10-02 22:55:10 +0000
commitf39941e4127085f2120e40ffefc287f8c4a9548a (patch)
treef0573c549da40417a8113d097adc062ad9c483da /argp/argp-parse.c
parent134abcb5b9ba854fec25051cd3c9f88e760913c5 (diff)
downloadglibc-f39941e4127085f2120e40ffefc287f8c4a9548a.tar
glibc-f39941e4127085f2120e40ffefc287f8c4a9548a.tar.gz
glibc-f39941e4127085f2120e40ffefc287f8c4a9548a.tar.bz2
glibc-f39941e4127085f2120e40ffefc287f8c4a9548a.zip
Update.
2003-08-22 Simon Josefsson <jas@extundo.com> * argp/argp-fmtstream.h [!__attribute__]: Define to nothing. * argp/argp-help.c: Don't include malloc.h, some platforms complain and it doesn't appear to be used. [!_LIBC && HAVE_STRERROR_R && !HAVE_DECL_STRERROR_R]: Declare strerror_r. [!_LIBC && !HAVE_STRERROR_R && !HAVE_DECL_STRERROR]: Declare strerror. (hol_entry_long_iterate): Change __attribute to __attribute__. (_help, __argp_error, __argp_failure) [!_LIBC && (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)]: Protect call to flockfile and funlockfile. (__argp_basename) [!_LIBC]: New. Taken from LSH, by Niels Möller, modifed after comments from Ulrich Drepper. (__argp_short_program_name): Ditto. (__argp_state_help, __argp_error, __argp_failure): Use it. (__argp_failure): Use strerror when necessary. * argp/argp-namefrob.h (__flockfile, __funlockfile, __mempcpy) (__strchrnul, __strerror_r, __strndup) [!_LIBC]: Remove __-prefix. (clearerr_unlocked, feof_unlocked, ferror_unlocked) (fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked) (fread_unlocked, fwrite_unlocked, getc_unlocked, getchar_unlocked) (putc_unlocked, putchar_unlocked) [!_LIBC && !HAVE_DECL_*]: Map to non-unlocked functions. [!_LIBC]: Add prototypes for __argp_basename and __argp_short_program_name. * argp/argp-parse.c (argp_default_parser): Only use program_invocation{_short,}_name if declared. (parser_init): Use __argp_short_program_name. * argp/argp-xinl.c [_LIBC || HAVE_FEATURES_H]: Add CPP check for '#include features.h'. * argp/argp.h [!__attribute__]: Define to nothing.
Diffstat (limited to 'argp/argp-parse.c')
-rw-r--r--argp/argp-parse.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index 6d5f08cf83..0b619db0f3 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -119,24 +119,28 @@ argp_default_parser (int key, char *arg, struct argp_state *state)
break;
case OPT_PROGNAME: /* Set the program name. */
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = arg;
-
+#endif
/* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
__PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
to be that, so we have to be a bit careful here.] */
- arg = strrchr (arg, '/');
- if (arg)
- program_invocation_short_name = arg + 1;
- else
- program_invocation_short_name = program_invocation_name;
/* Update what we use for messages. */
- state->name = program_invocation_short_name;
+ state->name = strrchr (arg, '/');
+ if (state->name)
+ state->name++;
+ else
+ state->name = arg;
+
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = state->name;
+#endif
if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
== ARGP_PARSE_ARGV0)
/* Update what getopt uses too. */
- state->argv[0] = program_invocation_name;
+ state->argv[0] = arg;
break;
@@ -599,7 +603,7 @@ parser_init (struct parser *parser, const struct argp *argp,
parser->state.name = short_name ? short_name + 1 : argv[0];
}
else
- parser->state.name = program_invocation_short_name;
+ parser->state.name = __argp_short_program_name ();
return 0;
}