m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: 47-gary-use-c99-bool-from-gnulib.patch


From: Gary V. Vaughan
Subject: FYI: 47-gary-use-c99-bool-from-gnulib.patch
Date: Fri, 29 Aug 2003 18:02:45 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030804

Applied to HEAD.
--
  ())_.  Gary V. Vaughan    gary@(oranda.demon.co.uk|gnu.org)
  ( '/   Research Scientist http://www.oranda.demon.co.uk       ,_())____
  / )=   GNU Hacker         http://www.gnu.org/software/libtool  \'      `&
`(_~)_   Tech' Author       http://sources.redhat.com/autobook   =`---d__/
Index: ChangeLog
from  Gary V. Vaughan  <address@hidden>

        * m4/stdbool_.h: New file from gnulib for systems without their
        own.
        * m4/Makefile.am: Add snippets from gnulib for C99 bool support.
        * config/stdbool.m4: New file.  Macros from gnulib for same.
        * configure.ac: Use it.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/Makefile.am,v
retrieving revision 1.10
diff -u -p -u -r1.10 Makefile.am
--- Makefile.am 4 Nov 2002 16:31:04 -0000 1.10
+++ Makefile.am 29 Aug 2003 16:55:20 -0000
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-## Copyright 2000 Free Software Foundation
+## Copyright (C) 2000 Free Software Foundation
 ##
 ## 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
Index: configure.ac
===================================================================
RCS file: /cvsroot/m4/m4/configure.ac,v
retrieving revision 1.11
diff -u -p -u -r1.11 configure.ac
--- configure.ac 27 Aug 2003 14:06:52 -0000 1.11
+++ configure.ac 29 Aug 2003 16:55:20 -0000
@@ -16,12 +16,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 # 02111-1307  USA
 
-## -------------------------- ##
-## We need a modern Autotest. ##
-## -------------------------- ##
-AC_PREREQ([2.55])
-
-
 
 ## ------------------------ ##
 ## Autoconf initialisation. ##
@@ -158,13 +152,13 @@ AC_PROG_AWK
 ## C headers required by M4. ##
 ## ------------------------- ##
 AC_HEADER_STDC
-AC_HEADER_STDBOOL
+AM_STDBOOL_H
 AC_CHECK_HEADERS(limits.h locale.h memory.h string.h unistd.h errno.h)
 
 if test $ac_cv_header_stdbool_h = yes; then
   INCLUDE_STDBOOL_H='#include <stdbool.h>'
 else
-  INCLUDE_STDBOOL_H='typedef enum {false = 0, true = 1} bool'
+  INCLUDE_STDBOOL_H='#include <m4/stdbool.h>'
 fi
 AC_SUBST([INCLUDE_STDBOOL_H])
 
Index: config/gnu-obstack.m4
===================================================================
RCS file: /cvsroot/m4/m4/config/gnu-obstack.m4,v
retrieving revision 1.13
diff -u -p -u -r1.13 gnu-obstack.m4
--- config/gnu-obstack.m4 27 Aug 2003 17:10:12 -0000 1.13
+++ config/gnu-obstack.m4 29 Aug 2003 16:55:20 -0000
@@ -31,7 +31,7 @@ m4_pattern_allow([^m4_obstack_h$])dnl
 
 AC_ARG_WITH([included-obstack],
     [AC_HELP_STRING([--with-included-obstack],
-                    [use the obstack imlementation included here])])
+                    [use the obstack implementation included here])])
 
 if test "x${with_included_obstack-no}" = xno; then
   AC_CACHE_CHECK([for obstack in libc], m4_cv_func_obstack,
Index: config/stdbool.m4
===================================================================
RCS file: config/stdbool.m4
diff -N config/stdbool.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ config/stdbool.m4 29 Aug 2003 16:55:20 -0000
@@ -0,0 +1,89 @@
+# Check for stdbool.h that conforms to C99.
+
+# 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program 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.
+
+# 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.
+
+# Prepare for substituting <stdbool.h> if it is not supported.
+
+AC_DEFUN([AM_STDBOOL_H],
+[
+  AC_REQUIRE([AC_HEADER_STDBOOL])
+
+  # Define two additional variables used in the Makefile substitution.
+
+  if test "$ac_cv_header_stdbool_h" = yes; then
+    STDBOOL_H=''
+  else
+    STDBOOL_H='stdbool.h'
+  fi
+  AC_SUBST([STDBOOL_H])
+
+  if test "$ac_cv_type__Bool" = yes; then
+    HAVE__BOOL=1
+  else
+    HAVE__BOOL=0
+  fi
+  AC_SUBST([HAVE__BOOL])
+])
+
+# This macro is only needed in autoconf <= 2.54.  Newer versions of autoconf
+# have this macro built-in.
+
+AC_DEFUN([AC_HEADER_STDBOOL],
+  [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+     [ac_cv_header_stdbool_h],
+     [AC_TRY_COMPILE(
+       [
+         #include <stdbool.h>
+         #ifndef bool
+          "error: bool is not defined"
+         #endif
+         #ifndef false
+          "error: false is not defined"
+         #endif
+         #if false
+          "error: false is not 0"
+         #endif
+         #ifndef true
+          "error: false is not defined"
+         #endif
+         #if true != 1
+          "error: true is not 1"
+         #endif
+         #ifndef __bool_true_false_are_defined
+          "error: __bool_true_false_are_defined is not defined"
+         #endif
+
+         struct s { _Bool s: 1; _Bool t; } s;
+
+         char a[true == 1 ? 1 : -1];
+         char b[false == 0 ? 1 : -1];
+         char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+         char d[(bool) -0.5 == true ? 1 : -1];
+         bool e = &s;
+         char f[(_Bool) -0.0 == false ? 1 : -1];
+         char g[true];
+         char h[sizeof (_Bool)];
+         char i[sizeof s.t];
+       ],
+       [ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ],
+       [ac_cv_header_stdbool_h=yes],
+       [ac_cv_header_stdbool_h=no])])
+   AC_CHECK_TYPES([_Bool])
+   if test $ac_cv_header_stdbool_h = yes; then
+     AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
+   fi])
Index: doc/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/doc/Makefile.am,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile.am
--- doc/Makefile.am 27 Aug 2001 07:49:30 -0000 1.4
+++ doc/Makefile.am 29 Aug 2003 16:55:20 -0000
@@ -1,5 +1,5 @@
 ## This file is part of GNU m4
-## Copyright 2000, 2001 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001 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
Index: examples/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/examples/Makefile.am,v
retrieving revision 1.6
diff -u -p -u -r1.6 Makefile.am
--- examples/Makefile.am 27 Aug 2001 07:52:50 -0000 1.6
+++ examples/Makefile.am 29 Aug 2003 16:55:20 -0000
@@ -1,5 +1,5 @@
 ## This file is part of GNU m4
-## Copyright 2000, 2001 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001 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
Index: m4/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/m4/Makefile.am,v
retrieving revision 1.16
diff -u -p -u -r1.16 Makefile.am
--- m4/Makefile.am 16 Jun 2003 10:43:45 -0000 1.16
+++ m4/Makefile.am 29 Aug 2003 16:55:20 -0000
@@ -1,6 +1,6 @@
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 ##
-## Copyright 2000, 2001, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 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
@@ -17,8 +17,10 @@
 ## the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ## Boston, MA 02111-1307, USA.
 
+BUILT_SOURCES          = $(OBSTACK_H)
+
 CLEANFILES             = pathconf.h
-DISTCLEANFILES         = obstack.h
+MOSTLYCLEANFILES       = obstack.h
 MAINTAINERCLEANFILES   = Makefile.in
 
 MODULE_PATH            = $(pkglibexecdir)
@@ -48,3 +50,19 @@ pathconf.h: Makefile
 # This file needs to be regenerated at configure time.
 dist-hook:
        rm -f $(distdir)/system.h
+
+
+# ------------------------------------------------------------ #
+# Taken from gnulib/modules/stdbool:Makefile.am.  Do not edit. #
+# ------------------------------------------------------------ #
+
+BUILT_SOURCES += $(STDBOOL_H)
+EXTRA_DIST += stdbool_.h
+
+# We need the following in order to create an <stdbool.h> when the system
+# doesn't have one that works.
+all-local $(lib_OBJECTS): $(STDBOOL_H)
+stdbool.h: stdbool_.h
+       sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > 
address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += stdbool.h stdbool.h-t
Index: m4/stdbool_.h
===================================================================
RCS file: m4/stdbool_.h
diff -N m4/stdbool_.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/stdbool_.h 29 Aug 2003 16:55:21 -0000
@@ -0,0 +1,92 @@
+/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+   Written by Bruno Haible <address@hidden>, 2001.
+
+   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.
+
+   This program 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.
+
+   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.  */
+
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+/* ISO C 99 <stdbool.h> for platforms that lack it.  */
+
+/* Usage suggestions:
+
+   Programs that use <stdbool.h> should be aware of some limitations
+   and standards compliance issues.
+
+   Standards compliance:
+
+       - <stdbool.h> must be #included before 'bool', 'false', 'true'
+         can be used.
+
+       - You cannot assume that sizeof (bool) == 1.
+
+       - Programs should not undefine the macros bool, true, and false,
+         as C99 lists that as an "obsolescent feature".
+
+   Limitations of this substitute, when used in a C89 environment:
+
+       - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+       - You cannot assume that _Bool is a typedef; it might be a macro.
+
+       - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+         performed in such a way that every nonzero value gets converted
+         to 'true', and zero gets converted to 'false'.  This doesn't work
+         with this substitute.  With this substitute, only the values 0 and 1
+         give the expected result when converted to _Bool' or 'bool'.
+
+   Also, it is suggested that programs use 'bool' rather than '_Bool';
+   this isn't required, but 'bool' is more common.  */
+
+
+/* 7.16. Boolean type and values */
+
+/* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
+   definitions below, but temporarily we have to #undef them.  */
+#ifdef __BEOS__
+# undef false
+# undef true
+#endif
+
+/* For the sake of symbolic names in gdb, we define true and false as
+   enum constants, not only as macros.
+   It is tempting to write
+      typedef enum { false = 0, true = 1 } _Bool;
+   so that gdb prints values of type 'bool' symbolically. But if we do
+   this, values of type '_Bool' may promote to 'int' or 'unsigned int'
+   (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+   (see ISO C 99 6.3.1.1.(2)).  So we add a negative value to the
+   enum; this ensures that '_Bool' promotes to 'int'.  */
+#ifndef __cplusplus
+# if address@hidden@
+#  if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1)
+    /* Avoid stupid "warning: _Bool is a keyword in ISO C99".  */
+#   define _Bool signed char
+enum { false = 0, true = 1 };
+#  else
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+#  endif
+# endif
+#else
+typedef bool _Bool;
+#endif
+#define bool _Bool
+
+/* The other macros must be usable in preprocessor directives.  */
+#define false 0
+#define true 1
+#define __bool_true_false_are_defined 1
+
+#endif /* _STDBOOL_H */
Index: modules/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/modules/Makefile.am,v
retrieving revision 1.21
diff -u -p -u -r1.21 Makefile.am
--- modules/Makefile.am 12 Aug 2003 15:33:57 -0000 1.21
+++ modules/Makefile.am 29 Aug 2003 16:55:21 -0000
@@ -1,5 +1,5 @@
 ## This file is part of GNU m4
-## Copyright 2000, 2001, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001, 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
Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/src/Makefile.am,v
retrieving revision 1.9
diff -u -p -u -r1.9 Makefile.am
--- src/Makefile.am 30 Sep 2001 14:23:28 -0000 1.9
+++ src/Makefile.am 29 Aug 2003 16:55:21 -0000
@@ -1,5 +1,5 @@
 ## This file is part of GNU m4
-## Copyright 2000 Free Software Foundation, Inc.
+## Copyright (C) 2000 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
Index: tests/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/tests/Makefile.am,v
retrieving revision 1.36
diff -u -p -u -r1.36 Makefile.am
--- tests/Makefile.am 27 Aug 2003 14:06:53 -0000 1.36
+++ tests/Makefile.am 29 Aug 2003 16:55:21 -0000
@@ -1,5 +1,5 @@
 ## This file is part of GNU m4
-## Copyright 2000, 2001 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2001 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]