From: Michael Goffioul Date: Mon, 9 Jun 2014 16:07:44 +0000 (+0100) Subject: isatty: fix to work on windows 8 X-Git-Tag: v1.0~7359 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a008d625b7854d2c08c6606d90f6f2f48263f973;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 53be01f526..fbb05bd40d 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 e38bc9d9aa..7180eadd26 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