From: Eric Blake Date: Wed, 10 Oct 2007 20:02:16 +0000 (-0600) Subject: Config header generation followup. X-Git-Tag: v2.62~213^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baa0ce097828a7369eee0444b529951730110e0c;p=thirdparty%2Fautoconf.git 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 --- diff --git a/ChangeLog b/ChangeLog index 23bbeeba..dfa78e1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-10-11 Eric Blake + + 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. + 2007-10-11 Ralf Wildenhues * lib/autotest/general.m4: Put function braces in separate line. diff --git a/THANKS b/THANKS index a3c215b2..c30e3417 100644 --- a/THANKS +++ b/THANKS @@ -96,6 +96,7 @@ Enrique Robledo Arnuncio enrique.robledo@wanadoo.es Erez Zadok ezk@cs.columbia.edu Eric Backus ericb@lsid.hp.com Eric Blake ebb9@byu.net +Eric Lemings lemings@roguewave.com Eric Mumpower nocturne@mit.edu Eric Paire ? Eric Sunshine sunshine@sunshineco.com diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 29161d07..faeb9fc3 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 non-@acronym{ASCII} characters. -@var{value} 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. +@var{value} 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 +@code{AC_CONFIG_HEADERS}, @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 384eb420..1b7a3553 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 93df3b8a..ea639fc5 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -763,16 +763,36 @@ 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_AUTOCONF([], [], [], +[[configure.ac:5: warning: AC_DEFINE: `one +configure.ac:5: two' is not a valid preprocessor define value +]]) +AT_CHECK_AUTOHEADER([], [], [], +[[configure.ac:5: warning: AC_DEFINE: `one +configure.ac:5: two' is not a valid preprocessor define value +]]) AT_CHECK_CONFIGURE AT_CHECK_DEFINES([[#define foo one -two ]]) + +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_CHECK_AUTOHEADER([], [], [], +[[configure.ac:5: warning: AC_DEFINE_UNQUOTED: `one +configure.ac:5: two' is not a valid preprocessor define value +]]) +AT_CHECK_CONFIGURE +AT_CHECK_DEFINES([[#define foo one +]]) + AT_CLEANUP