>From a008d625b7854d2c08c6606d90f6f2f48263f973 Mon Sep 17 00:00:00 2001 From: Michael Goffioul Date: Mon, 9 Jun 2014 17:07:44 +0100 Subject: [PATCH] isatty: fix to work on windows 8 * lib/isatty.c (IsConsoleHandle): Change from testing the lower 2 bits of the handle to the more expensive but accurate syscall. --- ChangeLog | 6 ++++++ lib/isatty.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53be01f..fbb05bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-06-09 Michael Goffioul + + isatty: fix to work on windows 8 + * lib/isatty.c (IsConsoleHandle): Change from testing the lower + 2 bits of the handle to the more expensive but accurate syscall. + 2014-06-07 Paul Eggert maint: fix typo in fdl.texi diff --git a/lib/isatty.c b/lib/isatty.c index e38bc9d..7180ead 100644 --- a/lib/isatty.c +++ b/lib/isatty.c @@ -32,9 +32,11 @@ /* Get _get_osfhandle(). */ #include "msvc-nothrow.h" -/* Optimized test whether a HANDLE refers to a console. - See . */ -#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3) +static BOOL IsConsoleHandle (HANDLE h) +{ + DWORD mode; + return GetConsoleMode (h, &mode) != 0; +} #if HAVE_MSVC_INVALID_PARAMETER_HANDLER static int -- 1.7.7.6