Detect console streams more reliably on Windows
commite075d7292632bd718475b5803d800dc4220da4b6
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Tue, 6 Dec 2011 00:17:03 +0000 (6 00:17 +0000)
treefe36aa9416a5f8d11fca6c1189dde9cefe44a7c4
parent6adfe5c463157dfd7b27a7e9fe640deec0ab038d
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