diff gcc/diagnostic-color.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line diff
--- a/gcc/diagnostic-color.c	Thu Oct 25 07:37:49 2018 +0900
+++ b/gcc/diagnostic-color.c	Thu Feb 13 11:34:05 2020 +0900
@@ -1,5 +1,5 @@
 /* Output colorization.
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 #include "config.h"
 #include "system.h"
 #include "diagnostic-color.h"
+#include "diagnostic-url.h"
 
 #ifdef __MINGW32__
 #  include <windows.h>
@@ -89,6 +90,7 @@
   { "range2", SGR_SEQ (COLOR_FG_BLUE), 6, false },
   { "locus", SGR_SEQ (COLOR_BOLD), 5, false },
   { "quote", SGR_SEQ (COLOR_BOLD), 5, false },
+  { "path", SGR_SEQ (COLOR_BOLD COLOR_SEPARATOR COLOR_FG_CYAN), 4, false },
   { "fixit-insert", SGR_SEQ (COLOR_FG_GREEN), 12, false },
   { "fixit-delete", SGR_SEQ (COLOR_FG_RED), 12, false },
   { "diff-filename", SGR_SEQ (COLOR_BOLD), 13, false },
@@ -125,7 +127,7 @@
 
 /* Parse GCC_COLORS.  The default would look like:
    GCC_COLORS='error=01;31:warning=01;35:note=01;36:\
-   range1=32:range2=34:locus=01:quote=01:\
+   range1=32:range2=34:locus=01:quote=01:path=01;36:\
    fixit-insert=32:fixit-delete=31:'\
    diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
    type-diff=01;32'
@@ -236,3 +238,22 @@
       gcc_unreachable ();
     }
 }
+
+/* Determine if URLs should be enabled, based on RULE.
+   This reuses the logic for colorization.  */
+
+bool
+diagnostic_urls_enabled_p (diagnostic_url_rule_t rule)
+{
+  switch (rule)
+    {
+    case DIAGNOSTICS_URL_NO:
+      return false;
+    case DIAGNOSTICS_URL_YES:
+      return true;
+    case DIAGNOSTICS_URL_AUTO:
+      return should_colorize ();
+    default:
+      gcc_unreachable ();
+    }
+}