diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-08 05:07:02 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-08 05:07:02 +0100 |
commit | 66c5b12dbf85142eea257ba6047191d7c0ee43f3 (patch) | |
tree | 913ab2ca77d8a90bb48e75de12435d2776805da5 /libbb | |
parent | dd807c16f99b4ead544289b83c88cc2488542f72 (diff) | |
download | busybox-w32-66c5b12dbf85142eea257ba6047191d7c0ee43f3.tar.gz busybox-w32-66c5b12dbf85142eea257ba6047191d7c0ee43f3.tar.bz2 busybox-w32-66c5b12dbf85142eea257ba6047191d7c0ee43f3.zip |
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')
-rw-r--r-- | libbb/lineedit.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 5dd835cca..afd28b75c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1809,10 +1809,9 @@ static void win_changed(int nsig) | |||
1809 | errno = sv_errno; | 1809 | errno = sv_errno; |
1810 | } | 1810 | } |
1811 | 1811 | ||
1812 | static int lineedit_read_key(char *read_key_buffer) | 1812 | static int lineedit_read_key(char *read_key_buffer, int timeout) |
1813 | { | 1813 | { |
1814 | int64_t ic; | 1814 | int64_t ic; |
1815 | int timeout = -1; | ||
1816 | #if ENABLE_UNICODE_SUPPORT | 1815 | #if ENABLE_UNICODE_SUPPORT |
1817 | char unicode_buf[MB_CUR_MAX + 1]; | 1816 | char unicode_buf[MB_CUR_MAX + 1]; |
1818 | int unicode_idx = 0; | 1817 | int unicode_idx = 0; |
@@ -1917,7 +1916,7 @@ static int isrtl_str(void) | |||
1917 | * 0 on ctrl-C (the line entered is still returned in 'command'), | 1916 | * 0 on ctrl-C (the line entered is still returned in 'command'), |
1918 | * >0 length of input string, including terminating '\n' | 1917 | * >0 length of input string, including terminating '\n' |
1919 | */ | 1918 | */ |
1920 | int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st) | 1919 | int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) |
1921 | { | 1920 | { |
1922 | int len; | 1921 | int len; |
1923 | #if ENABLE_FEATURE_TAB_COMPLETION | 1922 | #if ENABLE_FEATURE_TAB_COMPLETION |
@@ -1991,7 +1990,6 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
1991 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; | 1990 | new_settings.c_cc[VINTR] = _POSIX_VDISABLE; |
1992 | tcsetattr_stdin_TCSANOW(&new_settings); | 1991 | tcsetattr_stdin_TCSANOW(&new_settings); |
1993 | 1992 | ||
1994 | /* Now initialize things */ | ||
1995 | previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); | 1993 | previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); |
1996 | win_changed(0); /* do initial resizing */ | 1994 | win_changed(0); /* do initial resizing */ |
1997 | #if ENABLE_USERNAME_OR_HOMEDIR | 1995 | #if ENABLE_USERNAME_OR_HOMEDIR |
@@ -2033,7 +2031,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2033 | int32_t ic, ic_raw; | 2031 | int32_t ic, ic_raw; |
2034 | 2032 | ||
2035 | fflush_all(); | 2033 | fflush_all(); |
2036 | ic = ic_raw = lineedit_read_key(read_key_buffer); | 2034 | ic = ic_raw = lineedit_read_key(read_key_buffer, timeout); |
2037 | 2035 | ||
2038 | #if ENABLE_FEATURE_EDITING_VI | 2036 | #if ENABLE_FEATURE_EDITING_VI |
2039 | newdelflag = 1; | 2037 | newdelflag = 1; |
@@ -2194,7 +2192,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2194 | case 'd'|VI_CMDMODE_BIT: { | 2192 | case 'd'|VI_CMDMODE_BIT: { |
2195 | int nc, sc; | 2193 | int nc, sc; |
2196 | 2194 | ||
2197 | ic = lineedit_read_key(read_key_buffer); | 2195 | ic = lineedit_read_key(read_key_buffer, timeout); |
2198 | if (errno) /* error */ | 2196 | if (errno) /* error */ |
2199 | goto return_error_indicator; | 2197 | goto return_error_indicator; |
2200 | if (ic == ic_raw) { /* "cc", "dd" */ | 2198 | if (ic == ic_raw) { /* "cc", "dd" */ |
@@ -2258,7 +2256,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2258 | break; | 2256 | break; |
2259 | case 'r'|VI_CMDMODE_BIT: | 2257 | case 'r'|VI_CMDMODE_BIT: |
2260 | //FIXME: unicode case? | 2258 | //FIXME: unicode case? |
2261 | ic = lineedit_read_key(read_key_buffer); | 2259 | ic = lineedit_read_key(read_key_buffer, timeout); |
2262 | if (errno) /* error */ | 2260 | if (errno) /* error */ |
2263 | goto return_error_indicator; | 2261 | goto return_error_indicator; |
2264 | if (ic < ' ' || ic > 255) { | 2262 | if (ic < ' ' || ic > 255) { |