Switch the license of all .c files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / cli / cli-setshow.c
index 4b01e62e16e0ba4b819527ea28420c8f97334106..54f2bd41a5b48ec40cb38a3706961f4edc597cd4 100644 (file)
@@ -1,10 +1,10 @@
 /* Handle set and show GDB commands.
 
-   Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (c) 2000, 2001, 2002, 2003, 2007 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 +13,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., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "readline/tilde.h"
@@ -180,17 +178,25 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
            xfree (*(char **) c->var);
          *(char **) c->var = savestring (arg, strlen (arg));
          break;
-       case var_filename:
        case var_optional_filename:
          if (arg == NULL)
-           {
-             if (c->var_type == var_optional_filename)
-               arg = "";
-             else
-               error_no_arg (_("filename to set it to."));
-           }
+           arg = "";
+         if (*(char **) c->var != NULL)
+           xfree (*(char **) c->var);
+         *(char **) c->var = savestring (arg, strlen (arg));
+         break;
+       case var_filename:
+         if (arg == NULL)
+           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:
@@ -300,12 +306,8 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
       switch (c->var_type)
        {
        case var_string:
-         {
-           unsigned char *p;
-
-           if (*(unsigned char **) c->var)
-             fputstr_filtered (*(unsigned char **) c->var, '"', stb->stream);
-         }
+         if (*(char **) c->var)
+           fputstr_filtered (*(char **) c->var, '"', stb->stream);
          break;
        case var_string_noescape:
        case var_optional_filename:
@@ -408,14 +410,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.026785 seconds and 4 git commands to generate.