OSDN Git Service

2005-02-20 Andrew Cagney <cagney@gnu.org>
authorAndrew Cagney <cagney@redhat.com>
Mon, 21 Feb 2005 03:25:56 +0000 (03:25 +0000)
committerAndrew Cagney <cagney@redhat.com>
Mon, 21 Feb 2005 03:25:56 +0000 (03:25 +0000)
* cli/cli-decode.c (add_setshow_optional_filename_cmd): New
function.
* cli/cli-setshow.c (deprecated_show_value_hack)
(do_setshow_command): Handle var_optional_filename.
* command.h (enum var_types): Add var_optional_filename.
(add_setshow_optional_filename_cmd): Declare.
* infcmd.c (notice_args_read): Use.

gdb/ChangeLog
gdb/cli/cli-decode.c
gdb/cli/cli-setshow.c
gdb/command.h
gdb/infcmd.c

index c2eccfe..4ec29ae 100644 (file)
@@ -1,5 +1,13 @@
 2005-02-20  Andrew Cagney  <cagney@gnu.org>
 
+       * cli/cli-decode.c (add_setshow_optional_filename_cmd): New
+       function.
+       * cli/cli-setshow.c (deprecated_show_value_hack) 
+       (do_setshow_command): Handle var_optional_filename.
+       * command.h (enum var_types): Add var_optional_filename.
+       (add_setshow_optional_filename_cmd): Declare.
+       * infcmd.c (notice_args_read): Use.
+
        * symfile-mem.c (symbol_file_add_from_memory): Pass
        target_read_memory to bfd_elf_bfd_from_remote_memory.
        (do_target_read_memory): Delete.
index ec2f734..f2a533c 100644 (file)
@@ -536,6 +536,25 @@ add_setshow_string_noescape_cmd (char *name, enum command_class class,
 }
 
 /* Add element named NAME to both the set and show command LISTs (the
+   list for set/show or some sublist thereof).  */
+void
+add_setshow_optional_filename_cmd (char *name, enum command_class class,
+                                  char **var,
+                                  const char *set_doc, const char *show_doc,
+                                  const char *help_doc,
+                                  cmd_sfunc_ftype *set_func,
+                                  show_value_ftype *show_func,
+                                  struct cmd_list_element **set_list,
+                                  struct cmd_list_element **show_list)
+{
+  add_setshow_cmd_full (name, class, var_optional_filename, var,
+                       set_doc, show_doc, help_doc,
+                       set_func, show_func,
+                       set_list, show_list,
+                       NULL, NULL);
+}
+
+/* Add element named NAME to both the set and show command LISTs (the
    list for set/show or some sublist thereof).  CLASS is as in
    add_cmd.  VAR is address of the variable which will contain the
    value.  SET_DOC and SHOW_DOC are the documentation strings.  */
index 993ca5c..15c664d 100644 (file)
@@ -102,6 +102,7 @@ deprecated_show_value_hack (struct ui_file *ignore_file,
     {
     case var_string:
     case var_string_noescape:
+    case var_optional_filename:
     case var_filename:
     case var_enum:
       printf_filtered ((" is \"%s\".\n"), value);
@@ -177,8 +178,14 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
          *(char **) c->var = savestring (arg, strlen (arg));
          break;
        case var_filename:
+       case var_optional_filename:
          if (arg == NULL)
-           error_no_arg (_("filename to set it to."));
+           {
+             if (c->var_type == var_optional_filename)
+               arg = "";
+             else
+               error_no_arg (_("filename to set it to."));
+           }
          if (*(char **) c->var != NULL)
            xfree (*(char **) c->var);
          *(char **) c->var = tilde_expand (arg);
@@ -298,6 +305,7 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
          }
          break;
        case var_string_noescape:
+       case var_optional_filename:
        case var_filename:
        case var_enum:
          if (*(char **) c->var)
index dcebe49..cace34f 100644 (file)
@@ -80,8 +80,11 @@ typedef enum var_types
     /* String which stores what the user types verbatim.
        *VAR is a malloc'd string, or NULL if the string is empty.  */
     var_string_noescape,
-    /* String which stores a filename.
-       *VAR is a malloc'd string, or NULL if the string is empty.  */
+    /* String which stores a filename.  (*VAR) is a malloc'd string,
+       or "" if the string was empty.  */
+    var_optional_filename,
+    /* String which stores a filename.  (*VAR) is a malloc'd
+       string.  */
     var_filename,
     /* ZeroableInteger.  *VAR is an int.  Like Unsigned Integer except
        that zero really means zero.  */
@@ -301,6 +304,17 @@ extern void add_setshow_string_noescape_cmd (char *name,
                                             struct cmd_list_element **set_list,
                                             struct cmd_list_element **show_list);
 
+extern void add_setshow_optional_filename_cmd (char *name,
+                                              enum command_class class,
+                                              char **var,
+                                              const char *set_doc,
+                                              const char *show_doc,
+                                              const char *help_doc,
+                                              cmd_sfunc_ftype *set_func,
+                                              show_value_ftype *show_func,
+                                              struct cmd_list_element **set_list,
+                                              struct cmd_list_element **show_list);
+
 extern void add_setshow_integer_cmd (char *name,
                                     enum command_class class,
                                     unsigned int *var,
index 807db80..f04dc8a 100644 (file)
@@ -250,8 +250,10 @@ notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
 
 /* Notice when `show args' is run.  */
 static void
-notice_args_read (char *args, int from_tty, struct cmd_list_element *c)
+notice_args_read (struct ui_file *file, int from_tty,
+                 struct cmd_list_element *c, const char *value)
 {
+  deprecated_show_value_hack (file, from_tty, c, value);
   /* Might compute the value.  */
   get_inferior_args ();
 }
@@ -1980,15 +1982,14 @@ _initialize_infcmd (void)
               _("Set terminal for future runs of program being debugged."));
   set_cmd_completer (c, filename_completer);
 
-  c = add_set_cmd ("args", class_run, var_string_noescape,
-                  (char *) &inferior_args,
-                  "Set argument list to give program being debugged when it is started.\n\
-Follow this command with any number of args, to be passed to the program.",
-                  &setlist);
-  set_cmd_completer (c, filename_completer);
-  set_cmd_sfunc (c, notice_args_set);
-  c = deprecated_add_show_from_set (c, &showlist);
-  set_cmd_sfunc (c, notice_args_read);
+  add_setshow_optional_filename_cmd ("args", class_run,
+                                    &inferior_args, _("\
+Set argument list to give program being debugged when it is started."), _("\
+Show argument list to give program being debugged when it is started."), _("\
+Follow this command with any number of args, to be passed to the program."),
+                                    notice_args_set,
+                                    notice_args_read,
+                                    &setlist, &showlist);
 
   c = add_cmd ("environment", no_class, environment_info, _("\
 The environment to give the program, or one variable's value.\n\