specially.
testsuite/:
* gdb.base/args.exp: Add tests for newlines.
+2008-10-30 Andreas Schwab <schwab@suse.de>
+
+ * infcmd.c (construct_inferior_arguments): Handle newlines
+ specially.
+
2008-10-30 Joel Brobecker <brobecker@adacore.com>
* breakpoint.h (enum bptype): Delete bp_catch_exec.
/* 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;
{
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;
+ }
}
}
}
+2008-10-30 Andreas Schwab <schwab@suse.de>
+
+ * gdb.base/args.exp: Add tests for newlines.
+
2008-10-30 Joel Brobecker <brobecker@adacore.com>
gdb.base/foll-exec.exp: Update the expected output of a couple
set GDBFLAGS "-nx --args $binfile 1 '' '' 3"
args_test "two empty (with single quotes)" {{1} {''} {''} {3}}
+# try with arguments containing literal newlines.
+
+set GDBFLAGS "-nx --args $binfile 1 {\n} 3"
+args_test "one newline" {{1} {\\n} {3}}
+
+set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3"
+args_test "two newlines" {{1} {\\n} {\\n} {3}}
+
set GDBFLAGS $old_gdbflags