From: Andreas Schwab <schwab@suse.de>
To: gdb-patches@sources.redhat.com
Subject: gdb --args mishandles empty arguments
Date: Mon, 02 Dec 2002 06:42:00 -0000 [thread overview]
Message-ID: <jeel90eb3p.fsf@sykes.suse.de> (raw)
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."
next reply other threads:[~2002-12-02 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-02 6:42 Andreas Schwab [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jeel90eb3p.fsf@sykes.suse.de \
--to=schwab@suse.de \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox