2011-09-02 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / cli / cli-script.c
index cb54300c40f520863925198107a17c8249e1a802..66fa220b31004e825c766ecf6d45d747fb4a388d 100644 (file)
@@ -2,7 +2,7 @@
 
    Copyright (c) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
    1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010 Free Software Foundation, Inc.
+   2009, 2010, 2011 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -317,13 +317,13 @@ execute_user_command (struct cmd_list_element *c, char *args)
   static int user_call_depth = 0;
   extern int max_user_call_depth;
 
-  old_chain = setup_user_args (args);
-
   cmdlines = c->user_commands;
   if (cmdlines == 0)
     /* Null command */
     return;
 
+  old_chain = setup_user_args (args);
+
   if (++user_call_depth > max_user_call_depth)
     error (_("Max user call depth exceeded -- command aborted."));
 
@@ -1186,7 +1186,8 @@ read_command_lines (char *prompt_arg, int from_tty, int parse_commands,
       if (deprecated_readline_begin_hook)
        {
          /* Note - intentional to merge messages with no newline.  */
-         (*deprecated_readline_begin_hook) ("%s  %s\n", prompt_arg, END_MESSAGE);
+         (*deprecated_readline_begin_hook) ("%s  %s\n", prompt_arg,
+                                            END_MESSAGE);
        }
       else
        {
@@ -1479,7 +1480,8 @@ define_command (char *comname, int from_tty)
        hookc = 0;
       if (!hookc)
        {
-         warning (_("Your new `%s' command does not hook any existing command."),
+         warning (_("Your new `%s' command does not "
+                    "hook any existing command."),
                   comfull);
          if (!query (_("Proceed? ")))
            error (_("Not confirmed."));
@@ -1517,7 +1519,8 @@ define_command (char *comname, int from_tty)
           break;
         case CMD_POST_HOOK:
           hookc->hook_post  = newc;  /* Target gets hooked.  */
-          newc->hookee_post = hookc; /* We are marked as hooking target cmd.  */
+          newc->hookee_post = hookc; /* We are marked as hooking
+                                       target cmd.  */
           break;
         default:
           /* Should never come here as hookc would be 0.  */
@@ -1586,19 +1589,6 @@ source_cleanup_lines (void *args)
   source_file_name = p->old_file;
 }
 
-struct wrapped_read_command_file_args
-{
-  FILE *stream;
-};
-
-static void
-wrapped_read_command_file (struct ui_out *uiout, void *data)
-{
-  struct wrapped_read_command_file_args *args = data;
-
-  read_command_file (args->stream);
-}
-
 /* Used to implement source_command.  */
 
 void
@@ -1622,12 +1612,12 @@ script_from_file (FILE *stream, const char *file)
   error_pre_print = "";
 
   {
-    struct gdb_exception e;
-    struct wrapped_read_command_file_args args;
+    volatile struct gdb_exception e;
 
-    args.stream = stream;
-    e = catch_exception (uiout, wrapped_read_command_file, &args,
-                        RETURN_MASK_ERROR);
+    TRY_CATCH (e, RETURN_MASK_ERROR)
+      {
+       read_command_file (stream);
+      }
     switch (e.reason)
       {
       case 0:
@@ -1671,7 +1661,7 @@ show_user_1 (struct cmd_list_element *c, char *prefix, char *name,
     return;
   fprintf_filtered (stream, "User command \"%s%s\":\n", prefix, name);
 
-  print_command_lines (uiout, cmdlines, 1);
+  print_command_lines (current_uiout, cmdlines, 1);
   fputs_filtered ("\n", stream);
 }
 
This page took 0.027535 seconds and 4 git commands to generate.