aboutsummaryrefslogtreecommitdiff
path: root/readline.c
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-17 20:31:43 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-12-17 20:31:43 +0000
commitccf7aa52aad631e1db1bbda8f3a3784ef3cd182b (patch)
tree8c270eaf236a4fc9087d85ed559b6674b20d384a /readline.c
parent6240d6467077a12c24878bab645d8e2983e4975a (diff)
downloadqemu-ccf7aa52aad631e1db1bbda8f3a3784ef3cd182b.zip
qemu-ccf7aa52aad631e1db1bbda8f3a3784ef3cd182b.tar.gz
qemu-ccf7aa52aad631e1db1bbda8f3a3784ef3cd182b.tar.bz2
Handle history additions properly, by Andreas Schwab.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3835 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'readline.c')
-rw-r--r--readline.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/readline.c b/readline.c
index f690f6e..81bc491 100644
--- a/readline.c
+++ b/readline.c
@@ -267,7 +267,7 @@ static void term_hist_add(const char *cmdline)
new_entry = hist_entry;
/* Put this entry at the end of history */
memmove(&term_history[idx], &term_history[idx + 1],
- &term_history[TERM_MAX_CMDS] - &term_history[idx + 1]);
+ (TERM_MAX_CMDS - idx + 1) * sizeof(char *));
term_history[TERM_MAX_CMDS - 1] = NULL;
for (; idx < TERM_MAX_CMDS; idx++) {
if (term_history[idx] == NULL)
@@ -280,7 +280,7 @@ static void term_hist_add(const char *cmdline)
/* Need to get one free slot */
free(term_history[0]);
memcpy(term_history, &term_history[1],
- &term_history[TERM_MAX_CMDS] - &term_history[1]);
+ (TERM_MAX_CMDS - 1) * sizeof(char *));
term_history[TERM_MAX_CMDS - 1] = NULL;
idx = TERM_MAX_CMDS - 1;
}