This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[toplevel] Fix argument quoting for subconfigures


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  <drow@mvista.com>

	* configure.in (TOPLEVEL_CONFIGURE_ARGUMENTS, baseargs): Fix
	quoting.

2003-09-13  Daniel Jacobowitz  <drow@mvista.com>

	* 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' <<EOF_SED > 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 <<EOF_SED > 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' <<EOF >conftest.out
+$gcc_config_arguments
+EOF
+gcc_config_arguments_str=`cat conftest.out`
+rm -f conftest.out
+
 cat > configargs.h <<EOF
 /* Generated automatically. */
-static const char configuration_arguments[] = "$gcc_config_arguments";
+static const char configuration_arguments[] = "$gcc_config_arguments_str";
 static const char thread_model[] = "$thread_file";
 
 static const struct {
Index: gcc/gccbug.in
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/gccbug.in,v
retrieving revision 1.17
diff -u -p -r1.17 gccbug.in
--- gcc/gccbug.in	25 Jun 2003 21:08:26 -0000	1.17
+++ gcc/gccbug.in	13 Sep 2003 17:01:48 -0000
@@ -344,7 +344,11 @@ SEND-PR: support             I need help
 host: @host@
 build: @build@
 target: @target@
+__EOF__
+      cat >> $file << \__EOF__
 configured with: @gcc_config_arguments@
+__EOF__
+      cat >> $file << __EOF__
 >Description:
 	$DESCRIPTION_C
 >How-To-Repeat:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]