From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12460 invoked by alias); 14 Sep 2003 14:57:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12383 invoked from network); 14 Sep 2003 14:57:20 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 14 Sep 2003 14:57:20 -0000 Received: from drow by nevyn.them.org with local (Exim 4.22 #1 (Debian)) id 19yYJR-0004qb-0h; Sun, 14 Sep 2003 10:57:17 -0400 Date: Sun, 14 Sep 2003 14:57:00 -0000 From: Daniel Jacobowitz To: gcc-patches@gcc.gnu.org Cc: binutils@sources.redhat.com, gdb-patches@sources.redhat.com Subject: [toplevel] Fix argument quoting for subconfigures Message-ID: <20030914145716.GA18402@nevyn.them.org> Mail-Followup-To: gcc-patches@gcc.gnu.org, binutils@sources.redhat.com, gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.1i X-SW-Source: 2003-09/txt/msg00302.txt.bz2 This patch is for GCC PR driver/12201. A couple problems in recent changes to the quoting. Backslashes were being doubled, which is wrong as far as I can see - I believe that change was based on a similar autoconf-generated fragment for program_transform_name, which _does_ actually need backslashes doubled. Also, a single apostrophe was being added to each argument. I've also switched to the idiom suggested by Andreas: don't pass configure arguments to echo in case echo expands backslashes. Use cat and a here-doc instead. Unfortunately, if your echo does expand backslashes this won't fix the problem. Despite their own advice in the autoconf manual, autoconf generates code that passes user-supplied strings to echo. That's a problem for another day. So, using bash, this allows me to pass a program-transform-name containing both dollar signs and backslashes to configure and get the right arguments in subdir makefiles. It also fixes up the extra apostrophes in gcc -v output. OK? -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2003-09-13 Daniel Jacobowitz * configure.in (TOPLEVEL_CONFIGURE_ARGUMENTS, baseargs): Fix quoting. 2003-09-13 Daniel Jacobowitz * configure.in: Quote gcc_config_arguments for configargs.h. * gccbug.in: Don't shell-expand gcc_config_arguments. Index: configure.in =================================================================== RCS file: /big/fsf/rsync/gcc-cvs/gcc/configure.in,v retrieving revision 1.256 diff -u -p -r1.256 configure.in --- configure.in 4 Sep 2003 22:53:48 -0000 1.256 +++ configure.in 13 Sep 2003 16:46:44 -0000 @@ -67,19 +67,13 @@ progname=$0 if test -n "$PWD" ; then PWD=`${PWDCMD-pwd}`; fi # Export original configure arguments for use by sub-configures. These -# will be expanded once by make, and once by the shell, so they need to -# have '$' quoted for make, and then each argument quoted for the shell. -# What's more, the 'echo' below might expand backslashes. -cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g +# will be expanded by make, so quote '$'. +tmp="$progname $@" +sed -e 's,\$,$$,g' < conftestsed.out +$tmp EOF_SED -tmp="'$progname'" -for ac_arg -do - tmp="$tmp '"`echo "$ac_arg" | sed -f conftestsed` -done -rm -f conftestsed -TOPLEVEL_CONFIGURE_ARGUMENTS="$tmp" +TOPLEVEL_CONFIGURE_ARGUMENTS=`cat conftestsed.out` +rm -f conftestsed.out AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS) moveifchange=${srcdir}/move-if-change @@ -1766,7 +1760,7 @@ AC_SUBST_FILE(serialization_dependencies # Base args. Strip norecursion, cache-file, srcdir, host, build, # target and nonopt. These are the ones we might not want to pass -# down to subconfigures. +# down to subconfigures. These will be expanded by make, so quote '$'. cat <<\EOF_SED > conftestsed s/ --no[[^ ]]* / / s/ --c[[a-z-]]*[[= ]][[^ ]]* / / @@ -1781,10 +1775,13 @@ s/ -build[[= ]][[^ ]]* / / s/ -target[[= ]][[^ ]]* / / s/ [[^' -][^ ]*] / / s/^ *//;s/ *$// -s,\\,\\\\,g; s,\$,$$,g +s,\$,$$,g +EOF_SED +sed -f conftestsed < conftestsed.out + ${ac_configure_args} EOF_SED -baseargs=`echo " ${ac_configure_args} " | sed -f conftestsed` -rm -f conftestsed +baseargs=`cat conftestsed.out` +rm -f conftestsed conftestsed.out # For the build-side libraries, we just need to pretend we're native, # and not use the same cache file. Multilibs are neither needed nor Index: gcc/configure.in =================================================================== RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/configure.in,v retrieving revision 1.726 diff -u -p -r1.726 configure.in --- gcc/configure.in 10 Sep 2003 00:13:00 -0000 1.726 +++ gcc/configure.in 13 Sep 2003 17:21:05 -0000 @@ -1180,9 +1180,18 @@ if test -f configargs.h ; then else gcc_config_arguments="$TOPLEVEL_CONFIGURE_ARGUMENTS" fi + +# Double all backslashes and backslash all quotes to turn +# gcc_config_arguments into a C string. +sed -e 's/\\/\\\\/g; s/"/\\"/g' <conftest.out +$gcc_config_arguments +EOF +gcc_config_arguments_str=`cat conftest.out` +rm -f conftest.out + cat > configargs.h <> $file << \__EOF__ configured with: @gcc_config_arguments@ +__EOF__ + cat >> $file << __EOF__ >Description: $DESCRIPTION_C >How-To-Repeat: