diff options
author | Andreas Schwab <schwab@suse.de> | 2002-12-03 12:25:11 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 2002-12-03 12:25:11 +0000 |
commit | 8f232e83cac7bf992180d20c08d4630eb7dc6e11 (patch) | |
tree | 6a2e77053fc65cedb3f6280fe62bc14904866bfe /gdb/infcmd.c | |
parent | 5e4d7e4a97cb536dc6cbf725525ea04854c32591 (diff) | |
download | gdb-8f232e83cac7bf992180d20c08d4630eb7dc6e11.tar.gz |
* infcmd.c (construct_inferior_arguments): Handle empty arguments.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r-- | gdb/infcmd.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 6b4d7ae367a..2c631bcb5d2 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -278,7 +278,7 @@ construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv) /* 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 gdbarch *gdbarch, int argc, char **argv) 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'; |