This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
gdb --args mishandles empty arguments
- From: Andreas Schwab <schwab at suse dot de>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 02 Dec 2002 15:42:18 +0100
- Subject: gdb --args mishandles empty arguments
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."