This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: solaris forte 7 cc argp fixes


Sorry for the bother, but has anyone taken a look at the patch below?

Thanks,
Simon

Simon Josefsson <jas@extundo.com> writes:

> I doubt the old alloca check in argp-help.c was ever used outside
> libc, since argp-parse.c also uses alloca and didn't contain the
> check.  This patch add the code snippet from the Autoconf 2.57 manual
> to argp-parse.c and changes the one in argp-help.c, see discussion in
> <http://mail.gnu.org/archive/html/bug-gnulib/2003-06/msg00044.html>.
> Secondly, argp.h uses __restrict, so I copied the CPP block from
> regex.h to take care of that.  Finally, a few header files from gnulib
> need to be included for argp to build standalone properly.
>
> Phew.  Making argp work portably was more work than I expected.
>
> Thanks.
>
> 2003-10-10  Simon Josefsson  <jas@extundo.com>
>
> 	* argp/argp-namefrob.h [!_LIBC]: Include mempcpy.h, strcase.h,
> 	strchrnul.h, strndup.h (from gnulib).
> 	* argp/argp-parse.c: Add alloca.h include snippet verbatim from
> 	Autoconf manual.
> 	* argp/argp-help.c: Replace alloca.h include snipper with verbatim
> 	Autoconf manual version.
> 	* argp/argp.h: Map __restrict to restrict or empty string when
> 	necessary, copied verbatim from posix/regex.h.
>
> Index: argp-help.c
> ===================================================================
> RCS file: /cvs/glibc/libc/argp/argp-help.c,v
> retrieving revision 1.40
> diff -u -p -r1.40 argp-help.c
> --- argp-help.c	3 Oct 2003 00:44:39 -0000	1.40
> +++ argp-help.c	10 Oct 2003 18:24:52 -0000
> @@ -26,20 +26,16 @@
>  #include <config.h>
>  #endif
>  
> -#ifndef alloca
> -# ifdef __GNUC__
> -#  define alloca __builtin_alloca
> -#  define HAVE_ALLOCA 1
> +/* AIX requires this to be the first thing in the file.  */
> +#ifndef __GNUC__
> +# if HAVE_ALLOCA_H || defined _LIBC
> +#  include <alloca.h>
>  # else
> -#  if defined HAVE_ALLOCA_H || defined _LIBC
> -#   include <alloca.h>
> +#  ifdef _AIX
> +#pragma alloca
>  #  else
> -#   ifdef _AIX
> - #pragma alloca
> -#   else
> -#    ifndef alloca
> +#   ifndef alloca /* predefined by HP cc +Olibcalls */
>  char *alloca ();
> -#    endif
>  #   endif
>  #  endif
>  # endif
> Index: argp-namefrob.h
> ===================================================================
> RCS file: /cvs/glibc/libc/argp/argp-namefrob.h,v
> retrieving revision 1.5
> diff -u -p -r1.5 argp-namefrob.h
> --- argp-namefrob.h	3 Oct 2003 00:44:39 -0000	1.5
> +++ argp-namefrob.h	10 Oct 2003 18:24:52 -0000
> @@ -77,6 +77,11 @@
>  #undef __argp_fmtstream_wmargin
>  #define __argp_fmtstream_wmargin argp_fmtstream_wmargin
>  
> +#include "mempcpy.h"
> +#include "strcase.h"
> +#include "strchrnul.h"
> +#include "strndup.h"
> +
>  /* normal libc functions we call */
>  #undef __flockfile
>  #define __flockfile flockfile
> Index: argp-parse.c
> ===================================================================
> RCS file: /cvs/glibc/libc/argp/argp-parse.c,v
> retrieving revision 1.18
> diff -u -p -r1.18 argp-parse.c
> --- argp-parse.c	2 Oct 2003 22:53:45 -0000	1.18
> +++ argp-parse.c	10 Oct 2003 18:24:52 -0000
> @@ -1,5 +1,5 @@
>  /* Hierarchial argument parsing, layered over getopt
> -   Copyright (C) 1995-2000, 2002 Free Software Foundation, Inc.
> +   Copyright (C) 1995-2000, 2002, 2003 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>     Written by Miles Bader <miles@gnu.ai.mit.edu>.
>  
> @@ -20,6 +20,21 @@
>  
>  #ifdef HAVE_CONFIG_H
>  #include <config.h>
> +#endif
> +
> +/* AIX requires this to be the first thing in the file.  */
> +#ifndef __GNUC__
> +# if HAVE_ALLOCA_H || defined _LIBC
> +#  include <alloca.h>
> +# else
> +#  ifdef _AIX
> +#pragma alloca
> +#  else
> +#   ifndef alloca /* predefined by HP cc +Olibcalls */
> +char *alloca ();
> +#   endif
> +#  endif
> +# endif
>  #endif
>  
>  #include <stdlib.h>
> Index: argp.h
> ===================================================================
> RCS file: /cvs/glibc/libc/argp/argp.h,v
> retrieving revision 1.28
> diff -u -p -r1.28 argp.h
> --- argp.h	2 Oct 2003 22:54:33 -0000	1.28
> +++ argp.h	10 Oct 2003 18:24:52 -0000
> @@ -49,6 +49,18 @@
>  # endif
>  #endif
>  
> +/* GCC 2.95 and later have "__restrict"; C99 compilers have
> +   "restrict", and "configure" may have defined "restrict".  */
> +#ifndef __restrict
> +# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
> +#  if defined restrict || 199901L <= __STDC_VERSION__
> +#   define __restrict restrict
> +#  else
> +#   define __restrict
> +#  endif
> +# endif
> +#endif
> +
>  #ifndef __error_t_defined
>  typedef int error_t;
>  # define __error_t_defined


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]