autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH] Properly handle funny file names for headers in config.status.


From: Benoit Sigoure
Subject: [PATCH] Properly handle funny file names for headers in config.status.
Date: Mon, 17 Dec 2007 17:00:06 +0100

        The test suite did not cover this bug because the code was not
        quoting properly the arguments of `rm -f' (which "fails" silently)
        as well as the arguments of `diff' (whose output was redirected to
        /dev/null so we couldn't see its error message).
        * lib/autoconf/status.m4 (_AC_OUTPUT_HEADER): Properly quote the
        file names passed to `rm' and `diff'.
        * tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
        Add a regression test.

Signed-off-by: Benoit Sigoure <address@hidden>
---
The last hunk of status.m4 is a safety measure because the macro
_AC_AM_CONFIG_HEADER_HOOK in Git HEAD Automake reads:

| AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
| [# Compute $1's index in $config_headers.
| _am_stamp_count=1
| for _am_header in $config_headers :; do
|   case $_am_header in
|     $1 | $1:* )
|       break ;;
|     * )
|       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
|   esac
| done
| echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])

and it's obviously not safe if its argument contains spaces.  I thought it
would be better to fix the macro itself, but if we do so, we can only
advertise in the NEWS file that "support for funny file names has been fixed
but you need recent Automake to ..."

It's too bad that we don't have a test to exercise this code, or so it seems.

 lib/autoconf/status.m4 |    6 +++---
 tests/torture.at       |    6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 21abe54..23da2c6 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -861,10 +861,10 @@ m4_define([_AC_OUTPUT_HEADER],
       && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
     } >"$tmp/config.h" \
       || AC_MSG_ERROR([could not create $ac_file])
-    if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
       AC_MSG_NOTICE([$ac_file is unchanged])
     else
-      rm -f $ac_file
+      rm -f "$ac_file"
       mv "$tmp/config.h" "$ac_file" \
        || AC_MSG_ERROR([could not create $ac_file])
     fi
@@ -876,7 +876,7 @@ m4_define([_AC_OUTPUT_HEADER],
 dnl If running for Automake, be ready to perform additional
 dnl commands to set up the timestamp files.
 m4_ifdef([_AC_AM_CONFIG_HEADER_HOOK],
-        [_AC_AM_CONFIG_HEADER_HOOK([$ac_file])
+        [_AC_AM_CONFIG_HEADER_HOOK(["$ac_file"])
 ])dnl
 ])# _AC_OUTPUT_HEADER
 
diff --git a/tests/torture.at b/tests/torture.at
index 6a7b962..6e5ed59 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -274,6 +274,12 @@ AT_CHECK([grep OK "$file"], [], [OK
 ])
 AT_CHECK([./config.status "--header=$file:$file.in"],
         [0], [ignore])
+# Run the same test a 2nd time to see that config.status does not recreate
+# the header (regression test)
+AT_CHECK([./config.status "--header=$file:$file.in"],
+        [0], [config.status: creating file with  funny \ ' \' $ & #!*? name
+config.status: file with  funny \ ' \' $ & #!*? name is unchanged
+])
 AT_CHECK([grep OK "$file"], [], [OK
 ])
 AT_CLEANUP
-- 
1.5.3.7.997.g4ff2-dirty





reply via email to

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