mingw: adjust is_console() to work with stdin
[gitweb.git] / compat / winansi.c
index cb725fb02f6e4f48c4f314c3c6c5e8535aa6eda8..590d61cb1bc77a31a4fcecf7c405c74822c9d6fe 100644 (file)
@@ -84,6 +84,7 @@ static void warn_if_raster_font(void)
 static int is_console(int fd)
 {
        CONSOLE_SCREEN_BUFFER_INFO sbi;
+       DWORD mode;
        HANDLE hcon;
 
        static int initialized = 0;
@@ -98,7 +99,10 @@ static int is_console(int fd)
                return 0;
 
        /* check if its a handle to a console output screen buffer */
-       if (!GetConsoleScreenBufferInfo(hcon, &sbi))
+       if (!fd) {
+               if (!GetConsoleMode(hcon, &mode))
+                       return 0;
+       } else if (!GetConsoleScreenBufferInfo(hcon, &sbi))
                return 0;
 
        /* initialize attributes */