From 77348673a683dc1d16a3f46a0c6600df4fe544f3 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Fri, 22 Aug 2003 18:15:22 +0000 Subject: [PATCH] libc sync --- gl/argp-fmtstream.h | 25 +++++++++--------- gl/argp-help.c | 74 ++++++++++++++++++++++------------------------------- 2 files changed, 43 insertions(+), 56 deletions(-) diff --git a/gl/argp-fmtstream.h b/gl/argp-fmtstream.h index 1b48d220..5d0d5eac 100644 --- a/gl/argp-fmtstream.h +++ b/gl/argp-fmtstream.h @@ -3,19 +3,20 @@ This file is part of the GNU C Library. Written by Miles Bader . - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ /* This package emulates glibc `line_wrap_stream' semantics for systems that don't have that. If the system does have it, it is just a wrapper for @@ -35,12 +36,12 @@ #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ # define __attribute__(Spec) /* empty */ # endif /* The __-protected variants of `format' and `printf' attributes are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || __STRICT_ANSI__ # define __format__ format # define __printf__ printf # endif diff --git a/gl/argp-help.c b/gl/argp-help.c index 42e4e4a2..b8b31e16 100644 --- a/gl/argp-help.c +++ b/gl/argp-help.c @@ -3,19 +3,20 @@ This file is part of the GNU C Library. Written by Miles Bader . - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 @@ -68,14 +69,14 @@ char *alloca (); # endif #endif -#ifndef __attribute -# define __attribute(xyz) /* Ignore */ -#endif - #ifndef _LIBC # if !HAVE_DECL_STRERROR -char *strerror (); +char *strerror (int errnum); +# endif +# if !HAVE_DECL_STRERROR_R +char *strerror_r (int errnum, char *buf, size_t buflen); # endif +# define __strerror_r strerror_r #endif #include "argp.h" @@ -555,7 +556,7 @@ hol_entry_short_iterate (const struct hol_entry *entry, } static inline int -__attribute ((always_inline)) +__attribute__ ((always_inline)) hol_entry_long_iterate (const struct hol_entry *entry, int (*func)(const struct argp_option *opt, const struct argp_option *real, @@ -1662,9 +1663,6 @@ Try `%s --help' or `%s --usage' for more information.\n"), __argp_fmtstream_free (fs); } -#ifndef weak_alias -# define __argp_help argp_help -#endif /* Output a usage message for ARGP to STREAM. FLAGS are from the set ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */ void __argp_help (const struct argp *argp, FILE *stream, @@ -1676,21 +1674,21 @@ void __argp_help (const struct argp *argp, FILE *stream, weak_alias (__argp_help, argp_help) #endif -char *__argp_basename(char *name) +#ifndef _LIBC +char *__argp_basename (char *name) { - char *short_name = strrchr(name, '/'); + char *short_name = strrchr (name, '/'); return short_name ? short_name + 1 : name; } +#endif char * -__argp_short_program_name(const struct argp_state *state) +__argp_short_program_name (void) { - if (state) - return state->name; #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME || defined _LIBC return program_invocation_short_name; #elif HAVE_DECL_PROGRAM_INVOCATION_NAME - return __argp_basename(program_invocation_name); + return __argp_basename (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, @@ -1702,9 +1700,6 @@ __argp_short_program_name(const struct argp_state *state) #endif } -#ifndef weak_alias -# define __argp_state_help argp_state_help -#endif /* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are from the set ARGP_HELP_*. */ void @@ -1716,7 +1711,7 @@ __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags) flags |= ARGP_HELP_LONG_ONLY; _help (state ? state->root_argp : 0, state, stream, flags, - state ? state->name : __argp_short_program_name (state)); + state ? state->name : __argp_short_program_name ()); if (!state || ! (state->flags & ARGP_NO_EXIT)) { @@ -1731,9 +1726,6 @@ __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags) weak_alias (__argp_state_help, argp_state_help) #endif -#ifndef weak_alias -# define __argp_error argp_error -#endif /* If appropriate, print the printf string FMT and following args, preceded by the program name and `:', to stderr, and followed by a `Try ... --help' message, then exit (1). */ @@ -1760,8 +1752,7 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) __asprintf (&buf, fmt, ap); __fwprintf (stream, L"%s: %s\n", - state ? state->name : - __argp_short_program_name (state), + state ? state->name : __argp_short_program_name (), buf); free (buf); @@ -1770,8 +1761,7 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) #endif { fputs_unlocked (state - ? state->name : - __argp_short_program_name (state), + ? state->name : __argp_short_program_name (), stream); putc_unlocked (':', stream); putc_unlocked (' ', stream); @@ -1793,9 +1783,6 @@ __argp_error (const struct argp_state *state, const char *fmt, ...) weak_alias (__argp_error, argp_error) #endif -#ifndef weak_alias -# define __argp_failure argp_failure -#endif /* Similar to the standard gnu error-reporting function error(), but will respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print to STATE->err_stream. This is useful for argument parsing code that is @@ -1819,12 +1806,11 @@ __argp_failure (const struct argp_state *state, int status, int errnum, #ifdef USE_IN_LIBIO if (_IO_fwide (stream, 0) > 0) __fwprintf (stream, L"%s", - state ? state->name : - __argp_short_program_name (state)); + state ? state->name : __argp_short_program_name ()); else #endif fputs_unlocked (state - ? state->name : __argp_short_program_name (state), + ? state->name : __argp_short_program_name (), stream); if (fmt) @@ -1861,7 +1847,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum, #ifdef USE_IN_LIBIO if (_IO_fwide (stream, 0) > 0) -#if defined _LIBC +#if defined _LIBC || defined HAVE_STRERROR_R __fwprintf (stream, L": %s", __strerror_r (errnum, buf, sizeof (buf))); #else @@ -1872,7 +1858,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum, { putc_unlocked (':', stream); putc_unlocked (' ', stream); -#if defined _LIBC +#if defined _LIBC || defined HAVE_STRERROR_R fputs (__strerror_r (errnum, buf, sizeof (buf)), stream); #else fputs (strerror (errnum), stream); -- 2.11.4.GIT