qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] monitor: Provide empty command as final history ent


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH] monitor: Provide empty command as final history entry
Date: Sun, 08 Mar 2009 16:26:47 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

Provide an empty line as last entry in command line history, just like
bash e.g. does.

Signed-off-by: Jan Kiszka <address@hidden>
---

 readline.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/readline.c b/readline.c
index 9c4b68b..9c500f1 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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]