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);
rs->readline_func = readline_func;
rs->readline_opaque = opaque;
rs->read_password = read_password;
+ readline_restart(rs);
+}
+
+void readline_restart(ReadLineState *rs)
+{
rs->cmd_buf_index = 0;
rs->cmd_buf_size = 0;
}
{
ReadLineState *rs = qemu_mallocz(sizeof(*rs));
- if (!rs)
- return NULL;
-
rs->hist_entry = -1;
rs->mon = mon;
rs->completion_finder = completion_finder;