Detect console streams more reliably on Windows
commit3d095028b88bcf8456aa31568a6152d77d36ef2a
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 28 Dec 2010 17:56:08 +0000 (28 18:56 +0100)
tree1289bfd5953cfa016dde19c8695a6da84ac73986
parentd52d27e225b1c2bd8b902b4441e11f263f42ad29
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