autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH] Fix up AC_INIT vs. " issues, and document it.


From: Eric Blake
Subject: [PATCH] Fix up AC_INIT vs. " issues, and document it.
Date: Mon, 19 Jul 2010 16:45:11 -0600

* doc/autoconf.texi (Initializing configure): Improve
documentation on argument restrictions.
* NEWS: Tweak information.
* lib/autoconf/general.m4 (_AC_INIT_GENERAL): New macro, that also
rejects literal ".
(_AC_INIT_PACKAGE): Use it to plug hole in last patch.
* tests/base.at (AC_INIT with unusual version strings): Enhance
test.

Signed-off-by: Eric Blake <address@hidden>
---

> At this point, I'm thinking of using AS_LITERAL_HEREDOC_IF plus one
> additional check for "; all other uses of AC_PACKAGE_STRING and friends
> appeared to be inside "", so it's just a documentation matter to mention
> that these strings should be double-quoted for project-generic code
> (such as automake), but an individual project that follows stricter
> rules (such as coreutils version string always being a single shell
> word) can get by with referencing AC_PACKAGE_VERSION outside double quotes.
> 
> Updated patch coming shortly...

Like this.  I also enhanced the test to pass two spaces through,
as well as grepping the --version output for two spaces, which
goes a step further in validating that we don't use version strings
outside of double-quotes or here-docs.

 ChangeLog               |   12 ++++++++++++
 NEWS                    |   10 +++++-----
 doc/autoconf.texi       |    9 ++++++---
 lib/autoconf/general.m4 |   15 ++++++++++-----
 tests/base.at           |   37 +++++++++++++++++++++++++++++++++----
 5 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cb40375..c5d368b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,16 @@
 2010-07-19  Eric Blake  <address@hidden>
+
+       Fix up AC_INIT vs. " issues, and document it.
+       * doc/autoconf.texi (Initializing configure): Improve
+       documentation on argument restrictions.
+       * NEWS: Tweak information.
+       * lib/autoconf/general.m4 (_AC_INIT_GENERAL): New macro, that also
+       rejects literal ".
+       (_AC_INIT_PACKAGE): Use it to plug hole in last patch.
+       * tests/base.at (AC_INIT with unusual version strings): Enhance
+       test.
+
+2010-07-19  Eric Blake  <address@hidden>
        and Ralf Wildenhues  <address@hidden>

        Relax AC_INIT requirements for PACKAGE and VERSION strings again.
diff --git a/NEWS b/NEWS
index b3cd1a4..14ed11a 100644
--- a/NEWS
+++ b/NEWS
@@ -11,11 +11,11 @@ GNU Autoconf NEWS - User visible changes.
 ** New macro AC_FC_LINE_LENGTH to accept long Fortran source code lines.

 ** AC_INIT again allows parentheses and other characters that are literal
-   in both quoted and unquoted here-documents in its PACKAGE and
-   VERSION arguments.  This is relevant for packages not using these
-   strings nor products like PACKAGE_STRING in other contexts, e.g.,
-   for Automake, and may be subject to further restrictions in the
-   future.  Regression introduced in 2.66.
+   in quoted and unquoted here-documents and in double-quoted strings
+   in its PACKAGE and VERSION arguments.  This is relevant for
+   packages not using these strings nor products like PACKAGE_STRING
+   in other contexts, e.g., for Automake, and may be subject to
+   further restrictions in the future.  Regression introduced in 2.66.


 * Major changes in Autoconf 2.66 (2010-07-02) [stable]
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 4202108..7e77bc4 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -1844,9 +1844,12 @@ Initializing configure
 other than alphanumerics and underscores are changed to @samp{-}.  If
 provided, @var{url} should be the home page for the package.

-It is preferable that the arguments of @code{AC_INIT} be static, i.e.,
-there should not be any shell computation, but they can be computed by
-M4.
+The arguments of @code{AC_INIT} must be static, i.e., there should not
+be any shell computation, but they can be computed by M4 (the use of
address@hidden is permissible).  This is because the package
+information strings are expanded at M4 time into several contexts, and
+must give the same text at shell time whether used in double-quoted
+strings, quoted here-documents, or unquoted here-documents.

 The following M4 macros (e.g., @code{AC_PACKAGE_NAME}), output variables
 (e.g., @code{PACKAGE_NAME}), and preprocessor symbols (e.g.,
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 598b87b..6470c35 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -224,15 +224,20 @@ AU_ALIAS([AC_HELP_STRING], [AS_HELP_STRING])
 # The solution is to require AC_INIT in each of these macros.  AC_INIT
 # has the needed magic so that it can't be expanded twice.

-
+# _AC_INIT_LITERAL(STRING)
+# ------------------------
+# Reject STRING if it cannot be used as-is in double-quoted strings,
+# as well as quoted and unquoted here-docs.
+m4_define([_AC_INIT_LITERAL],
+[m4_if(m4_index([$1], dnl font-lock"
+["])AS_LITERAL_HEREDOC_IF([$1], [-]), [-1-], [],
+  [m4_warn([syntax], [AC_INIT: not a literal: $1])])])

 # _AC_INIT_PACKAGE(PACKAGE-NAME, VERSION, BUG-REPORT, [TARNAME], [URL])
 # ---------------------------------------------------------------------
 m4_define([_AC_INIT_PACKAGE],
-[AS_LITERAL_HEREDOC_IF([$1], [],
-                      [m4_warn([syntax], [AC_INIT: not a literal: $1])])
-AS_LITERAL_HEREDOC_IF([$2], [],
-                     [m4_warn([syntax], [AC_INIT: not a literal: $2])])
+[_AC_INIT_LITERAL([$1])
+_AC_INIT_LITERAL([$2])
 AS_LITERAL_IF([$3], [],  [m4_warn([syntax], [AC_INIT: not a literal: $3])])
 m4_ifndef([AC_PACKAGE_NAME],
          [m4_define([AC_PACKAGE_NAME],     [$1])])
diff --git a/tests/base.at b/tests/base.at
index ac4ab27..6dc9a17 100644
--- a/tests/base.at
+++ b/tests/base.at
@@ -226,16 +226,45 @@ AT_CLEANUP
 AT_SETUP([AC_INIT with unusual version strings])

 AT_DATA([configure.ac],
-[[AC_INIT([GNU String++ with spaces (foo)],
-         [2.48++ (2010-07-03)], [http://clisp.cons.org/], [clisp])
+[[AC_INIT([GNU String++ with  spaces (foo)],
+         [2.48++  (2010-07-03)], [http://clisp.cons.org/], [clisp])
 AC_OUTPUT
 ]])

+if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then
+  FGREP="grep -F"
+else
+  FGREP=fgrep
+fi
+
 AT_CHECK_AUTOCONF([-Werror])
 AT_CHECK_CONFIGURE([-q])
 AT_CHECK_CONFIGURE([--help])
-AT_CHECK_CONFIGURE([--version])
-AT_CHECK([./config.status --version], [], [ignore])
+AT_CHECK_CONFIGURE([--version], [], [stdout])
+AT_CHECK([$FGREP 'GNU String++ with  spaces (foo)' stdout], [], [ignore])
+AT_CHECK([$FGREP '2.48++  (2010-07-03)' stdout], [], [ignore])
+
+AT_CHECK([./config.status --version], [], [stdout])
+AT_CHECK([$FGREP 'GNU String++ with  spaces (foo)' stdout], [], [ignore])
+AT_CHECK([$FGREP '2.48++  (2010-07-03)' stdout], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU "String++"],
+         [2.48], [http://clisp.cons.org/], [clisp])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++],
+         ["codename" 2.48], [http://clisp.cons.org/], [clisp])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])

 AT_CLEANUP

-- 
1.7.1.1




reply via email to

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