Detect console streams more reliably on Windows
commit246e2b089e316b0e7707f6fdf6c40d73868a5a2d
authorKarsten Blees <blees@dcon.de>
Sat, 31 Jul 2010 00:04:02 +0000 (31 00:04 +0000)
committerlmfadmin <lmfadmin@ubuntu.ubuntu-domain>
Fri, 3 Sep 2010 12:28:43 +0000 (3 13:28 +0100)
tree3f586a9275d3489b1f9725d8efc68be3a0a2899e
parent71b4329defdb1f142fff1f3132b432c340080d50
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