aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c12
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
1812static int lineedit_read_key(char *read_key_buffer) 1812static 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 */
1920int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st) 1919int 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) {