From 894bf4971374be233df7e954aabb3b19116c1ac7 Mon Sep 17 00:00:00 2001 From: Sean Purcell Date: Mon, 27 Mar 2017 12:19:30 -0700 Subject: [PATCH 1/2] Fix IS_CONSOLE returning 1 for NUL on windows --- programs/platform.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/programs/platform.h b/programs/platform.h index 89a9f6cd4..819bec873 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -100,9 +100,18 @@ extern "C" { #if (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 1)) || (PLATFORM_POSIX_VERSION >= 200112L) || defined(__DJGPP__) # include /* isatty */ # define IS_CONSOLE(stdStream) isatty(fileno(stdStream)) -#elif defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) +#elif defined(MSDOS) || defined(OS2) || defined(__CYGWIN__) # include /* _isatty */ # define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream)) +#elif defined(WIN32) || defined(_WIN32) +# include /* _isatty */ +# include /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */ +# include /* FILE */ +static inline int IS_CONSOLE(FILE* stdStream) +{ + DWORD dummy; + return _isatty(_fileno(stdStream)) && GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdStream)), &dummy); +} #else # define IS_CONSOLE(stdStream) 0 #endif From efdaf8bb7ca36c80be96226775927b69dfa0cc11 Mon Sep 17 00:00:00 2001 From: Sean Purcell Date: Mon, 27 Mar 2017 12:26:40 -0700 Subject: [PATCH 2/2] Fix inline compile errors --- programs/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/platform.h b/programs/platform.h index 819bec873..ee7819512 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -107,7 +107,7 @@ extern "C" { # include /* _isatty */ # include /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */ # include /* FILE */ -static inline int IS_CONSOLE(FILE* stdStream) +static __inline int IS_CONSOLE(FILE* stdStream) { DWORD dummy; return _isatty(_fileno(stdStream)) && GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdStream)), &dummy);