diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2008-10-30 10:07:16 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2008-10-30 10:07:16 +0000 |
commit | c22261528c50f7760dd6a2e29314662b377eebb4 (patch) | |
tree | 19643dbbbe1d9df27aea0536cccd276b021fc14d /gdb/infcmd.c | |
parent | cb5220a03f6da7bfc09ce5b58d2b1a74eb1d306a (diff) | |
download | gdb-c22261528c50f7760dd6a2e29314662b377eebb4.zip gdb-c22261528c50f7760dd6a2e29314662b377eebb4.tar.gz gdb-c22261528c50f7760dd6a2e29314662b377eebb4.tar.bz2 |
* infcmd.c (construct_inferior_arguments): Handle newlines
specially.
testsuite/:
* gdb.base/args.exp: Add tests for newlines.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r-- | gdb/infcmd.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 8060af5..607d2b3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -270,7 +270,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 + 2 * (argv[i][0] == '\0'); + length += 3 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0'); result = (char *) xmalloc (length); out = result; @@ -290,9 +290,21 @@ construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv) { for (cp = argv[i]; *cp; ++cp) { - if (strchr (special, *cp) != NULL) - *out++ = '\\'; - *out++ = *cp; + if (*cp == '\n') + { + /* A newline cannot be quoted with a backslash (it + just disappears), only by putting it inside + quotes. */ + *out++ = '\''; + *out++ = '\n'; + *out++ = '\''; + } + else + { + if (strchr (special, *cp) != NULL) + *out++ = '\\'; + *out++ = *cp; + } } } } |