[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch for bool portability issues in Bison
From: |
Paul Eggert |
Subject: |
patch for bool portability issues in Bison |
Date: |
Fri, 3 Jan 2003 06:34:24 -0800 (PST) |
I installed this:
2003-01-03 Paul Eggert <address@hidden>
* lib/hash.c (_Bool, bool, false, true, __bool_true_false_are_defined):
Use the pattern recommended by Autoconf 2.57, except also protect
against double-definition.
* src/system.h: Likewise.
* data/glr.c (yybool): Renamed from bool, to avoid collisions in C.
All uses changed. Provide a definition in both C and C++.
(yytrue, yyfalse): Define even if defined (__cplusplus).
--- lib/hash.c 28 Nov 2002 00:42:28 -0000 1.9
+++ lib/hash.c 3 Jan 2003 14:14:24 -0000 1.10
@@ -1,5 +1,8 @@
/* hash - hashing table processing.
- Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+ Foundation, Inc.
+
Written by Jim Meyering, 1992.
This program is free software; you can redistribute it and/or modify
@@ -27,11 +30,25 @@
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
+
#if HAVE_STDBOOL_H
# include <stdbool.h>
#else
-typedef enum {false = 0, true = 1} bool;
+# ifndef __bool_true_false_are_defined
+# if ! HAVE__BOOL
+# ifdef __cplusplus
+typedef bool _Bool;
+# else
+typedef unsigned char _Bool;
+# endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+# endif
#endif
+
#include <stdio.h>
#ifndef HAVE_DECL_FREE
--- src/system.h 13 Dec 2002 08:44:28 -0000 1.58
+++ src/system.h 3 Jan 2003 14:15:16 -0000 1.59
@@ -1,5 +1,6 @@
/* System-dependent definitions for Bison.
- Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
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
@@ -185,7 +186,19 @@ void *memrchr (const void *s, int c, siz
#if HAVE_STDBOOL_H
# include <stdbool.h>
#else
-typedef enum {false = 0, true = 1} bool;
+# ifndef __bool_true_false_are_defined
+# if ! HAVE__BOOL
+# ifdef __cplusplus
+typedef bool _Bool;
+# else
+typedef unsigned char _Bool;
+# endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+# endif
#endif
--- data/glr.c 26 Dec 2002 08:27:09 -0000 1.47
+++ data/glr.c 3 Jan 2003 14:32:35 -0000 1.49
@@ -1,7 +1,7 @@
m4_divert(-1) -*- C -*-
# GLR skeleton for Bison
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
# 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
@@ -138,7 +138,7 @@ m4_define([b4_rhs_location],
m4_changecom()
m4_divert(0)dnl
@output @output_parser_name@
-b4_copyright([Skeleton parser for GLR parsing with Bison], [2002])
+b4_copyright([Skeleton parser for GLR parsing with Bison], [2002, 2003])
[
/* This is the parser code for GLR (Generalized LR) parser. */
@@ -216,11 +216,13 @@ static YYLTYPE yyloc_default;
]/* Line __line__ of glr.c. */
b4_syncline(address@hidden@], address@hidden@])
[
-#if ! defined (__cplusplus)
- typedef char bool;
-# define yytrue 1
-# define yyfalse 0
+#ifdef __cplusplus
+ typedef bool yybool;
+#else
+ typedef unsigned char yybool;
#endif
+#define yytrue 1
+#define yyfalse 0
/*-----------------.
| GCC extensions. |
@@ -536,8 +538,8 @@ typedef struct yyGLRStack yyGLRStack;
typedef struct yyGLRStateSet yyGLRStateSet;
struct yyGLRState {
- bool yyisState;
- bool yyresolved;
+ yybool yyisState;
+ yybool yyresolved;
yyStateNum yylrState;
yyGLRState* yypred;
size_t yyposn;
@@ -554,7 +556,7 @@ struct yyGLRStateSet {
};
struct yySemanticOption {
- bool yyisState;
+ yybool yyisState;
yyRuleNum yyrule;
yyGLRState* yystate;
yySemanticOption* yynext;
@@ -713,7 +715,7 @@ yylhsNonterm (yyRuleNum yyrule)
/** True iff LR state STATE has only a default reduction (regardless
* of token). */
-static inline bool
+static inline yybool
yyisDefaultedState (yyStateNum yystate)
{
return yyis_pact_ninf (yypact[yystate]);
@@ -772,13 +774,13 @@ yyLRgotoState (yyStateNum yystate, yySym
return yydefgoto[yylhs - YYNTOKENS];
}
-static inline bool
+static inline yybool
yyisShiftAction (int yyaction)
{
return 0 < yyaction;
}
-static inline bool
+static inline yybool
yyisErrorAction (int yyaction)
{
return yyaction == 0;
@@ -864,7 +866,7 @@ yyexpandGLRStack (yyGLRStack* yystack]b4
yyn -= 1, yyp0 += 1, yyp1 += 1)
{
*yyp1 = *yyp0;
- if (*(bool*) yyp0)
+ if (*(yybool *) yyp0)
{
yyGLRState* yys0 = &yyp0->yystate;
yyGLRState* yys1 = &yyp1->yystate;
@@ -1123,7 +1125,7 @@ yy_reduce_print (size_t yyk, yyRuleNum y
*/
static inline YYRESULTTAG
yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
- bool yyforceEval]b4_pure_formals[)
+ yybool yyforceEval]b4_pure_formals[)
{
size_t yyposn = yystack->yytops.yystates[yyk]->yyposn;
@@ -1209,7 +1211,7 @@ yysplitStack (yyGLRStack* yystack, int y
/** True iff Y0 and Y1 represent identical options at the top level.
* That is, they represent the same rule applied to RHS symbols
* that produce the same terminal symbols. */
-static bool
+static yybool
yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
{
if (yyy0->yyrule == yyy1->yyrule)
@@ -1918,7 +1920,7 @@ yypdumpstack (yyGLRStack* yystack)
for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
{
fprintf (stderr, "%3lu. ", (unsigned long) (yyp - yystack->yyitems));
- if (*(bool*) yyp)
+ if (*(yybool *) yyp)
{
fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
yyp->yystate.yyresolved, yyp->yystate.yylrState,
@@ -1948,7 +1950,7 @@ yypdumpstack (yyGLRStack* yystack)
b4_epilogue
m4_if(b4_defines_flag, 0, [],
address@hidden @output_header_name@
-b4_copyright([Skeleton parser for GLR parsing with Bison], [2002])
+b4_copyright([Skeleton parser for GLR parsing with Bison], [2002, 2003])
b4_token_defines(b4_tokens)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- patch for bool portability issues in Bison,
Paul Eggert <=