constify do_set_command and do_show_command
authorTom Tromey <tromey@redhat.com>
Fri, 27 Dec 2013 05:31:32 +0000 (22:31 -0700)
committerTom Tromey <tromey@redhat.com>
Thu, 26 Jun 2014 15:14:17 +0000 (09:14 -0600)
This changes do_set_command and do_show_command to take const
arguments.

2014-06-26  Tom Tromey  <tromey@redhat.com>

* cli/cli-setshow.c (do_set_command): Make "arg" const.
(do_show_command): Make "arg" const.
* cli/cli-setshow.h (do_set_command, do_show_command): Update.

gdb/ChangeLog
gdb/cli/cli-setshow.c
gdb/cli/cli-setshow.h

index 49d41fc..2b26f63 100644 (file)
@@ -1,5 +1,11 @@
 2014-06-26  Tom Tromey  <tromey@redhat.com>
 
+       * cli/cli-setshow.c (do_set_command): Make "arg" const.
+       (do_show_command): Make "arg" const.
+       * cli/cli-setshow.h (do_set_command, do_show_command): Update.
+
+2014-06-26  Tom Tromey  <tromey@redhat.com>
+
        * record-full.c (record_full_get_bookmark): Make "args" const.
        (record_full_goto_bookmark): Make "raw_bookmark" const.
        * record.c (record_goto): New function.
index d14d361..61ff085 100644 (file)
@@ -148,7 +148,7 @@ is_unlimited_literal (const char *arg)
    other command).  C is the command list element for the command.  */
 
 void
-do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
+do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
 {
   /* A flag to indicate the option is changed or not.  */
   int option_changed = 0;
@@ -233,13 +233,15 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
        if (arg != NULL)
          {
            /* Clear trailing whitespace of filename.  */
-           char *ptr = arg + strlen (arg) - 1;
+           const char *ptr = arg + strlen (arg) - 1;
+           char *copy;
 
            while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
              ptr--;
-           *(ptr + 1) = '\0';
+           copy = xstrndup (arg, ptr + 1 - arg);
 
-           val = tilde_expand (arg);
+           val = tilde_expand (copy);
+           xfree (copy);
          }
        else
          val = xstrdup ("");
@@ -564,7 +566,7 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c)
    other command).  C is the command list element for the command.  */
 
 void
-do_show_command (char *arg, int from_tty, struct cmd_list_element *c)
+do_show_command (const char *arg, int from_tty, struct cmd_list_element *c)
 {
   struct ui_out *uiout = current_uiout;
   struct cleanup *old_chain;
index a68d610..7619bad 100644 (file)
@@ -23,9 +23,9 @@ struct cmd_list_element;
    Returns 1 for true, 0 for false, and -1 if invalid.  */
 extern int parse_cli_boolean_value (const char *arg);
 
-extern void do_set_command (char *arg, int from_tty,
+extern void do_set_command (const char *arg, int from_tty,
                            struct cmd_list_element *c);
-extern void do_show_command (char *arg, int from_tty,
+extern void do_show_command (const char *arg, int from_tty,
                             struct cmd_list_element *c);
 
 extern void cmd_show_list (struct cmd_list_element *list, int from_tty,