summaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorDenys Vlasenko2011-02-08 05:07:02 +0100
committerDenys Vlasenko2011-02-08 05:07:02 +0100
commit66c5b12dbf85142eea257ba6047191d7c0ee43f3 (patch)
tree913ab2ca77d8a90bb48e75de12435d2776805da5 /libbb/lineedit.c
parentdd807c16f99b4ead544289b83c88cc2488542f72 (diff)
downloadbusybox-66c5b12dbf85142eea257ba6047191d7c0ee43f3.zip
busybox-66c5b12dbf85142eea257ba6047191d7c0ee43f3.tar.gz
ash: fix TMOUT not restoring tty attributes
function old new delta pgetc 420 500 +80 readtoken1 3202 3239 +37 read_line_input 3316 3337 +21 udhcpc_main 2610 2630 +20 file_get 266 272 +6 expandarg 958 963 +5 localcmd 257 259 +2 addLines 85 87 +2 read_line 94 95 +1 ed_main 2540 2541 +1 timed_out 1 - -1 lineedit_read_key 256 255 -1 alrm_sighandler 44 - -44 cmdloop 539 434 -105 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 10/2 up/down: 175/-151) Total: 24 bytes text data bss dec hex filename 887379 936 17200 905515 dd12b busybox_old 887411 936 17192 905539 dd143 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 5dd835c..afd28b7 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1809,10 +1809,9 @@ static void win_changed(int nsig)
errno = sv_errno;
}
-static int lineedit_read_key(char *read_key_buffer)
+static int lineedit_read_key(char *read_key_buffer, int timeout)
{
int64_t ic;
- int timeout = -1;
#if ENABLE_UNICODE_SUPPORT
char unicode_buf[MB_CUR_MAX + 1];
int unicode_idx = 0;
@@ -1917,7 +1916,7 @@ static int isrtl_str(void)
* 0 on ctrl-C (the line entered is still returned in 'command'),
* >0 length of input string, including terminating '\n'
*/
-int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st)
+int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout)
{
int len;
#if ENABLE_FEATURE_TAB_COMPLETION
@@ -1991,7 +1990,6 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
tcsetattr_stdin_TCSANOW(&new_settings);
- /* Now initialize things */
previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
win_changed(0); /* do initial resizing */
#if ENABLE_USERNAME_OR_HOMEDIR
@@ -2033,7 +2031,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
int32_t ic, ic_raw;
fflush_all();
- ic = ic_raw = lineedit_read_key(read_key_buffer);
+ ic = ic_raw = lineedit_read_key(read_key_buffer, timeout);
#if ENABLE_FEATURE_EDITING_VI
newdelflag = 1;
@@ -2194,7 +2192,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
case 'd'|VI_CMDMODE_BIT: {
int nc, sc;
- ic = lineedit_read_key(read_key_buffer);
+ ic = lineedit_read_key(read_key_buffer, timeout);
if (errno) /* error */
goto return_error_indicator;
if (ic == ic_raw) { /* "cc", "dd" */
@@ -2258,7 +2256,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
break;
case 'r'|VI_CMDMODE_BIT:
//FIXME: unicode case?
- ic = lineedit_read_key(read_key_buffer);
+ ic = lineedit_read_key(read_key_buffer, timeout);
if (errno) /* error */
goto return_error_indicator;
if (ic < ' ' || ic > 255) {