diff options
author | Ron Yorston <rmy@pobox.com> | 2014-03-20 15:10:56 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-03-20 15:10:56 +0000 |
commit | 88deb9583290c2a4880903249eb9c5ed6ac05466 (patch) | |
tree | fea35ee1ab1a9eb9621ba0c990e6468ac32b8e7c /win32 | |
parent | 19633819727ac696e51e0e1f5a6e65fd29f5c089 (diff) | |
download | busybox-w32-88deb9583290c2a4880903249eb9c5ed6ac05466.tar.gz busybox-w32-88deb9583290c2a4880903249eb9c5ed6ac05466.tar.bz2 busybox-w32-88deb9583290c2a4880903249eb9c5ed6ac05466.zip |
Implement getc replacement
Diffstat (limited to 'win32')
-rw-r--r-- | win32/winansi.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/win32/winansi.c b/win32/winansi.c index 8ebe7b1af..e2b18b274 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #undef puts | 17 | #undef puts |
18 | #undef write | 18 | #undef write |
19 | #undef read | 19 | #undef read |
20 | #undef getc | ||
20 | 21 | ||
21 | /* | 22 | /* |
22 | ANSI codes used by git: m, K | 23 | ANSI codes used by git: m, K |
@@ -637,3 +638,26 @@ int winansi_read(int fd, void *buf, size_t count) | |||
637 | 638 | ||
638 | return rv; | 639 | return rv; |
639 | } | 640 | } |
641 | |||
642 | int winansi_getc(FILE *stream) | ||
643 | { | ||
644 | int rv; | ||
645 | |||
646 | rv = getc(stream); | ||
647 | if (!isatty(fileno(stream))) | ||
648 | return rv; | ||
649 | |||
650 | init(); | ||
651 | |||
652 | if (!console_in) | ||
653 | return rv; | ||
654 | |||
655 | if ( rv != EOF ) { | ||
656 | unsigned char c = (unsigned char)rv; | ||
657 | char *s = (char *)&c; | ||
658 | OemToCharBuff(s, s, 1); | ||
659 | rv = (int)c; | ||
660 | } | ||
661 | |||
662 | return rv; | ||
663 | } | ||