This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Portability fix for argp/argp.h.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Simon Josefsson wrote:
> @@ -1812,14 +1847,22 @@ __argp_failure (const struct argp_state
>
> #ifdef USE_IN_LIBIO
> if (_IO_fwide (stream, 0) > 0)
> +#if defined _LIBC || defined HAVE_STRERROR_R
> __fwprintf (stream, L": %s",
> __strerror_r (errnum, buf, sizeof (buf)));
> +#else
> + __fwprintf (stream, L": %s", strerror (errnum));
> +#endif
> else
> #endif
> {
> putc_unlocked (':', stream);
> putc_unlocked (' ', stream);
> +#if defined _LIBC || defined HAVE_STRERROR_R
> fputs (__strerror_r (errnum, buf, sizeof (buf)), stream);
> +#else
> + fputs (strerror (errnum), stream);
> +#endif
I don't think half of this patch is needed. USE_IN_LIBIO is defined
only inside libc. We need no #ifs for HAVE_STRERROR_R in that branch.
> +#ifdef __LIBC
> + state->name = basename (arg);
> +#else
> + state->name = __argp_basename (arg);
> +#endif
> +
> +#if 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 +604,7 @@ parser_init (struct parser *parser, cons
> 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 (NULL);
>
> return 0;
You cannot remove program_invocation_short_name for _LIBC. This
variable is part of the libc ABI. After your change it seems not to be
initialized anymore. And in any case, since it is a separate variable
it might get a value other than basename(program_invocation_name)
assigned at any time. You cannot mess with it.
I.e., leave the code as is for libc. If necessary, add wrappers for
other uses although I still don't understand why it is needed.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/PF3+2ijCOnn/RHQRAvUCAKCbeqtqrfdWweO1x18y9L3us726jACeKfby
NVByiLONFiYYdXNaodKa9H0=
=3zVD
-----END PGP SIGNATURE-----