]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
saved_command_line
authorPedro Alves <palves@redhat.com>
Tue, 7 Nov 2017 12:09:06 +0000 (12:09 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 7 Nov 2017 12:09:06 +0000 (12:09 +0000)
gdb/event-top.c
gdb/main.c
gdb/top.c
gdb/top.h

index 73771894c9a7afaee400f01c6fd14831ec886b49..1e84fdff6afacd73a42a1d883db0d0eb189d4ba5 100644 (file)
@@ -634,8 +634,8 @@ command_line_append_input_line (struct buffer *cmd_line_buffer, char *rl)
    If REPEAT, handle command repetitions:
 
      - If the input command line is NOT empty, the command returned is
-       copied into the global 'saved_command_line' var so that it can
-       be repeated later.
+       copied into the 'ui->saved_command_line' var so that it can be
+       repeated later.
 
      - OTOH, if the input command line IS empty, return the previously
        saved command instead of the empty input line.
@@ -671,9 +671,9 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
 #define SERVER_COMMAND_PREFIX "server "
   if (startswith (cmd, SERVER_COMMAND_PREFIX))
     {
-      /* Note that we don't set `saved_command_line'.  Between this
-         and the check in dont_repeat, this insures that repeating
-         will still do the right thing.  */
+      /* Note that we don't set `ui->saved_command_line'.  Between
+         this and the check in dont_repeat, this insures that
+         repeating will still do the right thing.  */
       return cmd + strlen (SERVER_COMMAND_PREFIX);
     }
 
@@ -713,7 +713,7 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
   for (p1 = cmd; *p1 == ' ' || *p1 == '\t'; p1++)
     ;
   if (repeat && *p1 == '\0')
-    return saved_command_line;
+    return ui->saved_command_line;
 
   /* Add command to history if appropriate.  Note: lines consisting
      solely of comments are also added to the command history.  This
@@ -728,9 +728,9 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
   /* Save into global buffer if appropriate.  */
   if (repeat)
     {
-      xfree (saved_command_line);
-      saved_command_line = xstrdup (cmd);
-      return saved_command_line;
+      xfree (ui->saved_command_line);
+      ui->saved_command_line = xstrdup (cmd);
+      return ui->saved_command_line;
     }
   else
     return cmd;
index 835ae24dcf0e8a66f63111f3f8eb5e3f14a86613..8fae552fd53c52059709222850a97c0d26641f5c 100644 (file)
@@ -522,8 +522,6 @@ captured_main_1 (struct captured_main_args *context)
   notice_open_fds ();
   save_original_signals_state ();
 
-  saved_command_line = (char *) xstrdup ("");
-
 #ifdef __MINGW32__
   /* Ensure stderr is unbuffered.  A Cygwin pty or pipe is implemented
      as a Windows pipe, and Windows buffers on pipes.  */
index f006c669a1082a9117476f79b294eb982e03a6c1..a7d70627375b69ce013c51230751b3f5577214c8 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -132,10 +132,6 @@ show_confirm (struct ui_file *file, int from_tty,
 
 char *current_directory;
 
-/* The last command line executed on the console.  Used for command
-   repetitions.  */
-char *saved_command_line;
-
 /* Nonzero if the current command is modified by "server ".  This
    affects things like recording into the command history, commands
    repeating on RETURN, etc.  This is so a user interface (emacs, GUI,
@@ -251,6 +247,7 @@ static int highest_ui_num;
 ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_)
   : next (nullptr),
     num (++highest_ui_num),
+    saved_command_line (xstrdup ("")),
     call_readline (nullptr),
     input_handler (nullptr),
     command_editing (0),
@@ -675,7 +672,10 @@ dont_repeat (void)
      thing read from stdin in line and don't want to delete it.  Null
      lines won't repeat here in any case.  */
   if (ui->instream == ui->stdin_stream)
-    *saved_command_line = 0;
+    {
+      xfree (ui->saved_command_line);
+      ui->saved_command_line = NULL;
+    }
 }
 
 /* Prevent dont_repeat from working, and return a cleanup that
@@ -1659,7 +1659,8 @@ dont_repeat_command (char *ignored, int from_tty)
 {
   /* Can't call dont_repeat here because we're not necessarily reading
      from stdin.  */
-  *saved_command_line = 0;
+  xfree (current_ui->saved_command_line);
+  current_ui->saved_command_line = NULL;
 }
 \f
 /* Functions to manipulate command line editing control variables.  */
index ab65ddb741b66dbd5106940beea9aab148a24635..d0f0e1f8ff728d6dba3e4c457a75d3de919a1403 100644 (file)
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -71,6 +71,10 @@ struct ui
      input until we have a whole command line.  */
   struct buffer line_buffer;
 
+  /* The last command line executed on the console.  Used for command
+     repetitions.  */
+  char *saved_command_line;
+
   /* The callback used by the event loop whenever an event is detected
      on the UI's input file descriptor.  This function incrementally
      builds a buffer where it accumulates the line read up to the
@@ -217,7 +221,6 @@ extern void ui_register_input_event_handler (struct ui *ui);
 extern void ui_unregister_input_event_handler (struct ui *ui);
 
 /* From top.c.  */
-extern char *saved_command_line;
 extern int confirm;
 extern int inhibit_gdbinit;
 extern const char gdbinit[];