diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-02-25 07:59:06 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-02-25 07:59:06 +0100 |
commit | ca29d28681c55893a36ced1c7dfca44483d07eb4 (patch) | |
tree | 62f4acad7f03a0c423848400fa9d3b89b1561bfd | |
parent | 869554c72cbb5ae20a33ca0eeb6491913367c45e (diff) | |
download | ghdl-ca29d28681c55893a36ced1c7dfca44483d07eb4.tar.gz ghdl-ca29d28681c55893a36ced1c7dfca44483d07eb4.tar.bz2 ghdl-ca29d28681c55893a36ced1c7dfca44483d07eb4.zip |
Disable color diagnotics by default on Windows.
Close #289
-rw-r--r-- | src/vhdl/errorout.adb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/vhdl/errorout.adb b/src/vhdl/errorout.adb index f65cb555f..6b2c36e3b 100644 --- a/src/vhdl/errorout.adb +++ b/src/vhdl/errorout.adb @@ -15,7 +15,9 @@ -- along with GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. + with Ada.Text_IO; +with GNAT.OS_Lib; with Scanner; with Name_Table; with Iirs_Utils; use Iirs_Utils; @@ -34,14 +36,28 @@ package body Errorout is -- Set Flag_Color_Diagnostics to On or Off if is was Auto. procedure Detect_Terminal is + -- Import isatty. function isatty (Fd : Integer) return Integer; pragma Import (C, isatty); + + -- Awful way to detect if the host is Windows. Should be replaced by + -- a host-specific package. + Is_Windows : constant Boolean := GNAT.OS_Lib.Directory_Separator = '\'; begin if Flag_Color_Diagnostics = Auto then - if isatty (2) /= 0 then - Flag_Color_Diagnostics := On; - else + if Is_Windows then + -- Off by default on Windows, as the consoles may not support + -- ANSI control sequences. Should be replaced by calls to the + -- Win32 API. Flag_Color_Diagnostics := Off; + else + -- On Linux/Unix/Mac OS X: use color only when the output is to a + -- tty. + if isatty (2) /= 0 then + Flag_Color_Diagnostics := On; + else + Flag_Color_Diagnostics := Off; + end if; end if; end if; end Detect_Terminal; |