+2018-05-04  Tom Tromey  <tom@tromey.com>
+
+       * top.c (execute_command): Update.
+       * cli/cli-script.h (print_command_lines): Now varargs.
+       * cli/cli-script.c (print_command_lines): Now varargs.
+       (execute_control_command_1) <case while_control, case if_control>:
+       Update.
+
 2018-05-04  Tom Tromey  <tom@tromey.com>
 
        * tracepoint.c (all_tracepoint_actions): Rename from
 
    via while_command or if_command.  Inner levels of 'if' and 'while'
    are dealt with directly.  Therefore we can use these functions
    to determine whether the command has been printed already or not.  */
+ATTRIBUTE_PRINTF (1, 2)
 void
-print_command_trace (const char *cmd)
+print_command_trace (const char *fmt, ...)
 {
   int i;
 
   for (i=0; i < command_nest_depth; i++)
     printf_filtered ("+");
 
-  printf_filtered ("%s\n", cmd);
+  va_list args;
+
+  va_start (args, fmt);
+  vprintf_filtered (fmt, args);
+  va_end (args);
+  puts_filtered ("\n");
 }
 
 /* Helper for execute_control_command.  */
 
     case while_control:
       {
-       int len = strlen (cmd->line) + 7;
-       char *buffer = (char *) alloca (len);
-
-       xsnprintf (buffer, len, "while %s", cmd->line);
-       print_command_trace (buffer);
+       print_command_trace ("while %s", cmd->line);
 
        /* Parse the loop control expression for the while statement.  */
        std::string new_line = insert_user_defined_cmd_args (cmd->line);
 
     case if_control:
       {
-       int len = strlen (cmd->line) + 4;
-       char *buffer = (char *) alloca (len);
-
-       xsnprintf (buffer, len, "if %s", cmd->line);
-       print_command_trace (buffer);
+       print_command_trace ("if %s", cmd->line);
 
        /* Parse the conditional for the if statement.  */
        std::string new_line = insert_user_defined_cmd_args (cmd->line);
 
       line = p;
 
       /* If trace-commands is set then this will print this command.  */
-      print_command_trace (p);
+      print_command_trace ("%s", p);
 
       c = lookup_cmd (&cmd, cmdlist, "", 0, 1);
       p = cmd;