diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2002-12-03 12:25:11 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2002-12-03 12:25:11 +0000 |
commit | 03c6228e785151dba135f416c73b34902d8a356b (patch) | |
tree | 1d75232c10578a27494b046d1a219aed2e468edd /gdb/infcmd.c | |
parent | 6297c1fedec95880c039425d1d8f2919e1a8c410 (diff) | |
download | gdb-03c6228e785151dba135f416c73b34902d8a356b.zip gdb-03c6228e785151dba135f416c73b34902d8a356b.tar.gz gdb-03c6228e785151dba135f416c73b34902d8a356b.tar.bz2 |
* 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 6b4d7ae..2c631bc 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'; |