Detect console streams more reliably on Windows
commit31bef7b47c17617d05359051d9d69c4a250b7c8b
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 8 Jan 2011 14:15:32 +0000 (8 15:15 +0100)
tree28d5960acbb200f396777f48d51d06e835b57533
parent2902197ece30d07aa0015e053b3893974554cc9e
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