aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--awk.h6
-rw-r--r--configh.in5
-rwxr-xr-xconfigure95
-rw-r--r--configure.ac3
-rw-r--r--dfa.c4
-rw-r--r--missing_d/gawkbool.h40
-rw-r--r--regex.c4
8 files changed, 154 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 299c2f03..2a1373f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-09 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Added AC_HEADER_STDBOOL
+ * awk.h, dfa.c, regex.c: Reworked to use results
+ of test and include missing_d/gawkbool.h.
+
2012-05-07 Arnold D. Robbins <arnold@skeeve.com>
* array.c (prnode): Add casts to void* for %p format.
diff --git a/awk.h b/awk.h
index 89072619..0a0ac136 100644
--- a/awk.h
+++ b/awk.h
@@ -89,6 +89,12 @@ extern int errno;
#include <stdlib.h>
#endif /* not STDC_HEADERS */
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else
+#include "missing_d/gawkbool.h"
+#endif
+
#include "mbsupport.h" /* defines MBS_SUPPORT */
#if MBS_SUPPORT
diff --git a/configh.in b/configh.in
index 503fd062..8cb9826e 100644
--- a/configh.in
+++ b/configh.in
@@ -177,7 +177,7 @@
/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
-/* Define to 1 if you have the <stdbool.h> header file. */
+/* Define to 1 if stdbool.h conforms to C99. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stddef.h> header file. */
@@ -315,6 +315,9 @@
/* systems should define this type here */
#undef HAVE_WINT_T
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
/* disable lint checks */
#undef NO_LINT
diff --git a/configure b/configure
index 0d4cb6ce..d20266fa 100755
--- a/configure
+++ b/configure
@@ -8145,6 +8145,99 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
+$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
+if ${ac_cv_header_stdbool_h+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #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: true 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];
+ /* See body of main program for 'e'. */
+ char f[(_Bool) 0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ enum { j = false, k = true, l = false * true, m = true * 256 };
+ /* The following fails for
+ HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+ _Bool n[m];
+ char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+ /* Catch a bug in an HP-UX C compiler. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+ _Bool q = true;
+ _Bool *pq = &q;
+
+int
+main ()
+{
+
+ bool e = &s;
+ *pq |= q;
+ *pq |= ! q;
+ /* Refer to every declared value, to avoid compiler optimizations. */
+ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ + !m + !n + !o + !p + !q + !pq);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdbool_h=yes
+else
+ ac_cv_header_stdbool_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5
+$as_echo "$ac_cv_header_stdbool_h" >&6; }
+ ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"
+if test "x$ac_cv_type__Bool" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE__BOOL 1
+_ACEOF
+
+
+fi
+
+
+if test $ac_cv_header_stdbool_h = yes; then
+
+$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
+
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
if ${ac_cv_header_sys_wait_h+:} false; then :
@@ -8222,7 +8315,7 @@ $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
fi
for ac_header in arpa/inet.h fcntl.h limits.h locale.h libintl.h mcheck.h \
- netdb.h netinet/in.h stdarg.h stddef.h stdbool.h string.h \
+ netdb.h netinet/in.h stdarg.h stddef.h string.h \
sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \
termios.h stropts.h wchar.h wctype.h
do :
diff --git a/configure.ac b/configure.ac
index d618476d..ac257f98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,10 +135,11 @@ gt_LC_MESSAGES
dnl checks for header files
AC_HEADER_STDC
+AC_HEADER_STDBOOL
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS(arpa/inet.h fcntl.h limits.h locale.h libintl.h mcheck.h \
- netdb.h netinet/in.h stdarg.h stddef.h stdbool.h string.h \
+ netdb.h netinet/in.h stdarg.h stddef.h string.h \
sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \
termios.h stropts.h wchar.h wctype.h)
diff --git a/dfa.c b/dfa.c
index 161425aa..f9355f19 100644
--- a/dfa.c
+++ b/dfa.c
@@ -39,9 +39,7 @@
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
-#define bool int
-#define true (1)
-#define false (0)
+#include "missing_d/gawkbool.h"
#endif /* HAVE_STDBOOL_H */
diff --git a/missing_d/gawkbool.h b/missing_d/gawkbool.h
new file mode 100644
index 00000000..c75a5a10
--- /dev/null
+++ b/missing_d/gawkbool.h
@@ -0,0 +1,40 @@
+/*
+ * gawkbool.h -- replacement definitions for bool.
+ */
+
+/*
+ * Copyright (C) 2012 the Free Software Foundation, Inc.
+ *
+ * This file is part of GAWK, the GNU implementation of the
+ * AWK Programming Language.
+ *
+ * GAWK 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GAWK 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/* This stuff largely taken from the Autoconf doc. */
+
+#ifndef __bool_true_false_are_defined
+# ifndef HAVE__BOOL
+# ifdef __cplusplus
+typedef bool _Bool;
+# else
+# define _Bool signed char
+# endif
+# endif
+# define bool _Bool
+# define false 0
+# define true 1
+# define __bool_true_false_are_defined 1
+#endif
diff --git a/regex.c b/regex.c
index 8e046096..3abc7585 100644
--- a/regex.c
+++ b/regex.c
@@ -65,9 +65,7 @@
#include "regex_internal.c"
#ifndef HAVE_STDBOOL_H
-#define bool int
-#define true (1)
-#define false (0)
+#include "missing_d/gawkbool.h"
#endif
#include "regcomp.c"
#include "regexec.c"