things like enabling/disabling buttons, etc... */
void (*deprecated_call_command_hook) (struct cmd_list_element * c,
- char *cmd, int from_tty);
+ const char *cmd, int from_tty);
/* Called when the current thread changes. Argument is thread id. */
Pass FROM_TTY as second argument to the defining function. */
void
-execute_command (char *p, int from_tty)
+execute_command (const char *p, int from_tty)
{
struct cleanup *cleanup_if_error;
struct cmd_list_element *c;
- char *line;
+ const char *line;
+ const char *cmd_start = p;
cleanup_if_error = make_bpstat_clear_actions_cleanup ();
scoped_value_mark cleanup = prepare_execute_command ();
if (*p)
{
const char *cmd = p;
- char *arg;
+ const char *arg;
int was_sync = current_ui->prompt_state == PROMPT_BLOCKED;
line = p;
print_command_trace (p);
c = lookup_cmd (&cmd, cmdlist, "", 0, 1);
- p = (char *) cmd;
+ p = cmd;
scoped_restore save_repeat_args
= make_scoped_restore (&repeat_arguments, nullptr);
- char *args_pointer = p;
+ const char *args_pointer = p;
/* Pass null arg rather than an empty one. */
arg = *p ? p : 0;
is_complete_command hack is testing for. */
/* Clear off trailing whitespace, except for set and complete
command. */
+ std::string without_whitespace;
if (arg
&& c->type != set_cmd
&& !is_complete_command (c))
{
- p = arg + strlen (arg) - 1;
+ const char *old_end = arg + strlen (arg) - 1;
+ p = old_end;
while (p >= arg && (*p == ' ' || *p == '\t'))
p--;
- *(p + 1) = '\0';
+ if (p != old_end)
+ {
+ without_whitespace = std::string (arg, p + 1);
+ arg = without_whitespace.c_str ();
+ }
}
/* If this command has been pre-hooked, run the hook first. */
/* If this command has been post-hooked, run the hook last. */
execute_cmd_post_hook (c);
- if (repeat_arguments != NULL)
+ if (repeat_arguments != NULL && cmd_start == saved_command_line)
{
gdb_assert (strlen (args_pointer) >= strlen (repeat_arguments));
- strcpy (args_pointer, repeat_arguments);
+ strcpy (saved_command_line + (args_pointer - cmd_start),
+ repeat_arguments);
}
}
temporarily set to true. */
std::string
-execute_command_to_string (char *p, int from_tty)
+execute_command_to_string (const char *p, int from_tty)
{
/* GDB_STDOUT should be better already restored during these
restoration callbacks. */
/* Called by do_setshow_command. */
static void
-set_history_size_command (char *args, int from_tty, struct cmd_list_element *c)
+set_history_size_command (const char *args,
+ int from_tty, struct cmd_list_element *c)
{
set_readline_history_size (history_size_setshow_var);
}
/* Called by do_setshow_command. An elaborate joke. */
void
-set_verbose (char *args, int from_tty, struct cmd_list_element *c)
+set_verbose (const char *args, int from_tty, struct cmd_list_element *c)
{
const char *cmdname = "verbose";
struct cmd_list_element *showcmd;
/* "set editing" command. */
static void
-set_editing (char *args, int from_tty, struct cmd_list_element *c)
+set_editing (const char *args, int from_tty, struct cmd_list_element *c)
{
change_line_handler (set_editing_cmd_var);
/* Update the control variable so that MI's =cmd-param-changed event
/* "set" command for the gdb_datadir configuration variable. */
static void
-set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
+set_gdb_datadir (const char *args, int from_tty, struct cmd_list_element *c)
{
set_gdb_data_directory (staged_gdb_datadir);
observer_notify_gdb_datadir_changed ();
}
static void
-set_history_filename (char *args, int from_tty, struct cmd_list_element *c)
+set_history_filename (const char *args,
+ int from_tty, struct cmd_list_element *c)
{
/* We include the current directory so that if the user changes
directories the file written will be the same as the one