aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-09-15 17:14:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-09-15 17:14:01 +0200
commitaaaaaa5ad6a93101d38800467fe3750b35fed6ea (patch)
tree8cd7b7561f3e923a382e5f97b4bd0fbe5fd68c39 /libbb/lineedit.c
parente58b44755dbac7c55bf602f7f76dfb37b47323f5 (diff)
downloadbusybox-w32-aaaaaa5ad6a93101d38800467fe3750b35fed6ea.tar.gz
busybox-w32-aaaaaa5ad6a93101d38800467fe3750b35fed6ea.tar.bz2
busybox-w32-aaaaaa5ad6a93101d38800467fe3750b35fed6ea.zip
less,microcom,lineedit: use common routine to set raw termios
function old new delta get_termios_and_make_raw - 139 +139 xget1 39 8 -31 read_line_input 3912 3867 -45 less_main 2525 2471 -54 set_termios_to_raw 116 36 -80 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 139/-210) Total: -71 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 17766a126..3a092ffe2 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2259,7 +2259,7 @@ static int32_t reverse_i_search(int timeout)
2259 */ 2259 */
2260int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) 2260int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize)
2261{ 2261{
2262 int len; 2262 int len, n;
2263 int timeout; 2263 int timeout;
2264#if ENABLE_FEATURE_TAB_COMPLETION 2264#if ENABLE_FEATURE_TAB_COMPLETION
2265 smallint lastWasTab = 0; 2265 smallint lastWasTab = 0;
@@ -2274,9 +2274,10 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2274 2274
2275 INIT_S(); 2275 INIT_S();
2276 2276
2277 if (tcgetattr(STDIN_FILENO, &initial_settings) < 0 2277 n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0
2278 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON 2278 | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */
2279 ) { 2279 );
2280 if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) {
2280 /* Happens when e.g. stty -echo was run before. 2281 /* Happens when e.g. stty -echo was run before.
2281 * But if ICANON is not set, we don't come here. 2282 * But if ICANON is not set, we don't come here.
2282 * (example: interactive python ^Z-backgrounded, 2283 * (example: interactive python ^Z-backgrounded,
@@ -2329,18 +2330,6 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2329#endif 2330#endif
2330#define command command_must_not_be_used 2331#define command command_must_not_be_used
2331 2332
2332 new_settings = initial_settings;
2333 /* ~ICANON: unbuffered input (most c_cc[] are disabled, VMIN/VTIME are enabled) */
2334 /* ~ECHO, ~ECHONL: turn off echoing, including newline echoing */
2335 /* ~ISIG: turn off INTR (ctrl-C), QUIT, SUSP */
2336 new_settings.c_lflag &= ~(ICANON | ECHO | ECHONL | ISIG);
2337 /* reads will block only if < 1 char is available */
2338 new_settings.c_cc[VMIN] = 1;
2339 /* no timeout (reads block forever) */
2340 new_settings.c_cc[VTIME] = 0;
2341 /* Should be not needed if ISIG is off: */
2342 /* Turn off CTRL-C */
2343 /* new_settings.c_cc[VINTR] = _POSIX_VDISABLE; */
2344 tcsetattr_stdin_TCSANOW(&new_settings); 2333 tcsetattr_stdin_TCSANOW(&new_settings);
2345 2334
2346#if ENABLE_USERNAME_OR_HOMEDIR 2335#if ENABLE_USERNAME_OR_HOMEDIR