2009-01-23 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / cli / cli-setshow.c
index ac8bdb7ad94767e701d139deb5dabbf5a161cd78..206a55d8f0b4dbd68d038f885085dd4f7f58b957 100644 (file)
@@ -1,10 +1,11 @@
 /* Handle set and show GDB commands.
 
-   Copyright (c) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (c) 2000, 2001, 2002, 2003, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -13,9 +14,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "readline/tilde.h"
@@ -192,6 +191,13 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
            error_no_arg (_("filename to set it to."));
          if (*(char **) c->var != NULL)
            xfree (*(char **) c->var);
+         {
+           /* Clear trailing whitespace of filename.  */
+           char *ptr = arg + strlen (arg) - 1;
+           while (ptr >= arg && (*ptr == ' ' || *ptr == '\t'))
+             ptr--;
+           *(ptr + 1) = '\0';
+         }
          *(char **) c->var = tilde_expand (arg);
          break;
        case var_boolean:
@@ -226,6 +232,11 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
            error_no_arg (_("integer to set it to."));
          *(int *) c->var = parse_and_eval_long (arg);
          break;
+       case var_zuinteger:
+         if (arg == NULL)
+           error_no_arg (_("integer to set it to."));
+         *(unsigned int *) c->var = parse_and_eval_long (arg);
+         break;
        case var_enum:
          {
            int i;
@@ -237,16 +248,22 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
            /* if no argument was supplied, print an informative error message */
            if (arg == NULL)
              {
-               char msg[1024];
-               strcpy (msg, "Requires an argument. Valid arguments are ");
+               char *msg;
+               int msg_len = 0;
+               for (i = 0; c->enums[i]; i++)
+                 msg_len += strlen (c->enums[i]) + 2;
+
+               msg = xmalloc (msg_len);
+               *msg = '\0';
+               make_cleanup (xfree, msg);
+               
                for (i = 0; c->enums[i]; i++)
                  {
                    if (i != 0)
                      strcat (msg, ", ");
                    strcat (msg, c->enums[i]);
                  }
-               strcat (msg, ".");
-               error (("%s"), msg);
+               error (_("Requires an argument. Valid arguments are %s."), msg);
              }
 
            p = strchr (arg, ' ');
@@ -339,6 +356,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
              break;
            }
          /* else fall through */
+       case var_zuinteger:
        case var_zinteger:
          fprintf_filtered (stb->stream, "%u", *(unsigned int *) c->var);
          break;
@@ -405,14 +423,17 @@ cmd_show_list (struct cmd_list_element *list, int from_tty, char *prefix)
          /* Close the tuple.  */
          do_cleanups (optionlist_chain);
        }
-      if (list->type == show_cmd)
+      else
        {
          struct cleanup *option_chain
            = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
          ui_out_text (uiout, prefix);
          ui_out_field_string (uiout, "name", list->name);
          ui_out_text (uiout, ":  ");
-         do_setshow_command ((char *) NULL, from_tty, list);
+         if (list->type == show_cmd)
+           do_setshow_command ((char *) NULL, from_tty, list);
+         else
+           cmd_func (list, NULL, from_tty);
           /* Close the tuple.  */
          do_cleanups (option_chain);
        }
This page took 0.041345 seconds and 4 git commands to generate.