Detect console streams more reliably on Windows
commit8cc5f0bc24ea1e9f570ce4686652cb4060243942
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 5 Jan 2012 20:13:59 +0000 (5 14:13 -0600)
treedfdd1b15fc283330476eb92e90e0da33b8623b1c
parentc0b3607fee4b141d480eb86916fc05aa646ca4d9
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