autoconf-patches
[Top][All Lists]
Advanced

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

AC_HEADER_ASSERT: don't say assertions are disabled when they're not


From: Jim Meyering
Subject: AC_HEADER_ASSERT: don't say assertions are disabled when they're not
Date: Wed, 10 Dec 2008 15:09:53 +0100

I was surprised to see assertions being turned off by default:

    $ cat configure.ac
    AC_INIT
    AC_CONFIG_HEADERS([config.h])
    AC_HEADER_ASSERT
    AC_OUTPUT
    $ autoheader && autoconf && ./configure
    checking whether to enable assertions... no <-- wrong! default is to enable
    configure: creating ./config.status
    config.status: creating config.h
    config.status: config.h is unchanged

But in fact, they *are* still enabled:

    $ grep ND config.h
    /* #undef NDEBUG */

Here's the s/no/yes/ fix, along with indentation adjustments
to make it clearer that it's a two-test use of AS_IF.

If no one objects, I'll push in a few hours:
[gnulib's gl_ASSERT will get a similar change, included below]

>From 27d44bf831cdf696049e2d6a96173d8ea0fa40eb Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 10 Dec 2008 14:45:35 +0100
Subject: [PATCH] AC_HEADER_ASSERT: don't say assertions are disabled when 
they're not

* lib/autoconf/headers.m4 (AC_HEADER_ASSERT): Do not make configure
report "checking whether to enable assertions... no", when they
are in fact enabled.  This is solely a bug in the output of configure.
In spite of saying "no", NDEBUG was not defined in that case.
---
 ChangeLog               |    6 ++++++
 lib/autoconf/headers.m4 |   13 +++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 7fe94af..4fda7f9 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -437,13 +437,14 @@ AC_DEFUN([AC_HEADER_ASSERT],
   AC_ARG_ENABLE([assert],
     [AS_HELP_STRING([--disable-assert], [turn off assertions])],
     [ac_enable_assert=$enableval
-     AS_IF([test "x$enableval" = xno],
-      [AC_DEFINE([NDEBUG], [1],
-       [Define to 1 if assertions should be disabled.])],
+     AS_IF(dnl
+      [test "x$enableval" = xno],
+        [AC_DEFINE([NDEBUG], [1],
+          [Define to 1 if assertions should be disabled.])],
       [test "x$enableval" != xyes],
-      [AC_MSG_WARN([invalid argument supplied to --enable-assert])
-      ac_enable_assert=no])],
-    [ac_enable_assert=no])
+        [AC_MSG_WARN([invalid argument supplied to --enable-assert])
+        ac_enable_assert=no])],
+    [ac_enable_assert=yes])
   AC_MSG_RESULT([$ac_enable_assert])
 ])

--
1.6.1.rc2.282.ga5881

Here's the gnulib change.
I'm not bothering to change indentation here,
since this code will go away we can assume a new-enough
version of autoconf.

>From 718f4f383a01ba473e90a1ac08977e5669a56037 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 10 Dec 2008 15:06:42 +0100
Subject: [PATCH] gl_ASSERT: don't say assertions are disabled when they're not

* m4/assert.m4 (gl_ASSERT): Do not make configure report
"checking whether to enable assertions... no", when they are in
fact enabled.  This is solely a bug in the output of configure.
In spite of saying "no", NDEBUG was not defined in that case.
---
 m4/assert.m4 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/m4/assert.m4 b/m4/assert.m4
index cb61ce8..ab96854 100644
--- a/m4/assert.m4
+++ b/m4/assert.m4
@@ -1,4 +1,4 @@
-#serial 6
+#serial 7

 # Copyright (C) 1998, 1999, 2001, 2004, 2008 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -19,6 +19,6 @@ AC_DEFUN([gl_ASSERT],
       [test "x$enableval" != xyes],
       [AC_MSG_WARN([invalid argument supplied to --enable-assert])
       enable_assert=no])],
-    [enable_assert=no])
+    [enable_assert=yes])
   AC_MSG_RESULT([$enable_assert])
 ])
--
1.6.1.rc2.282.ga5881




reply via email to

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