Detect console streams more reliably on Windows
commit6564588e404d81bcf1d60ee85f680b9f56162480
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 14 Feb 2012 20:00:26 +0000 (14 14:00 -0600)
tree9618e807832c827b2e8fde9c0141af5ca5944056
parent53f357e029e1369e2d5800441e29b799b51372ba
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