prepare busybox-power 1.19.4power1 release
[busybox-power] / debian / patches / git-backports / 0003-lineedit-remove-SAVE_HISTORY-bit-hist_file-can-be-us.patch
1 From e45af7ad17c3f0ecaec1d761aa89cb4fd83afbc2 Mon Sep 17 00:00:00 2001
2 From: Denys Vlasenko <vda.linux@googlemail.com>
3 Date: Sun, 4 Sep 2011 16:15:24 +0200
4 Subject: [PATCH 3/3] lineedit: remove SAVE_HISTORY bit, ->hist_file can be
5  used as indicator
6
7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
8 ---
9  include/libbb.h  |   13 ++++++-------
10  libbb/lineedit.c |    6 +-----
11  shell/hush.c     |    3 +--
12  3 files changed, 8 insertions(+), 14 deletions(-)
13
14 diff --git a/include/libbb.h b/include/libbb.h
15 index 91343a9..1ca4489 100644
16 --- a/include/libbb.h
17 +++ b/include/libbb.h
18 @@ -1434,13 +1434,12 @@ typedef struct line_input_t {
19  # endif
20  } line_input_t;
21  enum {
22 -       DO_HISTORY = 1 * (MAX_HISTORY > 0),
23 -       SAVE_HISTORY = 2 * (MAX_HISTORY > 0) * ENABLE_FEATURE_EDITING_SAVEHISTORY,
24 -       TAB_COMPLETION = 4 * ENABLE_FEATURE_TAB_COMPLETION,
25 -       USERNAME_COMPLETION = 8 * ENABLE_FEATURE_USERNAME_COMPLETION,
26 -       VI_MODE = 0x10 * ENABLE_FEATURE_EDITING_VI,
27 -       WITH_PATH_LOOKUP = 0x20,
28 -       FOR_SHELL = DO_HISTORY | SAVE_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
29 +       DO_HISTORY       = 1 * (MAX_HISTORY > 0),
30 +       TAB_COMPLETION   = 2 * ENABLE_FEATURE_TAB_COMPLETION,
31 +       USERNAME_COMPLETION = 4 * ENABLE_FEATURE_USERNAME_COMPLETION,
32 +       VI_MODE          = 8 * ENABLE_FEATURE_EDITING_VI,
33 +       WITH_PATH_LOOKUP = 0x10,
34 +       FOR_SHELL        = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
35  };
36  line_input_t *new_line_input_t(int flags) FAST_FUNC;
37  /* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */
38 diff --git a/libbb/lineedit.c b/libbb/lineedit.c
39 index 0786f9a..603bbfc 100644
40 --- a/libbb/lineedit.c
41 +++ b/libbb/lineedit.c
42 @@ -1402,8 +1402,6 @@ void save_history(line_input_t *st)
43  {
44         FILE *fp;
45  
46 -       if (!(st->flags & SAVE_HISTORY))
47 -               return;
48         if (!st->hist_file)
49                 return;
50         if (st->cnt_history <= st->cnt_history_in_file)
51 @@ -1447,8 +1445,6 @@ static void save_history(char *str)
52         int fd;
53         int len, len2;
54  
55 -       if (!(state->flags & SAVE_HISTORY))
56 -               return;
57         if (!state->hist_file)
58                 return;
59  
60 @@ -2188,7 +2184,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
61         state = st ? st : (line_input_t*) &const_int_0;
62  #if MAX_HISTORY > 0
63  # if ENABLE_FEATURE_EDITING_SAVEHISTORY
64 -       if ((state->flags & SAVE_HISTORY) && state->hist_file)
65 +       if (state->hist_file)
66                 if (state->cnt_history == 0)
67                         load_history(state);
68  # endif
69 diff --git a/shell/hush.c b/shell/hush.c
70 index a9e2dd3..7a34f59 100644
71 --- a/shell/hush.c
72 +++ b/shell/hush.c
73 @@ -7820,7 +7820,7 @@ int hush_main(int argc, char **argv)
74          */
75  
76  #if ENABLE_FEATURE_EDITING
77 -       G.line_input_state = new_line_input_t(FOR_SHELL & ~SAVE_HISTORY);
78 +       G.line_input_state = new_line_input_t(FOR_SHELL);
79  #endif
80  
81         /* Initialize some more globals to non-zero values */
82 @@ -8105,7 +8105,6 @@ int hush_main(int argc, char **argv)
83                         }
84                         if (hp) {
85                                 G.line_input_state->hist_file = hp;
86 -                               G.line_input_state->flags |= SAVE_HISTORY;
87                                 //set_local_var(xasprintf("HISTFILE=%s", ...));
88                         }
89  #  if ENABLE_FEATURE_SH_HISTFILESIZE
90 -- 
91 1.7.6.1
92