Detect console streams more reliably on Windows
commitc6f410e6a269181da9bd6ece9ded5dd59b99c8b4
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 27 Dec 2013 16:04:45 +0000 (27 10:04 -0600)
tree64c3ff7ea4876e113010e5dc36c687bc14311f8b
parentebfbc1c748413d0c9f3594d0b55facf5dbfe929d
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