aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-01-08 20:40:19 +0000
committerdos-reis <gdr@axiomatics.org>2008-01-08 20:40:19 +0000
commit16a5290c91bc14ca3f3a26f24796761f9f08c0f0 (patch)
tree24f0c26663661a09e61563572ae3c07be408f8b3 /src/lib
parenta90e0b91cdd543cc28abf425355c801279482ad6 (diff)
downloadopen-axiom-16a5290c91bc14ca3f3a26f24796761f9f08c0f0.tar.gz
Disable highlighting on Win32
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cfuns-c.c19
1 files changed, 13 insertions, 6 deletions
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