aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-02 17:27:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-02 17:27:28 +0200
commit84ea60ed65f6ea6fd3b2170e44bbff5de410a78b (patch)
tree54837341ed6ed021d9b20400b8a8a5aea7bd3b62 /libbb
parentdd4b446f76736c0a13a61a38d7d816b6e6b5fca2 (diff)
downloadbusybox-w32-84ea60ed65f6ea6fd3b2170e44bbff5de410a78b.tar.gz
busybox-w32-84ea60ed65f6ea6fd3b2170e44bbff5de410a78b.tar.bz2
busybox-w32-84ea60ed65f6ea6fd3b2170e44bbff5de410a78b.zip
line editing: make read_line_input() not take timeout param
It's almost always -1. function old new delta read_line_input 3902 3912 +10 new_line_input_t 24 31 +7 pgetc 583 585 +2 save_command_ps_at_cur_history 80 78 -2 read_line 76 74 -2 fgetc_interactive 246 244 -2 addLines 84 82 -2 doCommands 2226 2222 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/5 up/down: 19/-12) Total: 7 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index e5721b063..0106093a1 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1267,6 +1267,7 @@ line_input_t* FAST_FUNC new_line_input_t(int flags)
1267{ 1267{
1268 line_input_t *n = xzalloc(sizeof(*n)); 1268 line_input_t *n = xzalloc(sizeof(*n));
1269 n->flags = flags; 1269 n->flags = flags;
1270 n->timeout = -1;
1270#if MAX_HISTORY > 0 1271#if MAX_HISTORY > 0
1271 n->max_history = MAX_HISTORY; 1272 n->max_history = MAX_HISTORY;
1272#endif 1273#endif
@@ -2130,7 +2131,7 @@ enum {
2130 * Backspace deletes last matched char. 2131 * Backspace deletes last matched char.
2131 * Control keys exit search and return to normal editing (at current history line). 2132 * Control keys exit search and return to normal editing (at current history line).
2132 */ 2133 */
2133static int32_t reverse_i_search(void) 2134static int32_t reverse_i_search(int timeout)
2134{ 2135{
2135 char match_buf[128]; /* for user input */ 2136 char match_buf[128]; /* for user input */
2136 char read_key_buffer[KEYCODE_BUFFER_SIZE]; 2137 char read_key_buffer[KEYCODE_BUFFER_SIZE];
@@ -2152,8 +2153,8 @@ static int32_t reverse_i_search(void)
2152 int h; 2153 int h;
2153 unsigned match_buf_len = strlen(match_buf); 2154 unsigned match_buf_len = strlen(match_buf);
2154 2155
2155//FIXME: correct timeout? 2156//FIXME: correct timeout? (i.e. count it down?)
2156 ic = lineedit_read_key(read_key_buffer, -1); 2157 ic = lineedit_read_key(read_key_buffer, timeout);
2157 2158
2158 switch (ic) { 2159 switch (ic) {
2159 case CTRL('R'): /* searching for the next match */ 2160 case CTRL('R'): /* searching for the next match */
@@ -2256,9 +2257,10 @@ static int32_t reverse_i_search(void)
2256 * (in both cases the cursor remains on the input line, '\n' is not printed) 2257 * (in both cases the cursor remains on the input line, '\n' is not printed)
2257 * >0 length of input string, including terminating '\n' 2258 * >0 length of input string, including terminating '\n'
2258 */ 2259 */
2259int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) 2260int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize)
2260{ 2261{
2261 int len; 2262 int len;
2263 int timeout;
2262#if ENABLE_FEATURE_TAB_COMPLETION 2264#if ENABLE_FEATURE_TAB_COMPLETION
2263 smallint lastWasTab = 0; 2265 smallint lastWasTab = 0;
2264#endif 2266#endif
@@ -2297,8 +2299,15 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2297 maxsize = MAX_LINELEN; 2299 maxsize = MAX_LINELEN;
2298 S.maxsize = maxsize; 2300 S.maxsize = maxsize;
2299 2301
2300 /* With zero flags, no other fields are ever used */ 2302 timeout = -1;
2301 state = st ? st : (line_input_t*) &const_int_0; 2303 /* Make state->flags == 0 if st is NULL.
2304 * With zeroed flags, no other fields are ever referenced.
2305 */
2306 state = (line_input_t*) &const_int_0;
2307 if (st) {
2308 state = st;
2309 timeout = st->timeout;
2310 }
2302#if MAX_HISTORY > 0 2311#if MAX_HISTORY > 0
2303# if ENABLE_FEATURE_EDITING_SAVEHISTORY 2312# if ENABLE_FEATURE_EDITING_SAVEHISTORY
2304 if (state->hist_file) 2313 if (state->hist_file)
@@ -2510,7 +2519,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2510 } 2519 }
2511#if ENABLE_FEATURE_REVERSE_SEARCH 2520#if ENABLE_FEATURE_REVERSE_SEARCH
2512 case CTRL('R'): 2521 case CTRL('R'):
2513 ic = ic_raw = reverse_i_search(); 2522 ic = ic_raw = reverse_i_search(timeout);
2514 goto again; 2523 goto again;
2515#endif 2524#endif
2516 2525