Detect console streams more reliably on Windows
commit26a90188efba7946ebabb77fd969d28032b61999
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Sun, 29 Jan 2012 10:58:13 +0000 (29 10:58 +0000)
tree7baba6fa2c7d897cc3950fbde56cf40a6f2c9877
parent277d7843d38b3429e49a283e0ed671391137b269
Detect console streams more reliably on Windows

GetStdHandle(STD_OUTPUT_HANDLE) doesn't work for stderr if stdout is
redirected. Use _get_osfhandle of the FILE* instead.

_isatty() is true for all character devices (including parallel and serial
ports). Check return value of GetConsoleScreenBufferInfo instead to
reliably detect console handles (also don't initialize internal state from
an uninitialized CONSOLE_SCREEN_BUFFER_INFO structure if the function
fails).

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
compat/winansi.c