Detect console streams more reliably on Windows
commit9e9c8d7b8adbb69b46c7bf2d43bd6b4a3c51e9cd
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Sun, 24 Oct 2010 23:04:37 +0000 (25 00:04 +0100)
treef7e271eb49e0f748519594c8dd15f29c39e5a0bf
parentf6ee2a3b4a31f9feafdd9e68100e2eef423e6514
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