summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary V. Vaughan <gary@gnu.org>2003-08-29 16:55:55 +0000
committerEric Blake <ebb9@byu.net>2007-10-05 22:00:21 -0600
commitc0e7fbef55f8f50e03d0b8ae21d345a39a20ef96 (patch)
tree802f77ed74e20e819565737893537548c717ba34
parentf2d311322e171eae94c3daf7fbf5439b38c42f03 (diff)
downloadm4-c0e7fbef55f8f50e03d0b8ae21d345a39a20ef96.tar.gz
* 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.
-rw-r--r--ChangeLog8
-rw-r--r--Makefile.am2
-rw-r--r--config/gnu-obstack.m42
-rw-r--r--config/stdbool.m489
-rw-r--r--configure.ac10
-rw-r--r--doc/Makefile.am2
-rw-r--r--examples/Makefile.am2
-rw-r--r--m4/Makefile.am22
-rw-r--r--m4/stdbool_.h92
-rw-r--r--modules/Makefile.am2
-rw-r--r--src/Makefile.am2
-rw-r--r--tests/Makefile.am2
12 files changed, 218 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e991fa5..a250ea8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-08-29 Gary V. Vaughan <gary@gnu.org>
+
+ * 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.
+
2003-08-27 Gary V. Vaughan <gary@gnu.org>
* config/debug.m4: `perl -pi.bak -e 's/(Copyright) (\d)/$1 (C) $2/g'`
diff --git a/Makefile.am b/Makefile.am
index 0fc7c495..4a13aca8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/config/gnu-obstack.m4 b/config/gnu-obstack.m4
index a544d1eb..b917ad79 100644
--- a/config/gnu-obstack.m4
+++ b/config/gnu-obstack.m4
@@ -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,
diff --git a/config/stdbool.m4 b/config/stdbool.m4
new file mode 100644
index 00000000..ed000c81
--- /dev/null
+++ b/config/stdbool.m4
@@ -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])
diff --git a/configure.ac b/configure.ac
index b3f03791..672c5360 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 27b44e00..5e5f4021 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -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
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 4d969810..9923c074 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -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
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 5f5d96a0..3ef76057 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -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 > $@-t
+ mv $@-t $@
+MOSTLYCLEANFILES += stdbool.h stdbool.h-t
diff --git a/m4/stdbool_.h b/m4/stdbool_.h
new file mode 100644
index 00000000..3dbb51b2
--- /dev/null
+++ b/m4/stdbool_.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+ Written by Bruno Haible <haible@clisp.cons.org>, 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 !@HAVE__BOOL@
+# 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 */
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 48cbaccb..bf43eba8 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -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
diff --git a/src/Makefile.am b/src/Makefile.am
index 89454145..a3ba339a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f44bf751..6fa002f3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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