From 03c6228e785151dba135f416c73b34902d8a356b Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 3 Dec 2002 12:25:11 +0000 Subject: [PATCH] * infcmd.c (construct_inferior_arguments): Handle empty arguments. --- gdb/ChangeLog | 4 ++++ gdb/infcmd.c | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2e9ec72126d..b740a6c1836 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2002-12-03 Andreas Schwab + + * infcmd.c (construct_inferior_arguments): Handle empty arguments. + 2002-12-02 Adam Fedor Klee Dienes 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'; -- 2.30.2