diff options
Diffstat (limited to '')
-rw-r--r-- | libbb/xfuncs.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index b03af8542..7df1a4cd3 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "libbb.h" | 23 | #include "libbb.h" |
24 | 24 | ||
25 | /* Turn on nonblocking I/O on a fd */ | 25 | /* Turn on nonblocking I/O on a fd */ |
26 | #if !ENABLE_PLATFORM_MINGW32 | ||
26 | int FAST_FUNC ndelay_on(int fd) | 27 | int FAST_FUNC ndelay_on(int fd) |
27 | { | 28 | { |
28 | int flags = fcntl(fd, F_GETFL); | 29 | int flags = fcntl(fd, F_GETFL); |
@@ -45,6 +46,7 @@ void FAST_FUNC close_on_exec_on(int fd) | |||
45 | { | 46 | { |
46 | fcntl(fd, F_SETFD, FD_CLOEXEC); | 47 | fcntl(fd, F_SETFD, FD_CLOEXEC); |
47 | } | 48 | } |
49 | #endif | ||
48 | 50 | ||
49 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) | 51 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) |
50 | { | 52 | { |
@@ -219,7 +221,12 @@ off_t FAST_FUNC fdlength(int fd) | |||
219 | 221 | ||
220 | int FAST_FUNC bb_putchar_stderr(char ch) | 222 | int FAST_FUNC bb_putchar_stderr(char ch) |
221 | { | 223 | { |
224 | #if ENABLE_PLATFORM_MINGW32 && !defined(_UCRT) | ||
225 | // Workaround for problems with stderr in MSVCRT | ||
226 | return fputc(ch, stderr); | ||
227 | #else | ||
222 | return write(STDERR_FILENO, &ch, 1); | 228 | return write(STDERR_FILENO, &ch, 1); |
229 | #endif | ||
223 | } | 230 | } |
224 | 231 | ||
225 | ssize_t FAST_FUNC full_write1_str(const char *str) | 232 | ssize_t FAST_FUNC full_write1_str(const char *str) |
@@ -268,6 +275,7 @@ int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *heigh | |||
268 | int err; | 275 | int err; |
269 | int close_me = -1; | 276 | int close_me = -1; |
270 | 277 | ||
278 | #if !ENABLE_PLATFORM_MINGW32 | ||
271 | if (fd == -1) { | 279 | if (fd == -1) { |
272 | if (isatty(STDOUT_FILENO)) | 280 | if (isatty(STDOUT_FILENO)) |
273 | fd = STDOUT_FILENO; | 281 | fd = STDOUT_FILENO; |
@@ -280,6 +288,7 @@ int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *heigh | |||
280 | else | 288 | else |
281 | close_me = fd = open("/dev/tty", O_RDONLY); | 289 | close_me = fd = open("/dev/tty", O_RDONLY); |
282 | } | 290 | } |
291 | #endif | ||
283 | 292 | ||
284 | win.ws_row = 0; | 293 | win.ws_row = 0; |
285 | win.ws_col = 0; | 294 | win.ws_col = 0; |
@@ -314,7 +323,7 @@ int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) | |||
314 | return tcsetattr(STDIN_FILENO, TCSANOW, tp); | 323 | return tcsetattr(STDIN_FILENO, TCSANOW, tp); |
315 | } | 324 | } |
316 | 325 | ||
317 | int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) | 326 | int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags IF_PLATFORM_MINGW32(UNUSED_PARAM)) |
318 | { | 327 | { |
319 | //TODO: slattach, shell read might be adapted to use this too: grep for "tcsetattr", "[VTIME] = 0" | 328 | //TODO: slattach, shell read might be adapted to use this too: grep for "tcsetattr", "[VTIME] = 0" |
320 | int r; | 329 | int r; |
@@ -323,6 +332,10 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t | |||
323 | r = tcgetattr(fd, oldterm); | 332 | r = tcgetattr(fd, oldterm); |
324 | *newterm = *oldterm; | 333 | *newterm = *oldterm; |
325 | 334 | ||
335 | #if ENABLE_PLATFORM_MINGW32 | ||
336 | newterm->imode &= | ||
337 | ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT); | ||
338 | #else | ||
326 | /* Turn off buffered input (ICANON) | 339 | /* Turn off buffered input (ICANON) |
327 | * Turn off echoing (ECHO) | 340 | * Turn off echoing (ECHO) |
328 | * and separate echoing of newline (ECHONL, normally off anyway) | 341 | * and separate echoing of newline (ECHONL, normally off anyway) |
@@ -379,6 +392,7 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t | |||
379 | */ | 392 | */ |
380 | newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL); | 393 | newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL); |
381 | } | 394 | } |
395 | #endif | ||
382 | return r; | 396 | return r; |
383 | } | 397 | } |
384 | 398 | ||