[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] lib/isatty.c - Remove IsConsoleHandle(h)

From: mart0258
Subject: [PATCH] lib/isatty.c - Remove IsConsoleHandle(h)
Date: Sun, 08 Jun 2014 22:40:32 -0400

isatty.c contains an "optimized test" to determine whether or not something is 
sent to terminal based on the low two bits. 

I don't see the purpose behind the optimization.  It's only called after the 
_isatty(fd), meaning gnulib already has an accurate confirmation on whether or 
not the call is valid.  

More importantly, it breaks on Windows 8, where all handles are multiples of 4. 
 The result is a false negative, and an unclean output from a freshly compiled 

diff --git a/lib/isatty.c b/lib/isatty.c
index e38bc9d..447ce0d 100644
--- a/lib/isatty.c
+++ b/lib/isatty.c
@@ -32,10 +32,6 @@
 /* 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 int
 _isatty_nothrow (int fd)
@@ -73,8 +69,7 @@ isatty (int fd)
      But it does not set errno when it returns 0.  */
   if (_isatty_nothrow (fd))
-      if (IsConsoleHandle (h))
-        return 1;
+      return 1;
   errno = ENOTTY;
   return 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]