This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [PATCH] For -### only quote what is needed


On Fri, Apr 16, 2010 at 08:10:52PM +0200, Ralf Wildenhues wrote:
> * Jakub Jelinek wrote on Fri, Apr 16, 2010 at 07:49:53PM CEST:
> > 2010-04-16  Jakub Jelinek  <jakub@redhat.com>
> > 
> > 	* gcc.c (execute): For -### don't quote arguments that
> > 	contain just alphanumerics and _/-. characters.
> 
> I like the idea, but you also need to adjust the documentation,
> invoke.texi currently states that all command arguments are quoted.

Ok, here it is with invoke.texi part, bootstrapped/regtested
on x86_64-linux and i686-linux.

2010-04-16  Jakub Jelinek  <jakub@redhat.com>

	* gcc.c (execute): For -### don't quote arguments that
	contain just alphanumerics and _/-. characters.
	* doc/invoke.texi: Document that change for -###.

--- gcc/gcc.c.jj	2010-04-13 14:16:43.000000000 +0200
+++ gcc/gcc.c	2010-04-16 19:31:26.000000000 +0200
@@ -3011,14 +3011,23 @@ execute (void)
 	      for (j = commands[i].argv; *j; j++)
 		{
 		  const char *p;
-		  fprintf (stderr, " \"");
 		  for (p = *j; *p; ++p)
+		    if (!ISALNUM ((unsigned char) *p)
+			&& *p != '_' && *p != '/' && *p != '-' && *p != '.')
+		      break;
+		  if (*p || !*j)
 		    {
-		      if (*p == '"' || *p == '\\' || *p == '$')
-			fputc ('\\', stderr);
-		      fputc (*p, stderr);
+		      fprintf (stderr, " \"");
+		      for (p = *j; *p; ++p)
+			{
+			  if (*p == '"' || *p == '\\' || *p == '$')
+			    fputc ('\\', stderr);
+			  fputc (*p, stderr);
+			}
+		      fputc ('"', stderr);
 		    }
-		  fputc ('"', stderr);
+		  else
+		    fprintf (stderr, " %s", *j);
 		}
 	    }
 	  else
--- gcc/doc/invoke.texi.jj	2010-04-16 17:35:37.000000000 +0200
+++ gcc/doc/invoke.texi	2010-04-16 20:48:38.000000000 +0200
@@ -1171,9 +1171,9 @@ program and of the preprocessor and the 
 
 @item -###
 @opindex ###
-Like @option{-v} except the commands are not executed and all command
-arguments are quoted.  This is useful for shell scripts to capture the
-driver-generated command lines.
+Like @option{-v} except the commands are not executed and arguments
+are quoted unless they contain only alpha numeric characters or @code{./-_}.
+This is useful for shell scripts to capture the driver-generated command lines.
 
 @item -pipe
 @opindex pipe


	Jakub


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