diff options
author | 2009-03-13 15:02:28 +0000 | |
---|---|---|
committer | 2009-03-13 15:02:28 +0000 | |
commit | 5b0d272717ac6a1a2bc382f591a6a0a30ee52774 (patch) | |
tree | 979fd42ed43c727dd3843b63acf20e14601171f4 /readline.c | |
parent | Add and use remaining #defines for PCI device IDs (Stuart Brady) (diff) | |
download | qemu-kvm-5b0d272717ac6a1a2bc382f591a6a0a30ee52774.tar.gz qemu-kvm-5b0d272717ac6a1a2bc382f591a6a0a30ee52774.tar.bz2 qemu-kvm-5b0d272717ac6a1a2bc382f591a6a0a30ee52774.zip |
monitor: Provide empty command as final history entry (Jan Kiszka)
Provide an empty line as last entry in command line history, just like
bash e.g. does.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6842 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'readline.c')
-rw-r--r-- | readline.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/readline.c b/readline.c index 9c4b68b53..9c500f1fe 100644 --- a/readline.c +++ b/readline.c @@ -196,12 +196,14 @@ static void readline_up_char(ReadLineState *rs) static void readline_down_char(ReadLineState *rs) { - if (rs->hist_entry == READLINE_MAX_CMDS - 1 || rs->hist_entry == -1) - return; - if (rs->history[++rs->hist_entry] != NULL) { + if (rs->hist_entry == -1) + return; + if (rs->hist_entry < READLINE_MAX_CMDS - 1 && + rs->history[++rs->hist_entry] != NULL) { pstrcpy(rs->cmd_buf, sizeof(rs->cmd_buf), rs->history[rs->hist_entry]); } else { + rs->cmd_buf[0] = 0; rs->hist_entry = -1; } rs->cmd_buf_index = rs->cmd_buf_size = strlen(rs->cmd_buf); |