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 glib. 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) - #if HAVE_MSVC_INVALID_PARAMETER_HANDLER 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;
