lineedit: remove SAVE_HISTORY bit, ->hist_file can be used as indicator

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-09-04 16:15:24 +02:00
parent bede215cf1
commit e45af7ad17
3 changed files with 8 additions and 14 deletions

View File

@ -1434,13 +1434,12 @@ typedef struct line_input_t {
# endif # endif
} line_input_t; } line_input_t;
enum { enum {
DO_HISTORY = 1 * (MAX_HISTORY > 0), DO_HISTORY = 1 * (MAX_HISTORY > 0),
SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_EDITING_SAVEHISTORY, TAB_COMPLETION = 2 * ENABLE_FEATURE_TAB_COMPLETION,
TAB_COMPLETION = 4 * ENABLE_FEATURE_TAB_COMPLETION, USERNAME_COMPLETION = 4 * ENABLE_FEATURE_USERNAME_COMPLETION,
USERNAME_COMPLETION = 8 * ENABLE_FEATURE_USERNAME_COMPLETION, VI_MODE = 8 * ENABLE_FEATURE_EDITING_VI,
VI_MODE = 0x10 * ENABLE_FEATURE_EDITING_VI, WITH_PATH_LOOKUP = 0x10,
WITH_PATH_LOOKUP = 0x20, FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
}; };
line_input_t *new_line_input_t(int flags) FAST_FUNC; line_input_t *new_line_input_t(int flags) FAST_FUNC;
/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */ /* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */

View File

@ -1402,8 +1402,6 @@ void save_history(line_input_t *st)
{ {
FILE *fp; FILE *fp;
if (!(st->flags & SAVE_HISTORY))
return;
if (!st->hist_file) if (!st->hist_file)
return; return;
if (st->cnt_history <= st->cnt_history_in_file) if (st->cnt_history <= st->cnt_history_in_file)
@ -1447,8 +1445,6 @@ static void save_history(char *str)
int fd; int fd;
int len, len2; int len, len2;
if (!(state->flags & SAVE_HISTORY))
return;
if (!state->hist_file) if (!state->hist_file)
return; return;
@ -2188,7 +2184,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
state = st ? st : (line_input_t*) &const_int_0; state = st ? st : (line_input_t*) &const_int_0;
#if MAX_HISTORY > 0 #if MAX_HISTORY > 0
# if ENABLE_FEATURE_EDITING_SAVEHISTORY # if ENABLE_FEATURE_EDITING_SAVEHISTORY
if ((state->flags & SAVE_HISTORY) && state->hist_file) if (state->hist_file)
if (state->cnt_history == 0) if (state->cnt_history == 0)
load_history(state); load_history(state);
# endif # endif

View File

@ -7820,7 +7820,7 @@ int hush_main(int argc, char **argv)
*/ */
#if ENABLE_FEATURE_EDITING #if ENABLE_FEATURE_EDITING
G.line_input_state = new_line_input_t(FOR_SHELL & ~SAVE_HISTORY); G.line_input_state = new_line_input_t(FOR_SHELL);
#endif #endif
/* Initialize some more globals to non-zero values */ /* Initialize some more globals to non-zero values */
@ -8105,7 +8105,6 @@ int hush_main(int argc, char **argv)
} }
if (hp) { if (hp) {
G.line_input_state->hist_file = hp; G.line_input_state->hist_file = hp;
G.line_input_state->flags |= SAVE_HISTORY;
//set_local_var(xasprintf("HISTFILE=%s", ...)); //set_local_var(xasprintf("HISTFILE=%s", ...));
} }
# if ENABLE_FEATURE_SH_HISTFILESIZE # if ENABLE_FEATURE_SH_HISTFILESIZE