Detect console streams more reliably on Windows
commitdb0493d39d4c41e222287df4c3ae201305048c71
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Fri, 10 Sep 2010 22:44:31 +0000 (10 23:44 +0100)
tree2ee2db47b79988d6550737e3907a0473930426bb
parentbb3656f8bfa3f1bdedc1368582b53e0c3bfefc50
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