Add previous_saved_command_line to allow a command to repeat a previous command.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 20 Apr 2019 12:02:29 +0000 (14:02 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 31 May 2019 15:10:08 +0000 (17:10 +0200)
commit68bb5386b84af4031175bf186269eb6b54b8611d
treeb3b9b003d4b9f692f2437a7afb86cd4f7efd1869
parenta0486bac41d6ce47f27795a5abbca5cc53ddba00
Add previous_saved_command_line to allow a command to repeat a previous command.

Currently, a previous command can be repeated when the user types an
empty line.  This is implemented in handle_line_of_input by
returning saved_command_line in case an empty line has been input.

If we want a command to repeat the previous command, we need to save
the previous saved_command_line, as when a command runs, the saved_command_line
already contains the current command line of the command being executed.

As suggested by Tom, the previous_saved_command_line is made static.
At the same time, saved_command_line is also made static.
The support functions/variables for the repeat command logic are now all
located inside top.c.

gdb/ChangeLog
2019-05-31  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* top.h (saved_command_line): Remove declaration.
* top.c (previous_saved_command_line, previous_repeat_arguments):
New variables.
(saved_command_line): Make static, define together with other
'repeat variables'.
(dont_repeat): Clear repeat_arguments.
(repeat_previous, get_saved_command_line, save_command_line):
New functions.
(gdb_init): Initialize saved_command_line
and previous_saved_command_line.
* main.c (captured_main_1): Remove saved_command_line initialization.
* event-top.c (handle_line_of_input): Update to use
the new 'repeat' related functions instead of direct access to
saved_command_line.
* command.h (repeat_previous, get_saved_command_line,
save_command_line): New declarations.
(dont_repeat): Add comment.
gdb/ChangeLog
gdb/command.h
gdb/event-top.c
gdb/main.c
gdb/top.c
gdb/top.h