Detect console streams more reliably on Windows
commit38b9bfd2fbef031049dc9a81dd1fd0aba8e5db58
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerStepan Kasal <kasal@ucw.cz>
Thu, 15 May 2014 07:40:57 +0000 (15 09:40 +0200)
tree24162e7be0a9d360d80bd0da46b1d2ace756acbe
parentc7759fadde2afe698a21316023bcc8592cf7d56b
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