libbb/lineedit: fix the case when we configured history to have 0 lines

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-09-27 02:48:53 +02:00
parent e74aaf9385
commit db9c57eed1
2 changed files with 21 additions and 19 deletions

View File

@ -1290,7 +1290,7 @@ static void remember_in_history(char *str)
/* i <= MAX_HISTORY */
state->cur_history = i;
state->cnt_history = i;
#if ENABLE_FEATURE_EDITING_SAVEHISTORY
# if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
if ((state->flags & SAVE_HISTORY) && state->hist_file)
save_history(str);
# endif
@ -1688,6 +1688,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
/* With null flags, no other fields are ever used */
state = st ? st : (line_input_t*) &const_int_0;
#if MAX_HISTORY > 0
# if ENABLE_FEATURE_EDITING_SAVEHISTORY
if ((state->flags & SAVE_HISTORY) && state->hist_file)
if (state->cnt_history == 0)
@ -1695,6 +1696,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
# endif
if (state->flags & DO_HISTORY)
state->cur_history = state->cnt_history;
#endif
/* prepare before init handlers */
cmdedit_y = 0; /* quasireal y, not true if line > xt*yt */

View File

@ -13317,7 +13317,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
}
if (sflag || minusc == NULL) {
#if ENABLE_FEATURE_EDITING_SAVEHISTORY
#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
if (iflag) {
const char *hp = lookupvar("HISTFILE");
if (hp)