autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 1/3] Properly expand @configure_input@ in config.status.


From: Ralf Wildenhues
Subject: Re: [PATCH 1/3] Properly expand @configure_input@ in config.status.
Date: Sat, 5 Jan 2008 04:09:06 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Benoit,

Thanks for working on this.

* Benoit Sigoure wrote on Tue, Dec 18, 2007 at 01:54:06PM CET:
>       Fixes test 119.
>       * lib/autoconf/status.m4 (_AC_OUTPUT_FILE): Escape the
>       backslashes and ampersands in $configure_input before using
>       it in the sed replacement string to expand @address@hidden

This is missing a test to expose the failure, and as such, it's no
wonder the fix doesn't work.  ;-)

The other patch to add to the testsuite should include @configure_input@
somewhere in the *.in file, and the test should check for that.

> --- 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

This bit of code is executed at configure time, but needs to be run at
config.status time.

> @@ -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

This is problematic as well.  If & is used as sed s delimiter, then
escaping & in the RHS right is tricky (portably), as it's now both
delimiter and replacement operator, and literal.  It's easier to use
something different here, for example |.

I think this should work, but I'm not done with the test yet.
(dunno if leaving your sign-off on this would be ok?)

Cheers,
Ralf

    Properly expand @configure_input@ in config.status.
    
    * lib/autoconf/status.m4 (_AC_OUTPUT_FILE, _AC_OUTPUT_MAIN_LOOP):
    Escape the backslashes and ampersands in $configure_input before
    using it in the sed replacement string to expand @address@hidden
    Report by Eric Blake.
    
    Signed-off-by: Benoit Sigoure <address@hidden>
    Signed-off-by: Ralf Wildenhues <address@hidden>

diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 8afa9ba..86c0ce5 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -635,7 +635,10 @@ 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
+dnl Note if you change the s||| delimiter here, don't forget to adjust
+dnl ac_sed_conf_input accordingly.  Using & is a bad idea if & appears in
+dnl the replacement string.
+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.
@@ -1655,6 +1658,12 @@ do
       configure_input="$ac_file.  $configure_input"
       AC_MSG_NOTICE([creating $ac_file])
     fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *'&'*) ac_sed_conf_input=`AS_ECHO(["$configure_input"]) |
+            sed 's/[[\\\\&|]]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
 
     case $ac_tag in
     *:-:* | *:-) cat >"$tmp/stdin" \





reply via email to

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