]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala,libvaladoc: Properly check for colored terminal output on Windows
authorwszqkzqk <wszqkzqk@qq.com>
Tue, 3 Jan 2023 15:12:24 +0000 (23:12 +0800)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 30 Jan 2023 15:32:00 +0000 (16:32 +0100)
Additionally look for `_isatty()` and adjust for more possible results

Fixes https://gitlab.gnome.org/GNOME/vala/issues/1383

libvaladoc/errorreporter.vala
vala/valareport.vala

index 68b09a8ef8ef4f6fc1e970f3d0a5f97548f675c3..d63ed6ecdb3985ac84d913a4bb492f4e6e01bea5 100644 (file)
@@ -240,11 +240,14 @@ public class Valadoc.ErrorReporter : Object {
                void* _func;
                module.symbol ("isatty", out _func);
                if (_func == null) {
-                       return false;
+                       module.symbol ("_isatty", out _func);
+                       if (_func == null) {
+                               return false;
+                       }
                }
 
                AttyFunc? func = (AttyFunc) _func;
-               return func (fd) == 1;
+               return func (fd) > 0;
        }
 
        [PrintfFormat]
index bdb11236fcd8f077957364a1285141296c043ee6..081f37c42b4b7e6a69fef0821a6dc04f1092e1fb 100644 (file)
@@ -410,10 +410,13 @@ public class Vala.Report {
                void* _func;
                module.symbol ("isatty", out _func);
                if (_func == null) {
-                       return false;
+                       module.symbol ("_isatty", out _func);
+                       if (_func == null) {
+                               return false;
+                       }
                }
 
                AttyFunc? func = (AttyFunc) _func;
-               return func (fd) == 1;
+               return func (fd) > 0;
        }
 }