Fix infringement on user name space reported by Bruno Haible.

* data/yacc.c (YYSIZE_T): Define first, so that later decls can use it.
Prefer GCC's __SIZE_TYPE__ if available, so that we don't infringe on
the user's name space.
(alloca): Include <stdlib.h> to get it, if it's not built in.
(YYMALLOC, YYFREE): Define only if needed.
(malloc, free): Declare, but only if needed, as this infringes on
the user name space.
This commit is contained in:
Paul Eggert
2005-05-27 23:22:10 +00:00
parent 4d1801f1a8
commit bedf57f515
2 changed files with 43 additions and 29 deletions

View File

@@ -1,3 +1,14 @@
2005-05-27 Paul Eggert <eggert@cs.ucla.edu>
Fix infringement on user name space reported by Bruno Haible.
* data/yacc.c (YYSIZE_T): Define first, so that later decls can use it.
Prefer GCC's __SIZE_TYPE__ if available, so that we don't infringe on
the user's name space.
(alloca): Include <stdlib.h> to get it, if it's not built in.
(YYMALLOC, YYFREE): Define only if needed.
(malloc, free): Declare, but only if needed, as this infringes on
the user name space.
2005-05-25 Paul Eggert <eggert@cs.ucla.edu> 2005-05-25 Paul Eggert <eggert@cs.ucla.edu>
Fix BeOS, FreeBSD, MacOS porting problems reported by Bruno Haible. Fix BeOS, FreeBSD, MacOS porting problems reported by Bruno Haible.

View File

@@ -214,14 +214,21 @@ typedef struct YYLTYPE
/* Line __line__ of yacc.c. */ /* Line __line__ of yacc.c. */
b4_syncline([@oline@], [@ofile@])[ b4_syncline([@oline@], [@ofile@])[
#if ! defined (yyoverflow) || YYERROR_VERBOSE #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
# ifndef YYFREE #if ! defined (yyoverflow) || YYERROR_VERBOSE
# define YYFREE free
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# endif
/* The parser invokes alloca or malloc; define the necessary symbols. */ /* The parser invokes alloca or malloc; define the necessary symbols. */
@@ -231,6 +238,10 @@ b4_syncline([@oline@], [@ofile@])[
# define YYSTACK_ALLOC __builtin_alloca # define YYSTACK_ALLOC __builtin_alloca
# else # else
# define YYSTACK_ALLOC alloca # define YYSTACK_ALLOC alloca
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYINCLUDED_STDLIB_H
# endif
# endif # endif
# endif # endif
# endif # endif
@@ -246,17 +257,25 @@ b4_syncline([@oline@], [@ofile@])[
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
# endif # endif
# else # else
# if defined (__STDC__) || defined (__cplusplus)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned long int
# endif
# define YYSTACK_ALLOC YYMALLOC # define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE # define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM # ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
# endif # endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
&& (defined (__STDC__) || defined (__cplusplus)))
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
&& (defined (__STDC__) || defined (__cplusplus)))
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif # endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
@@ -463,22 +482,6 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
]b4_stos[ ]b4_stos[
}; };
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif
#define yyerrok (yyerrstatus = 0) #define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY) #define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2) #define YYEMPTY (-2)