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.
#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);
}
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
/* 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;
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. */
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,
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),
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
{
/* 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. */
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
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[];