diff --git a/src/cmdbuf.c b/src/cmdbuf.c index 0269179..b01b362 100644 --- a/src/cmdbuf.c +++ b/src/cmdbuf.c @@ -210,12 +210,16 @@ void cmdbuf_reset(void) cur = tail = 0; } -void cmdbuf_store(char *cmd_buf) +void cmdbuf_trunc(char *cmd_buf) { - int prev_count = (cmdqueue_count - 1) % MAX_CMDQUEUE_LEN; cmd_buf[tail] = '\0'; /* Reset the cmdbuf */ cur = tail = 0; +} + +void cmdbuf_store(const char *cmd_buf) +{ + int prev_count = (cmdqueue_count - 1) % MAX_CMDQUEUE_LEN; if (cmd_buf[0] == '\0') return; diff --git a/src/cmdbuf.h b/src/cmdbuf.h index 4a27955..dcaded0 100644 --- a/src/cmdbuf.h +++ b/src/cmdbuf.h @@ -12,8 +12,9 @@ int cmdbuf_move(char *cmd_buf, int direction); void cmdbuf_delch(char *cmd_buf); int cmdbuf_bksp(char *cmd_buf); void cmdbuf_clear(char *cmd_buf); +void cmdbuf_trunc(char *cmd_buf); char cmdbuf_putch(char *cmd_buf, unsigned int buf_size, char ch, unsigned short flag); -void cmdbuf_store(char *cmd_buf); +void cmdbuf_store(const char *cmd_buf); void cmdbuf_reset(void); void cmdbuf_init(void); diff --git a/src/command.c b/src/command.c index 3ff90ef..16c6360 100644 --- a/src/command.c +++ b/src/command.c @@ -703,7 +703,7 @@ static void prompt_for_and_get_cmd(void) } while (key != KEY_ENTER); if (need_store) - cmdbuf_store(conbuf); + cmdbuf_trunc(conbuf); else cmdbuf_reset(); strcpy(cmd_line, conbuf); @@ -727,6 +727,8 @@ static void prompt_for_and_get_cmd(void) memmove(cmd_line, cmd_line + len1, len - len1 + 1); len -= len1; } + if (need_store) + cmdbuf_store(cmd_line); parse_cmd_line(); cputs("\r\n"); }