autoconf-patches
[Top][All Lists]
Advanced

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

Re: awk for config headers


From: Eric Blake
Subject: Re: awk for config headers
Date: Wed, 10 Oct 2007 23:22:14 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:

> 
> Following up on
> <http://lists.gnu.org/archive/html/autoconf/2007-09/msg00075.html>,
> here's a rewrite using awk instead of sed to generate config headers.
> 
...
> 
> In the patch below, I've not changed the XFAILing test `Define a
> newline' as that would clash with Eric's proposed patch; likewise a
> manual change is still missing.

How about this?  It embodies the ideas from my earlier proposal[1], but without 
regex overhead, and with m4_warn instead of m4_fatal.  I haven't committed it 
yet...

[1] http://lists.gnu.org/archive/html/autoconf-patches/2007-09/msg00041.html

From: Eric Blake <address@hidden>
Date: Wed, 10 Oct 2007 14:02:16 -0600
Subject: [PATCH] Config header generation followup.

* lib/autoconf/general.m4 (_AC_DEFINE_Q): Check for raw newlines,
which won't work with the preprocessor nor with the awk
implementation.
* tests/torture.at (Define a newline): Test raw newline detection,
removing the XFAIL.
* doc/autoconf.texi (Defining Symbols): Document recent change to
allow backslash-newline.
* THANKS: Update.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   11 +++++++++++
 THANKS                  |    1 +
 doc/autoconf.texi       |   13 +++++++++----
 lib/autoconf/general.m4 |    6 ++++++
 tests/torture.at        |   18 ++++++++++++------
 5 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1e1735a..eafe5ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2007-10-10  Eric Blake  <address@hidden>
 
+       Config header generation followup.
+       * lib/autoconf/general.m4 (_AC_DEFINE_Q): Check for raw newlines,
+       which won't work with the preprocessor nor with the awk
+       implementation.
+       * lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Avoid overquoting.
+       * tests/torture.at (Define a newline): Test raw newline detection,
+       removing the XFAIL.
+       * doc/autoconf.texi (Defining Symbols): Document recent change to
+       allow backslash-newline.
+       * THANKS: Update.
+
        Avoid some overhead from m4_defn and m4_popdef.
        * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Only
        pass on first argument, since we are documented that way.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 29161d0..faeb9fc 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -8494,10 +8494,15 @@ terminated by an ellipsis @samp{...} if C99 syntax is 
employed.
 backslash-newlines, universal character names, or address@hidden
 characters.
 
address@hidden should not contain literal newlines, and if you are not
-using @code{AC_CONFIG_HEADERS} it should not contain any @samp{#}
-characters, as @command{make} tends to eat them.  To use a shell variable,
-use @code{AC_DEFINE_UNQUOTED} instead.
address@hidden may contain backslash-escaped newlines, which will be
+preserved if you use @code{AC_CONFIG_HEADERS} but flattened if passed
+via @code{@@DEFS@@} (with no effect on the compilation, since the
+preprocessor sees only one line in the first place).  @var{value} should
+not contain raw newlines.  If you are not using
address@hidden, @var{value} should not contain any @samp{#}
+characters, as @command{make} tends to eat them.  To use a shell
+variable, use @code{AC_DEFINE_UNQUOTED} instead.
+
 @var{description} is only useful if you are using
 @code{AC_CONFIG_HEADERS}.  In this case, @var{description} is put into
 the generated @file{config.h.in} as the comment before the macro define.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 384eb42..c210726 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2045,6 +2045,12 @@ m4_define([_AC_DEFINE_Q],
 [m4_pushdef([AC_name], m4_if(m4_index([$2], [(]), [-1], [[[$2]]],
                             [m4_bpatsubst([[[$2]]], [(.*)])]))dnl
 AC_DEFINE_TRACE(AC_name)dnl
+m4_cond([m4_index([$3], [
+])], [-1], [],
+       [AS_LITERAL_IF([$3], [m4_bregexp([[$3]], [[^\\]
+], [-])])], [], [],
+       [m4_warn([syntax], [AC_DEFINE]m4_ifval([$1], [], [[_UNQUOTED]])dnl
+[: `$3' is not a valid preprocessor define value])])dnl
 m4_ifval([$4], [AH_TEMPLATE(AC_name, [$4])])dnl
 m4_popdef([AC_name])dnl
 cat >>confdefs.h <<$1_ACEOF
diff --git a/tests/torture.at b/tests/torture.at
index 93df3b8..7db8b31 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -763,16 +763,22 @@ AT_CLEANUP
 ## ------------------ ##
 
 AT_SETUP([Define a newline])
-AT_XFAIL_IF(:)
 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
 two], [This spans two lines.])
 ]])
-AT_CHECK_AUTOCONF
-AT_CHECK_AUTOHEADER
-AT_CHECK_CONFIGURE
-AT_CHECK_DEFINES([[#define foo one
-two
+AT_CHECK_AUTOCONF([], [], [],
+[[configure.ac:5: warning: AC_DEFINE: `one
+configure.ac:5: two' is not a valid preprocessor define value
 ]])
+
+AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
+two], [This spans two lines.])
+]])
+AT_CHECK_AUTOCONF([], [], [],
+[[configure.ac:5: warning: AC_DEFINE_UNQUOTED: `one
+configure.ac:5: two' is not a valid preprocessor define value
+]])
+
 AT_CLEANUP
 
 
-- 
1.5.3.2







reply via email to

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