diff options
author | Ron Yorston <rmy@pobox.com> | 2018-04-05 20:31:13 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-04-05 20:31:13 +0100 |
commit | f7c592f6d832602a628008d598a3aa130d89de4d (patch) | |
tree | 5b771c3f51bfb51e52f3736f89f7b4b195e13f82 /libbb | |
parent | 3f18c23c67ea8614f1901265d100d3e49bc7491e (diff) | |
download | busybox-w32-f7c592f6d832602a628008d598a3aa130d89de4d.tar.gz busybox-w32-f7c592f6d832602a628008d598a3aa130d89de4d.tar.bz2 busybox-w32-f7c592f6d832602a628008d598a3aa130d89de4d.zip |
win32: exclude termios code
The code to manipulate terminal settings serves no purpose in WIN32.
Use conditional compilation to exclude much of it.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 19 | ||||
-rw-r--r-- | libbb/xfuncs.c | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index b9ba71242..36b6abe2b 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -2379,7 +2379,7 @@ static int32_t reverse_i_search(int timeout) | |||
2379 | */ | 2379 | */ |
2380 | int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) | 2380 | int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) |
2381 | { | 2381 | { |
2382 | int len, n; | 2382 | int len IF_NOT_PLATFORM_MINGW32(, n); |
2383 | int timeout; | 2383 | int timeout; |
2384 | #if ENABLE_FEATURE_TAB_COMPLETION | 2384 | #if ENABLE_FEATURE_TAB_COMPLETION |
2385 | smallint lastWasTab = 0; | 2385 | smallint lastWasTab = 0; |
@@ -2389,21 +2389,18 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2389 | smallint vi_cmdmode = 0; | 2389 | smallint vi_cmdmode = 0; |
2390 | #endif | 2390 | #endif |
2391 | struct termios initial_settings; | 2391 | struct termios initial_settings; |
2392 | #if !ENABLE_PLATFORM_MINGW32 | ||
2392 | struct termios new_settings; | 2393 | struct termios new_settings; |
2394 | #endif | ||
2393 | char read_key_buffer[KEYCODE_BUFFER_SIZE]; | 2395 | char read_key_buffer[KEYCODE_BUFFER_SIZE]; |
2394 | 2396 | ||
2395 | INIT_S(); | 2397 | INIT_S(); |
2396 | 2398 | ||
2399 | #if !ENABLE_PLATFORM_MINGW32 | ||
2397 | n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0 | 2400 | n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0 |
2398 | | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */ | 2401 | | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */ |
2399 | ); | 2402 | ); |
2400 | #if ENABLE_PLATFORM_MINGW32 | ||
2401 | initial_settings.c_cc[VINTR] = CTRL('C'); | ||
2402 | initial_settings.c_cc[VEOF] = CTRL('D'); | ||
2403 | if (n > 0 || !isatty(0) || !isatty(1)) { | ||
2404 | #else | ||
2405 | if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) { | 2403 | if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) { |
2406 | #endif | ||
2407 | /* Happens when e.g. stty -echo was run before. | 2404 | /* Happens when e.g. stty -echo was run before. |
2408 | * But if ICANON is not set, we don't come here. | 2405 | * But if ICANON is not set, we don't come here. |
2409 | * (example: interactive python ^Z-backgrounded, | 2406 | * (example: interactive python ^Z-backgrounded, |
@@ -2418,6 +2415,10 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2418 | DEINIT_S(); | 2415 | DEINIT_S(); |
2419 | return len; | 2416 | return len; |
2420 | } | 2417 | } |
2418 | #else | ||
2419 | initial_settings.c_cc[VINTR] = CTRL('C'); | ||
2420 | initial_settings.c_cc[VEOF] = CTRL('D'); | ||
2421 | #endif | ||
2421 | 2422 | ||
2422 | init_unicode(); | 2423 | init_unicode(); |
2423 | 2424 | ||
@@ -2456,7 +2457,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2456 | #endif | 2457 | #endif |
2457 | #define command command_must_not_be_used | 2458 | #define command command_must_not_be_used |
2458 | 2459 | ||
2460 | #if !ENABLE_PLATFORM_MINGW32 | ||
2459 | tcsetattr_stdin_TCSANOW(&new_settings); | 2461 | tcsetattr_stdin_TCSANOW(&new_settings); |
2462 | #endif | ||
2460 | 2463 | ||
2461 | #if ENABLE_USERNAME_OR_HOMEDIR | 2464 | #if ENABLE_USERNAME_OR_HOMEDIR |
2462 | { | 2465 | { |
@@ -2947,8 +2950,10 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2947 | free_tab_completion_data(); | 2950 | free_tab_completion_data(); |
2948 | #endif | 2951 | #endif |
2949 | 2952 | ||
2953 | #if !ENABLE_PLATFORM_MINGW32 | ||
2950 | /* restore initial_settings */ | 2954 | /* restore initial_settings */ |
2951 | tcsetattr_stdin_TCSANOW(&initial_settings); | 2955 | tcsetattr_stdin_TCSANOW(&initial_settings); |
2956 | #endif | ||
2952 | #if ENABLE_FEATURE_EDITING_WINCH | 2957 | #if ENABLE_FEATURE_EDITING_WINCH |
2953 | /* restore SIGWINCH handler */ | 2958 | /* restore SIGWINCH handler */ |
2954 | sigaction_set(SIGWINCH, &S.SIGWINCH_handler); | 2959 | sigaction_set(SIGWINCH, &S.SIGWINCH_handler); |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index f2112aec9..6fa21ad00 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -305,6 +305,7 @@ int FAST_FUNC get_terminal_width(int fd) | |||
305 | return width; | 305 | return width; |
306 | } | 306 | } |
307 | 307 | ||
308 | #if !ENABLE_PLATFORM_MINGW32 | ||
308 | int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) | 309 | int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) |
309 | { | 310 | { |
310 | return tcsetattr(STDIN_FILENO, TCSANOW, tp); | 311 | return tcsetattr(STDIN_FILENO, TCSANOW, tp); |
@@ -380,6 +381,7 @@ int FAST_FUNC set_termios_to_raw(int fd, struct termios *oldterm, int flags) | |||
380 | get_termios_and_make_raw(fd, &newterm, oldterm, flags); | 381 | get_termios_and_make_raw(fd, &newterm, oldterm, flags); |
381 | return tcsetattr(fd, TCSANOW, &newterm); | 382 | return tcsetattr(fd, TCSANOW, &newterm); |
382 | } | 383 | } |
384 | #endif | ||
383 | 385 | ||
384 | pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options) | 386 | pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options) |
385 | { | 387 | { |