From c21493b89f5f5dd49e1f46d311326d5d4f49f8a4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 20 Jan 2006 01:59:30 +0000 Subject: [PATCH] Fix some porting glitches found by Nelson H. F. Beebe. * lib/abitset.c (abitset_resize): Rewrite to avoid warnings from compilers that don't understand that abort () does not return. * src/state.c (transitions_to): Likewise. * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Check that '#include ' works. * src/system.h (INT8_MIN, INT16_MIN, INT32_MIN, INT8_MAX): (INT16_MAX, UINT8_MAX, INT32_MAX, UINT16_MAX, UINT32_MAX): #undef if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901, for the benefit of some pre-C99 compilers. --- ChangeLog | 11 +++++++++++ lib/abitset.c | 10 +++++----- m4/cxx.m4 | 7 ++++--- src/state.c | 14 +++++++++----- src/system.h | 20 ++++++++++++++++++-- 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25a7cdba..28a4198b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2006-01-19 Paul Eggert + Fix some porting glitches found by Nelson H. F. Beebe. + * lib/abitset.c (abitset_resize): Rewrite to avoid warnings from + compilers that don't understand that abort () does not return. + * src/state.c (transitions_to): Likewise. + * m4/cxx.m4 (BISON_TEST_FOR_WORKING_CXX_COMPILER): Check + that '#include ' works. + * src/system.h (INT8_MIN, INT16_MIN, INT32_MIN, INT8_MAX): + (INT16_MAX, UINT8_MAX, INT32_MAX, UINT16_MAX, UINT32_MAX): + #undef if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901, + for the benefit of some pre-C99 compilers. + * bootstrap: Undo changes to gnulib files that autoreconf made. Minor fixups to get 'make maintainer-check' to work. diff --git a/lib/abitset.c b/lib/abitset.c index ec5bf6a0..c573f34a 100644 --- a/lib/abitset.c +++ b/lib/abitset.c @@ -1,5 +1,5 @@ /* Array bitsets. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz). This program is free software; you can redistribute it and/or modify @@ -37,11 +37,11 @@ static bitset_bindex abitset_resize (bitset src ATTRIBUTE_UNUSED, bitset_bindex size ATTRIBUTE_UNUSED) { - if (BITSET_SIZE_ (src) == size) - return size; - /* These bitsets have a fixed size. */ - abort (); + if (BITSET_SIZE_ (src) != size) + abort (); + + return size; } /* Find list of up to NUM bits set in BSET starting from and including diff --git a/m4/cxx.m4 b/m4/cxx.m4 index 71bf8f96..695476d1 100644 --- a/m4/cxx.m4 +++ b/m4/cxx.m4 @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Sanity-test a C++ compiler. # -# Copyright (C) 2004 Free Software Foundation, Inc. +# Copyright (C) 2004, 2006 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 @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 USA -# Written by Paul Eggert . +# Written by Paul Eggert. AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER], [ @@ -27,7 +27,8 @@ AC_DEFUN([BISON_TEST_FOR_WORKING_CXX_COMPILER], [AC_LANG_PUSH([C++]) AC_RUN_IFELSE( [AC_LANG_PROGRAM( - [#include + [#include + #include using namespace std;], [std::cerr << ""; cout << "";])], diff --git a/src/state.c b/src/state.c index d7289a3b..83e0108f 100644 --- a/src/state.c +++ b/src/state.c @@ -1,6 +1,7 @@ /* Type definitions for nondeterministic finite state machine for Bison. - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -58,10 +59,13 @@ state * transitions_to (transitions *shifts, symbol_number sym) { int j; - for (j = 0; j < shifts->num; j++) - if (TRANSITION_SYMBOL (shifts, j) == sym) - return shifts->states[j]; - abort (); + for (j = 0; ; j++) + { + if (shifts->num <= j) + abort (); + if (TRANSITION_SYMBOL (shifts, j) == sym) + return shifts->states[j]; + } } diff --git a/src/system.h b/src/system.h index 74639ec5..c1c45b49 100644 --- a/src/system.h +++ b/src/system.h @@ -1,7 +1,7 @@ /* System-dependent definitions for Bison. - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software - Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 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 @@ -20,6 +20,22 @@ #ifndef BISON_SYSTEM_H #define BISON_SYSTEM_H +/* flex 2.5.31 gratutiously defines macros like INT8_MIN. But this + runs afoul of pre-C99 compilers that have or + , which are included below if available. It also runs + afoul of pre-C99 compilers that define these macros in . */ +#if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901 +# undef INT8_MIN +# undef INT16_MIN +# undef INT32_MIN +# undef INT8_MAX +# undef INT16_MAX +# undef UINT8_MAX +# undef INT32_MAX +# undef UINT16_MAX +# undef UINT32_MAX +#endif + #include #include #include -- 2.45.2