Detect console streams more reliably on Windows
commit9a8a1a28b0086caa9b638ada7f8ee33176ab053b
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Mon, 22 Oct 2012 12:29:59 +0000 (22 13:29 +0100)
tree07be23ecaa805249d9ecf063f17077553999a93b
parent7b63a8048a6f176a5205ab0f95928c48c543e783
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