summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-08-06 14:51:32 -0400
committerZack Weinberg <zackw@panix.com>2020-08-18 08:24:00 -0400
commit6a0c0239449a98181c5dd7e505cddbc0840471a4 (patch)
treec784675154478f6432d0c89bf11e4ea315ed0ea6 /tests
parent508225174b29b27a5d3a4b9ba9fdddd9a4627dda (diff)
downloadautoconf-6a0c0239449a98181c5dd7e505cddbc0840471a4.tar.gz
Trim whitespace from arguments of AC_INIT (#107986)
Specifically, all five arguments, if present, are passed through m4_normalize before doing anything else with them. For instance, AC_INIT([ GNU Hello ], [1.0]) is now equivalent to AC_INIT([GNU Hello], [1.0]). As a consequence, newlines in the arguments to AC_INIT are now converted to spaces and no longer trigger warnings. Also, diagnose inappropriate contents of the fourth and fifth arguments as well as the first three. The fifth argument should be “usable as-is in single- and double-quoted strings and quoted and unquoted here-docs,” like the first three. (This is the check performed by _AC_INIT_LITERAL.) The fourth argument (TARNAME) is used to construct filenames, so apply an even more stringent test, namely AS_LITERAL_WORD_IF. Suggested by David A. Wheeler, who submitted a patch, but I didn’t wind up using any of his code. * lib/autoconf/general.m4 (_AC_INIT_LITERAL): Not necessary to check for newlines anymore. (_AC_INIT_PACKAGE): Pass all five arguments through m4_normalize before doing anything else with them. New warning: apply _AC_INIT_LITERAL to fifth argument (URL). New warning: complain if fourth argument (TARNAME) is not a literal word according to AS_LITERAL_WORD_IF. Simplify a conditional by using m4_default. * tests/base.at (AC_INIT with unusual version strings): Adjust to match above changes, add more subtests.
Diffstat (limited to 'tests')
-rw-r--r--tests/base.at73
1 files changed, 65 insertions, 8 deletions
diff --git a/tests/base.at b/tests/base.at
index ff753f1a..98125173 100644
--- a/tests/base.at
+++ b/tests/base.at
@@ -227,7 +227,10 @@ AT_SETUP([AC_INIT with unusual version strings])
AT_DATA([configure.ac],
[[AC_INIT([GNU String++ with spaces (foo)],
- [2.48++ (2010-07-03)], [[https://example.com/?a=b&c=d#e]], [clisp])
+ [2.48++ (2010-07-03)],
+ [[https://example.com/?a=b&c=d#e]],
+ [string++],
+ [[https://example.com/?f=g&h=i%2fj#42]])
AC_OUTPUT
]])
@@ -241,19 +244,20 @@ AT_CHECK_AUTOCONF([-Werror])
AT_CHECK_CONFIGURE([-q])
AT_CHECK_CONFIGURE([--help], [], [stdout])
AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
+AT_CHECK([[$FGREP 'com/?f=g&h=i%2fj#42' stdout]], [], [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([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore])
+AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore])
AT_CHECK([./config.status --help], [], [stdout])
AT_CHECK([[$FGREP 'com/?a=b&c=d#e' 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_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], [https://example.com/], [clisp])
+ [2.48], [https://example.com/], [string++])
AC_OUTPUT
]])
@@ -262,7 +266,7 @@ AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
AT_DATA([configure.ac],
[[AC_INIT([GNU String++],
- ['codename' 2.48], [https://example.com/], [clisp])
+ ['codename' 2.48], [https://example.com/], [string++])
AC_OUTPUT
]])
@@ -271,13 +275,66 @@ AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
AT_DATA([configure.ac],
[[AC_INIT([GNU
-String++], [2.48], [https://example.com/], [clisp])
+String++], [2.48], [https://example.com/], [string++])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++], ['2.48'], [https://example.com], [string++])
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++], [2.48], ['https://example.com'], [string++])
+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++], [2.48], [https://example.com], [string++],
+ ['https://example.com'])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
+
+
+# The TARNAME argument is used to construct filenames, so it's even
+# more constrained.
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++], [2.48], [https://example.com], ['string++'])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: unsafe as a filename: ' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++], [2.48], [https://example.com], [string ++])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: unsafe as a filename: ' stderr], [], [ignore])
+
+AT_DATA([configure.ac],
+[[AC_INIT([GNU String++], [2.48], [https://example.com], [string*])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
+AT_CHECK([grep 'AC_INIT: unsafe as a filename: ' stderr], [], [ignore])
+
+
AT_CLEANUP