proc do_test { method } {
global binfile hex
- # The second arg is an empty string on purpose.
- set inferior_args { "first arg" "" "third-arg" "'" "\"" " " }
+ # The second arg is an empty string on purpose. The last argument
+ # must be the empty argument -- we once had a bug where that
+ # wouldn't work!
+ set inferior_args { "first arg" "" "third-arg" "'" "\"" " " "" }
clean_restart $binfile
}
# Now that we are stopped at main, inspect argc/argv.
- gdb_test "print argc" " = 7"
+ gdb_test "print argc" " = 8"
gdb_test "print argv\[0\]" " = $hex \".*\""
gdb_test "print argv\[1\]" " = $hex \"first arg\""
gdb_test "print argv\[2\]" " = $hex \"\""
gdb_test "print argv\[4\]" " = $hex \"'\""
gdb_test "print argv\[5\]" " = $hex \"\\\\\"\""
gdb_test "print argv\[6\]" " = $hex \" \""
+ gdb_test "print argv\[7\]" " = $hex \"\""
}
foreach_with_prefix method { "start" "starti" "run" "set args" } {
char *new_program_name = NULL;
int i;
- for (i = 0, p = own_buf + strlen ("vRun;"); *p; p = next_p, ++i)
+ for (i = 0, p = own_buf + strlen ("vRun;");
+ /* Exit condition is at the end of the loop. */;
+ p = next_p + 1, ++i)
{
next_p = strchr (p, ';');
if (next_p == NULL)
new_argv.push_back (full_arg);
xfree (arg);
}
- if (*next_p)
- next_p++;
+ if (*next_p == '\0')
+ break;
}
if (new_program_name == NULL)