Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* gdb --args mishandles empty arguments
@ 2002-12-02  6:42 Andreas Schwab
  2002-12-02 18:23 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2002-12-02  6:42 UTC (permalink / raw)
  To: gdb-patches

With the intruduction of --args it is possible to construct empty
arguments that need to be transformed to ''.

Andreas.

2002-12-02  Andreas Schwab  <schwab@suse.de>

	* infcmd.c (construct_inferior_arguments): Handle empty arguments.

--- gdb/infcmd.c.~1.64.~	2002-12-02 11:00:11.000000000 +0100
+++ gdb/infcmd.c	2002-12-02 14:52:12.000000000 +0100
@@ -278,7 +278,7 @@ construct_inferior_arguments (struct gdb
 
       /* We over-compute the size.  It shouldn't matter.  */
       for (i = 0; i < argc; ++i)
-	length += 2 * strlen (argv[i]) + 1;
+	length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
 
       result = (char *) xmalloc (length);
       out = result;
@@ -288,11 +288,20 @@ construct_inferior_arguments (struct gdb
 	  if (i > 0)
 	    *out++ = ' ';
 
-	  for (cp = argv[i]; *cp; ++cp)
+	  /* Need to handle empty arguments specially.  */
+	  if (argv[i][0] == '\0')
 	    {
-	      if (strchr (special, *cp) != NULL)
-		*out++ = '\\';
-	      *out++ = *cp;
+	      *out++ = '\'';
+	      *out++ = '\'';
+	    }
+	  else
+	    {
+	      for (cp = argv[i]; *cp; ++cp)
+		{
+		  if (strchr (special, *cp) != NULL)
+		    *out++ = '\\';
+		  *out++ = *cp;
+		}
 	    }
 	}
       *out = '\0';

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-01-03 22:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-02  6:42 gdb --args mishandles empty arguments Andreas Schwab
2002-12-02 18:23 ` Daniel Jacobowitz
2002-12-02 18:46   ` Andrew Cagney
2002-12-02 20:00     ` Daniel Jacobowitz
2003-01-03 22:46       ` Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox