From 16a5290c91bc14ca3f3a26f24796761f9f08c0f0 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Tue, 8 Jan 2008 20:40:19 +0000 Subject: Disable highlighting on Win32 --- src/lib/cfuns-c.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index f588beab..47485408 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -277,18 +277,25 @@ std_stream_is_terminal(int fd) { assert(fd > -1 && fd < 3); #ifdef __WIN32__ - HANDLE handle; + DWORD handle; switch (fd) { case 0: handle = STD_INPUT_HANDLE; break; case 1: handle = STD_OUTPUT_HANDLE; break; case 2: handle = STD_ERROR_HANDLE; break; } - /* VerifyConsoleIoHandle appears to be an undocumented function. - MS documentation suggests `GetFileType', but then the return - value is still insufficient for determining whether the - output stream is attached to a terminal or not. */ - return VerifyConsoleIoHandle(GetStdHandle(handle)); + /* The MS documentation suggests `GetFileType' for determining + the nature of the file handle. The return value, in our case, + is an over approximation of what we are interested int: Are we + dealing with a stream connected to a terminal? The constant + FILE_TYPE_CHAR characterises character files; in particular + a console terminal, or a printer. There is an undocumented + function `VerifyConsoleIoHandle' to deal precisely with the case + we are interested in. However, while availale in Wine, it is + not available in the MinGW headers. Consequently, we cannot + rely on it for the moment. + So, we may still get garbage out of this function on MS platforms. */ + return GetFileType(GetStdHandle(handle)) == FILE_TYPE_CHAR; #else return isatty(fd); #endif -- cgit v1.2.3