[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] Properly handle funny file names for headers in config.status
From: |
Benoit Sigoure |
Subject: |
[PATCH v2] Properly handle funny file names for headers in config.status. |
Date: |
Mon, 17 Dec 2007 17:21:57 +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>
---
I noticed that my previous attempt to fix this bug introduced a minor problem
in that the comment "/* file $file Generated from $file.in by configure. */"
was also using the escaped version of "$file", which is not very nice. I
adjusted the testsuite to cover this too.
lib/autoconf/status.m4 | 19 +++++++++++--------
tests/torture.at | 9 +++++++++
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 21abe54..03733b4 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -624,6 +624,13 @@ esac
_ACEOF
])dnl
+# Neutralize special characters interpreted by sed in replacement strings.
+case $configure_input in #(
+ *'&'*) ac_sed_conf_input=`AS_ECHO(["$configure_input"]) |
+ sed 's/\\\\/\\\\\\\\/g;s/&/\\\\\\&/g'`;;
+ *) ac_sed_conf_input=$configure_input
+esac
+
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
@@ -635,7 +642,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
[/@[a-zA-Z_][a-zA-Z_0-9]*@/!b]
dnl configure_input is a somewhat special, so we don't call AC_SUBST_TRACE.
-s&@configure_input@&$configure_input&;t t
+s&@configure_input@&$ac_sed_conf_input&;t t
dnl During the transition period, this is a special case:
s&@top_builddir@&$ac_top_builddir_sub&;t t[]AC_SUBST_TRACE([top_builddir])
dnl For this substitution see the witness macro _AC_HAVE_TOP_BUILD_PREFIX
above.
@@ -861,10 +868,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 +883,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
@@ -1655,10 +1662,6 @@ do
configure_input="$ac_file. $configure_input"
AC_MSG_NOTICE([creating $ac_file])
fi
- case $configure_input in #(
- *'&'*) configure_input=`AS_ECHO(["$configure_input"]) |
- sed 's/\\\\/\\\\\\\\/g;s/&/\\\\\\&/g'`;;
- esac
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
diff --git a/tests/torture.at b/tests/torture.at
index 6a7b962..c1ec29a 100644
--- a/tests/torture.at
+++ b/tests/torture.at
@@ -274,6 +274,15 @@ 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 ' & ' "$file"], [],
+[/* file with funny \ ' \' $ & #!*? name. Generated from file with funny \
' \' $ & #!*? name.in by configure. */
+])
AT_CHECK([grep OK "$file"], [], [OK
])
AT_CLEANUP
--
1.5.3.7.997.g4ff2-dirty