]> Savannah Git Hosting - gnulib.git/commitdiff
isatty: fix to work on windows 8
authorMichael Goffioul <michael.goffioul@gmail.com>
Mon, 9 Jun 2014 16:07:44 +0000 (17:07 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 9 Jun 2014 16:10:10 +0000 (17:10 +0100)
* lib/isatty.c (IsConsoleHandle): Change from testing the lower
2 bits of the handle to the more expensive but accurate syscall.

ChangeLog
lib/isatty.c

index 53be01f5262060387b75a9aaa9e50d694c5ee731..fbb05bd40d95474b1b5f64162b18f67e8b9aa0ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-09  Michael Goffioul  <michael.goffioul@gmail.com>
+
+       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  <eggert@cs.ucla.edu>
 
        maint: fix typo in fdl.texi
index e38bc9d9aaf6a3c37e418419e6637fd50a53fd72..7180eadd2672bafe402c9d8d63c3711a7a371d8a 100644 (file)
 /* Get _get_osfhandle().  */
 #include "msvc-nothrow.h"
 
-/* Optimized test whether a HANDLE refers to a console.
-   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  */
-#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