ports/186853: [patch] Colour output support for lang/gcc48

Olivier software-freebsd at interfasys.ch
Tue Feb 18 01:30:02 UTC 2014


>Number:         186853
>Category:       ports
>Synopsis:       [patch] Colour output support for lang/gcc48
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 18 01:30:01 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Olivier
>Release:        9.2
>Organization:
interfaSys sàrl
>Environment:
FreeBSD 9.2-RELEASE-p2 #0 r259303
>Description:
lang/gcc48 does not support colour diagnostics and it will still take several months for lang/gcc49 to become stable, so here are patches which add support for "-fdiagnostics-color" [1], based on official commits made in the gcc 4.9 trunk [2][3][4]

Note: If you're using ccache, you'll need to patch the port using PR 186851 [5]

[1]http://gcc.gnu.org/onlinedocs/gcc/Language-Independent-Options.html#index-fdiagnostics-color-239
[2]http://repo.or.cz/w/official-gcc.git/commitdiff/41609f8bc12a3e7feeaf7749a03f880e5b3c2819#patch11
[3]http://repo.or.cz/w/official-gcc.git/commitdiff/adc604d41825b3cbd09045baeef09b1b88fc5a02
[4]http://repo.or.cz/w/official-gcc.git/commitdiff/71eeb8d395362158ffe9efbc2a7efbe3c4268db5#patch5
[5]http://www.freebsd.org/cgi/query-pr.cgi?pr=186851
>How-To-Repeat:

>Fix:
Patches included

Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	files/
#	files/patch-gcc_common.opt
#	files/patch-gcc_diagnostic-color.c
#	files/patch-gcc_diagnostic.c
#	files/patch-gcc_c-family_c-format.c
#	files/patch-gcc_cp_error.c
#	files/patch-gcc_Makefile.in
#	files/patch-gcc_toplev.c
#	files/patch-gcc_testsuite_lib_c-compat.exp
#	files/patch-gcc_diagnostic-core.h
#	files/patch-gcc_pretty-print.h
#	files/patch-gcc_langhooks.c
#	files/patch-gcc_diagnostic.def
#	files/patch-gcc_doc_invoke.texi
#	files/patch-gcc_diagnostic-color.h
#	files/patch-gcc_dwarf2out.c
#	files/patch-gcc_pretty-print.c
#	files/patch-gcc_opts.c
#	files/patch-gcc_testsuite_lib_prune.exp
#
echo c - files/
mkdir -p files/ > /dev/null 2>&1
echo x - files/patch-gcc_common.opt
sed 's/^X//' >files/patch-gcc_common.opt << 'dee1ae459171401f7cd97b063f689e34'
X--- gcc/common.opt
X+++ gcc/common.opt
X@@ -1028,6 +1028,30 @@ fdiagnostics-show-caret
X Common Var(flag_diagnostics_show_caret) Init(1)
X Show the source line with a caret indicating the column
X 
X+fdiagnostics-color
X+Common Alias(fdiagnostics-color=,always,never)
X+;
X+
X+fdiagnostics-color=
X+Common Joined RejectNegative Var(flag_diagnostics_show_color) Enum(diagnostic_color_rule) Init(DIAGNOSTICS_COLOR_NO)
X+-fdiagnostics-color=[never|always|auto]        Colorize diagnostics
X+
X+; Required for these enum values.
X+SourceInclude
X+diagnostic-color.h
X+
X+Enum
X+Name(diagnostic_color_rule) Type(int)
X+
X+EnumValue
X+Enum(diagnostic_color_rule) String(never) Value(DIAGNOSTICS_COLOR_NO)
X+
X+EnumValue
X+Enum(diagnostic_color_rule) String(always) Value(DIAGNOSTICS_COLOR_YES)
X+
X+EnumValue
X+Enum(diagnostic_color_rule) String(auto) Value(DIAGNOSTICS_COLOR_AUTO)
X+
X fdiagnostics-show-option
X Common Var(flag_diagnostics_show_option) Init(1)
X Amend appropriate diagnostic messages with the command line option that controls them
dee1ae459171401f7cd97b063f689e34
echo x - files/patch-gcc_diagnostic-color.c
sed 's/^X//' >files/patch-gcc_diagnostic-color.c << '7ce27e8f33f1b5377cb15c35726aee8b'
X--- /dev/null
X+++ gcc/diagnostic-color.c
X@@ -0,0 +1,307 @@
X+/* Output colorization.
X+   Copyright 2011-2013 Free Software Foundation, Inc.
X+
X+   This program is free software; you can redistribute it and/or modify
X+   it under the terms of the GNU General Public License as published by
X+   the Free Software Foundation; either version 3, or (at your option)
X+   any later version.
X+
X+   This program is distributed in the hope that it will be useful,
X+   but WITHOUT ANY WARRANTY; without even the implied warranty of
X+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X+   GNU General Public License for more details.
X+
X+   You should have received a copy of the GNU General Public License
X+   along with this program; if not, write to the Free Software
X+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
X+   02110-1301, USA.  */
X+
X+#include "config.h"
X+#include "system.h"
X+#include "diagnostic-color.h"
X+
X+/* Select Graphic Rendition (SGR, "\33[...m") strings.  */
X+/* Also Erase in Line (EL) to Right ("\33[K") by default.  */
X+/*    Why have EL to Right after SGR?
X+	 -- The behavior of line-wrapping when at the bottom of the
X+	    terminal screen and at the end of the current line is often
X+	    such that a new line is introduced, entirely cleared with
X+	    the current background color which may be different from the
X+	    default one (see the boolean back_color_erase terminfo(5)
X+	    capability), thus scrolling the display by one line.
X+	    The end of this new line will stay in this background color
X+	    even after reverting to the default background color with
X+	    "\33[m', unless it is explicitly cleared again with "\33[K"
X+	    (which is the behavior the user would instinctively expect
X+	    from the whole thing).  There may be some unavoidable
X+	    background-color flicker at the end of this new line because
X+	    of this (when timing with the monitor's redraw is just right).
X+	 -- The behavior of HT (tab, "\t") is usually the same as that of
X+	    Cursor Forward Tabulation (CHT) with a default parameter
X+	    of 1 ("\33[I"), i.e., it performs pure movement to the next
X+	    tab stop, without any clearing of either content or screen
X+	    attributes (including background color); try
X+	       printf 'asdfqwerzxcv\rASDF\tZXCV\n'
X+	    in a bash(1) shell to demonstrate this.  This is not what the
X+	    user would instinctively expect of HT (but is ok for CHT).
X+	    The instinctive behavior would include clearing the terminal
X+	    cells that are skipped over by HT with blank cells in the
X+	    current screen attributes, including background color;
X+	    the boolean dest_tabs_magic_smso terminfo(5) capability
X+	    indicates this saner behavior for HT, but only some rare
X+	    terminals have it (although it also indicates a special
X+	    glitch with standout mode in the Teleray terminal for which
X+	    it was initially introduced).  The remedy is to add "\33K"
X+	    after each SGR sequence, be it START (to fix the behavior
X+	    of any HT after that before another SGR) or END (to fix the
X+	    behavior of an HT in default background color that would
X+	    follow a line-wrapping at the bottom of the screen in another
X+	    background color, and to complement doing it after START).
X+	    Piping GCC's output through a pager such as less(1) avoids
X+	    any HT problems since the pager performs tab expansion.
X+
X+      Generic disadvantages of this remedy are:
X+	 -- Some very rare terminals might support SGR but not EL (nobody
X+	    will use "gcc -fdiagnostics-color" on a terminal that does not
X+	    support SGR in the first place).
X+	 -- Having these extra control sequences might somewhat complicate
X+	    the task of any program trying to parse "gcc -fdiagnostics-color"
X+	    output in order to extract structuring information from it.
X+      A specific disadvantage to doing it after SGR START is:
X+	 -- Even more possible background color flicker (when timing
X+	    with the monitor's redraw is just right), even when not at the
X+	    bottom of the screen.
X+      There are no additional disadvantages specific to doing it after
X+      SGR END.
X+
X+      It would be impractical for GCC to become a full-fledged
X+      terminal program linked against ncurses or the like, so it will
X+      not detect terminfo(5) capabilities.  */
X+#define COLOR_SEPARATOR		";"
X+#define COLOR_NONE		"00"
X+#define COLOR_BOLD		"01"
X+#define COLOR_UNDERSCORE	"04"
X+#define COLOR_BLINK		"05"
X+#define COLOR_REVERSE		"07"
X+#define COLOR_FG_BLACK		"30"
X+#define COLOR_FG_RED		"31"
X+#define COLOR_FG_GREEN		"32"
X+#define COLOR_FG_YELLOW		"33"
X+#define COLOR_FG_BLUE		"34"
X+#define COLOR_FG_MAGENTA	"35"
X+#define COLOR_FG_CYAN		"36"
X+#define COLOR_FG_WHITE		"37"
X+#define COLOR_BG_BLACK		"40"
X+#define COLOR_BG_RED		"41"
X+#define COLOR_BG_GREEN		"42"
X+#define COLOR_BG_YELLOW		"43"
X+#define COLOR_BG_BLUE		"44"
X+#define COLOR_BG_MAGENTA	"45"
X+#define COLOR_BG_CYAN		"46"
X+#define COLOR_BG_WHITE		"47"
X+#define SGR_START		"\33["
X+#define SGR_END			"m\33[K"
X+#define SGR_SEQ(str)		SGR_START str SGR_END
X+#define SGR_RESET		SGR_SEQ("")
X+
X+
X+/* The context and logic for choosing default --color screen attributes
X+   (foreground and background colors, etc.) are the following.
X+      -- There are eight basic colors available, each with its own
X+	 nominal luminosity to the human eye and foreground/background
X+	 codes (black [0 %, 30/40], blue [11 %, 34/44], red [30 %, 31/41],
X+	 magenta [41 %, 35/45], green [59 %, 32/42], cyan [70 %, 36/46],
X+	 yellow [89 %, 33/43], and white [100 %, 37/47]).
X+      -- Sometimes, white as a background is actually implemented using
X+	 a shade of light gray, so that a foreground white can be visible
X+	 on top of it (but most often not).
X+      -- Sometimes, black as a foreground is actually implemented using
X+	 a shade of dark gray, so that it can be visible on top of a
X+	 background black (but most often not).
X+      -- Sometimes, more colors are available, as extensions.
X+      -- Other attributes can be selected/deselected (bold [1/22],
X+	 underline [4/24], standout/inverse [7/27], blink [5/25], and
X+	 invisible/hidden [8/28]).  They are sometimes implemented by
X+	 using colors instead of what their names imply; e.g., bold is
X+	 often achieved by using brighter colors.  In practice, only bold
X+	 is really available to us, underline sometimes being mapped by
X+	 the terminal to some strange color choice, and standout best
X+	 being left for use by downstream programs such as less(1).
X+      -- We cannot assume that any of the extensions or special features
X+	 are available for the purpose of choosing defaults for everyone.
X+      -- The most prevalent default terminal backgrounds are pure black
X+	 and pure white, and are not necessarily the same shades of
X+	 those as if they were selected explicitly with SGR sequences.
X+	 Some terminals use dark or light pictures as default background,
X+	 but those are covered over by an explicit selection of background
X+	 color with an SGR sequence; their users will appreciate their
X+	 background pictures not be covered like this, if possible.
X+      -- Some uses of colors attributes is to make some output items
X+	 more understated (e.g., context lines); this cannot be achieved
X+	 by changing the background color.
X+      -- For these reasons, the GCC color defaults should strive not
X+	 to change the background color from its default, unless it's
X+	 for a short item that should be highlighted, not understated.
X+      -- The GCC foreground color defaults (without an explicitly set
X+	 background) should provide enough contrast to be readable on any
X+	 terminal with either a black (dark) or white (light) background.
X+	 This only leaves red, magenta, green, and cyan (and their bold
X+	 counterparts) and possibly bold blue.  */
X+/* Default colors. The user can overwrite them using environment
X+   variable GCC_COLORS.  */
X+struct color_cap
X+{
X+  const char *name;
X+  const char *val;
X+  unsigned char name_len;
X+  bool free_val;
X+};
X+
X+/* For GCC_COLORS.  */
X+static struct color_cap color_dict[] =
X+{
X+  { "error", SGR_SEQ (COLOR_BOLD COLOR_SEPARATOR COLOR_FG_RED), 5, false },
X+  { "warning", SGR_SEQ (COLOR_BOLD COLOR_SEPARATOR COLOR_FG_MAGENTA),
X+	       7, false },
X+  { "note", SGR_SEQ (COLOR_BOLD COLOR_SEPARATOR COLOR_FG_CYAN), 4, false },
X+  { "caret", SGR_SEQ (COLOR_BOLD COLOR_SEPARATOR COLOR_FG_GREEN), 5, false },
X+  { "locus", SGR_SEQ (COLOR_BOLD), 5, false },
X+  { "quote", SGR_SEQ (COLOR_BOLD), 5, false },
X+  { NULL, NULL, 0, false }
X+};
X+
X+const char *
X+colorize_start (bool show_color, const char *name, size_t name_len)
X+{
X+  struct color_cap const *cap;
X+
X+  if (!show_color)
X+    return "";
X+
X+  for (cap = color_dict; cap->name; cap++)
X+    if (cap->name_len == name_len
X+	&& memcmp (cap->name, name, name_len) == 0)
X+      break;
X+  if (cap->name == NULL)
X+    return "";
X+
X+  return cap->val;
X+}
X+
X+const char *
X+colorize_stop (bool show_color)
X+{
X+  return show_color ? SGR_RESET : "";
X+}
X+
X+/* Parse GCC_COLORS.  The default would look like:
X+   GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
X+   No character escaping is needed or supported.  */
X+static bool
X+parse_gcc_colors (void)
X+{
X+  const char *p, *q, *name, *val;
X+  char *b;
X+  size_t name_len = 0, val_len = 0;
X+
X+  p = getenv ("GCC_COLORS"); /* Plural! */
X+  if (p == NULL)
X+    return true;
X+  if (*p == '\0')
X+    return false;
X+
X+  name = q = p;
X+  val = NULL;
X+  /* From now on, be well-formed or you're gone.  */
X+  for (;;)
X+    if (*q == ':' || *q == '\0')
X+      {
X+	struct color_cap *cap;
X+
X+	if (val)
X+	  val_len = q - val;
X+	else
X+	  name_len = q - name;
X+	/* Empty name without val (empty cap)
X+	   won't match and will be ignored.  */
X+	for (cap = color_dict; cap->name; cap++)
X+	  if (cap->name_len == name_len
X+	      && memcmp (cap->name, name, name_len) == 0)
X+	    break;
X+	/* If name unknown, go on for forward compatibility.  */
X+	if (cap->val && val)
X+	  {
X+	    if (cap->free_val)
X+	      free (CONST_CAST (char *, cap->val));
X+	    b = XNEWVEC (char, val_len + sizeof (SGR_SEQ ("")));
X+	    memcpy (b, SGR_START, strlen (SGR_START));
X+	    memcpy (b + strlen (SGR_START), val, val_len);
X+	    memcpy (b + strlen (SGR_START) + val_len, SGR_END,
X+		    sizeof (SGR_END));
X+	    cap->val = (const char *) b;
X+	    cap->free_val = true;
X+	  }
X+	if (*q == '\0')
X+	  return true;
X+	name = ++q;
X+	val = NULL;
X+      }
X+    else if (*q == '=')
X+      {
X+	if (q == name || val)
X+	  return true;
X+
X+	name_len = q - name;
X+	val = ++q; /* Can be the empty string.  */
X+      }
X+    else if (val == NULL)
X+      q++; /* Accumulate name.  */
X+    else if (*q == ';' || (*q >= '0' && *q <= '9'))
X+      q++; /* Accumulate val.  Protect the terminal from being sent
X+	      garbage.  */
X+    else
X+      return true;
X+}
X+
X+#if defined(_WIN32)
X+static bool
X+should_colorize (void)
X+{
X+  return false;
X+}
X+
X+bool
X+colorize_init (void)
X+{
X+  return false;
X+}
X+#else
X+
X+/* Return true if we should use color when in auto mode, false otherwise. */
X+static bool
X+should_colorize (void)
X+{
X+  char const *t = getenv ("TERM");
X+  return t && strcmp (t, "dumb") != 0 && isatty (STDERR_FILENO);
X+}
X+
X+
X+bool
X+colorize_init (diagnostic_color_rule_t rule)
X+{
X+  switch (rule)
X+    {
X+    case DIAGNOSTICS_COLOR_NO:
X+      return false;
X+    case DIAGNOSTICS_COLOR_YES:
X+      return parse_gcc_colors ();
X+    case DIAGNOSTICS_COLOR_AUTO:
X+      if (should_colorize ())
X+	return parse_gcc_colors ();
X+      else
X+	return false;
X+    default:
X+      gcc_unreachable ();
X+    }
X+}
X+#endif
7ce27e8f33f1b5377cb15c35726aee8b
echo x - files/patch-gcc_diagnostic.c
sed 's/^X//' >files/patch-gcc_diagnostic.c << '326316ec1be3a844607af0a4bcad2cdf'
X--- gcc/diagnostic.c.orig
X+++ gcc/diagnostic.c
X@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
X #include "intl.h"
X #include "backtrace.h"
X #include "diagnostic.h"
X+#include "diagnostic-color.h"
X 
X #define pedantic_warning_kind(DC)                      \
X   ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
X@@ -210,12 +210,31 @@ diagnostic_build_prefix (diagnostic_context *context,
X                         const diagnostic_info *diagnostic)
X {
X   static const char *const diagnostic_kind_text[] = {
X-#define DEFINE_DIAGNOSTIC_KIND(K, T) (T),
X+#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (T),
X #include "diagnostic.def"
X #undef DEFINE_DIAGNOSTIC_KIND
X     "must-not-happen"
X   };
X+  static const char *const diagnostic_kind_color[] = {
X+#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (C),
X+#include "diagnostic.def"
X+#undef DEFINE_DIAGNOSTIC_KIND
X+    NULL
X+  };
X   const char *text = _(diagnostic_kind_text[diagnostic->kind]);
X+  const char *text_cs = "", *text_ce = "";
X+  const char *locus_cs, *locus_ce;
X+  pretty_printer *pp = context->printer;
X+
X+  if (diagnostic_kind_color[diagnostic->kind])
X+    {
X+      text_cs = colorize_start (pp_show_color (pp),
X+                               diagnostic_kind_color[diagnostic->kind]);
X+      text_ce = colorize_stop (pp_show_color (pp));
X+    }
X+  locus_cs = colorize_start (pp_show_color (pp), "locus");
X+  locus_ce = colorize_stop (pp_show_color (pp));
X+
X   expanded_location s = expand_location_to_spelling_point (diagnostic->location);
X   if (diagnostic->override_column)
X     s.column = diagnostic->override_column;
X@@ -223,10 +242,13 @@ diagnostic_build_prefix (diagnostic_context *context,
X 
X   return
X     (s.file == NULL
X-     ? build_message_string ("%s: %s", progname, text)
X+     ? build_message_string ("%s%s:%s %s%s%s", locus_cs, progname, locus_ce,
X+                            text_cs, text, text_ce)
X      : context->show_column
X-     ? build_message_string ("%s:%d:%d: %s", s.file, s.line, s.column, text)
X-     : build_message_string ("%s:%d: %s", s.file, s.line, text));
X+     ? build_message_string ("%s%s:%d:%d:%s %s%s%s", locus_cs, s.file, s.line,
X+                            s.column, locus_ce, text_cs, text, text_ce)
X+     : build_message_string ("%s%s:%d:%s %s%s%s", locus_cs, s.file, s.line, locus_ce,
X+                            text_cs, text, text_ce));
X }
X 
X /* If LINE is longer than MAX_WIDTH, and COLUMN is not smaller than
X@@ -262,7 +284,7 @@ diagnostic_show_locus (diagnostic_context * context,
X   expanded_location s;
X   int max_width;
X   const char *saved_prefix;
X-
X+  const char *caret_cs, *caret_ce;
X 
X   if (!context->show_caret
X       || diagnostic->location <= BUILTINS_LOCATION
X@@ -290,9 +312,13 @@ diagnostic_show_locus (diagnostic_context * context,
X       line++;
X     }
X   pp_newline (context->printer);
X+  caret_cs = colorize_start (pp_show_color (context->printer), "caret");
X+  caret_ce = colorize_stop (pp_show_color (context->printer));
X+
X   /* pp_printf does not implement %*c.  */
X-  buffer = XALLOCAVEC (char, s.column + 3);
X-  snprintf (buffer, s.column + 3, " %*c", s.column, '^');
X+  size_t len = s.column + 3 + strlen (caret_cs) + strlen (caret_ce);
X+  buffer = XALLOCAVEC (char, len);
X+  snprintf (buffer, len, "%s %*c%s", caret_cs, s.column, '^', caret_ce);
X   pp_string (context->printer, buffer);
X   pp_set_prefix (context->printer, saved_prefix);
X }
326316ec1be3a844607af0a4bcad2cdf
echo x - files/patch-gcc_c-family_c-format.c
sed 's/^X//' >files/patch-gcc_c-family_c-format.c << '0d3364fdf973b68b13a17e686e486286'
X--- gcc/c-family/c-format.c
X+++ gcc/c-family/c-format.c
X@@ -654,9 +654,10 @@ static const format_char_info gcc_diag_char_table[] =
X   /* Custom conversion specifiers.  */
X 
X   /* These will require a "tree" at runtime.  */
X-  { "K", 0, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q",    "",   NULL },
X+  { "K",   0, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q",    "",   NULL },
X 
X-  { "<>'", 0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X+  { "r",   1, STD_C89, { T89_C,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "",    "cR",   NULL },
X+  { "<>'R",0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X   { "m",   0, STD_C89, NOARGUMENTS, "q",     "",   NULL },
X   { NULL,  0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
X };
X@@ -676,9 +677,10 @@ static const format_char_info gcc_tdiag_char_table[] =
X   /* These will require a "tree" at runtime.  */
X   { "DFKTEV", 0, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q+", "",   NULL },
X 
X-  { "v", 0,STD_C89, { T89_I,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q#",  "",   NULL },
X+  { "v",   0, STD_C89, { T89_I,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q#",  "",   NULL },
X 
X-  { "<>'", 0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X+  { "r",   1, STD_C89, { T89_C,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "",    "cR",   NULL },
X+  { "<>'R",0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X   { "m",   0, STD_C89, NOARGUMENTS, "q",     "",   NULL },
X   { NULL,  0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
X };
X@@ -698,9 +700,10 @@ static const format_char_info gcc_cdiag_char_table[] =
X   /* These will require a "tree" at runtime.  */
X   { "DEFKTV", 0, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q+", "",   NULL },
X 
X-  { "v", 0,STD_C89, { T89_I,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q#",  "",   NULL },
X+  { "v",   0, STD_C89, { T89_I,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q#",  "",   NULL },
X 
X-  { "<>'", 0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X+  { "r",   1, STD_C89, { T89_C,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "",    "cR",   NULL },
X+  { "<>'R",0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X   { "m",   0, STD_C89, NOARGUMENTS, "q",     "",   NULL },
X   { NULL,  0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
X };
X@@ -725,7 +728,8 @@ static const format_char_info gcc_cxxdiag_char_table[] =
X   /* These accept either an 'int' or an 'enum tree_code' (which is handled as an 'int'.)  */
X   { "CLOPQ",0,STD_C89, { T89_I,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "q",  "",   NULL },
X 
X-  { "<>'", 0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X+  { "r",   1, STD_C89, { T89_C,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "",    "cR",   NULL },
X+  { "<>'R",0, STD_C89, NOARGUMENTS, "",      "",   NULL },
X   { "m",   0, STD_C89, NOARGUMENTS, "q",     "",   NULL },
X   { NULL,  0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
0d3364fdf973b68b13a17e686e486286
echo x - files/patch-gcc_cp_error.c
sed 's/^X//' >files/patch-gcc_cp_error.c << '88a37f29e530f76fb0fac40a83a68029'
X--- ./gcc/cp/error.c.orig	2013-05-09 15:51:05.000000000 +0200
X+++ ./gcc/cp/error.c	2014-02-17 19:46:58.000000000 +0100
X@@ -3010,14 +3010,14 @@
X 		    {
X 		      if (context->show_column && s.column != 0)
X 			pp_printf (context->printer,
X-				   _("    inlined from %qs at %s:%d:%d"),
X+				   _("    inlined from %qs at %r%s:%d:%d%R"),
X 				   cxx_printable_name_translate (fndecl, 2),
X-				   s.file, s.line, s.column);
X+				   "locus", s.file, s.line, s.column);
X 		      else
X 			pp_printf (context->printer,
X-				   _("    inlined from %qs at %s:%d"),
X+				   _("    inlined from %qs at %r%s:%d%R"),
X 				   cxx_printable_name_translate (fndecl, 2),
X-				   s.file, s.line);
X+				   "locus", s.file, s.line);
X 
X 		    }
X 		  else
X@@ -3099,11 +3099,11 @@
X   xloc = expand_location (loc);
X 
X   if (context->show_column)
X-    pp_verbatim (context->printer, _("%s:%d:%d:   "),
X-		 xloc.file, xloc.line, xloc.column);
X+    pp_verbatim (context->printer, _("%r%s:%d:%d:%R   "),
X+		 "locus", xloc.file, xloc.line, xloc.column);
X   else
X-    pp_verbatim (context->printer, _("%s:%d:   "),
X-		 xloc.file, xloc.line);
X+    pp_verbatim (context->printer, _("%r%s:%d:%R   "),
X+		 "locus", xloc.file, xloc.line);
X 
X   if (t != NULL)
X     {
X@@ -3177,14 +3177,16 @@
X 	  xloc = expand_location (loc);
X 	  if (context->show_column)
X 	    pp_verbatim (context->printer,
X-			 _("%s:%d:%d:   [ skipping %d instantiation contexts, "
X-			   "use -ftemplate-backtrace-limit=0 to disable ]\n"),
X-			 xloc.file, xloc.line, xloc.column, skip);
X+			 _("%r%s:%d:%d:%R   [ skipping %d instantiation "
X+			   "contexts, use -ftemplate-backtrace-limit=0 to "
X+			   "disable ]\n"),
X+			 "locus", xloc.file, xloc.line, xloc.column, skip);
X 	  else
X 	    pp_verbatim (context->printer,
X-			 _("%s:%d:   [ skipping %d instantiation contexts, "
X-			   "use -ftemplate-backtrace-limit=0 to disable ]\n"),
X-			 xloc.file, xloc.line, skip);
X+			 _("%r%s:%d:%R   [ skipping %d instantiation "
X+			   "contexts, use -ftemplate-backtrace-limit=0 to "
X+			   "disable ]\n"),
X+			 "locus", xloc.file, xloc.line, skip);
X 	  
X 	  do {
X 	    loc = t->locus;
X@@ -3246,12 +3248,12 @@
X       const char *s = expr_as_string (t, 0);
X       if (context->show_column)
X 	pp_verbatim (context->printer,
X-		     _("%s:%d:%d:   in constexpr expansion of %qs"),
X-		     xloc.file, xloc.line, xloc.column, s);
X+		     _("%r%s:%d:%d:%R   in constexpr expansion of %qs"),
X+		     "locus", xloc.file, xloc.line, xloc.column, s);
X       else
X 	pp_verbatim (context->printer,
X-		     _("%s:%d:   in constexpr expansion of %qs"),
X-		     xloc.file, xloc.line, s);
X+		     _("%r%s:%d:%R   in constexpr expansion of %qs"),
X+		     "locus", xloc.file, xloc.line, s);
X       pp_base_newline (context->printer);
X     }
X }
88a37f29e530f76fb0fac40a83a68029
echo x - files/patch-gcc_Makefile.in
sed 's/^X//' >files/patch-gcc_Makefile.in << '316c6780940ce47b4429f89b0e216eb6'
X--- gcc/Makefile.in
X+++ gcc/Makefile.in
X@@ -1463,7 +1463,7 @@
X 
X # Objects in libcommon.a, potentially used by all host binaries and with
X # no target dependencies.
X-OBJS-libcommon = diagnostic.o pretty-print.o intl.o input.o version.o
X+OBJS-libcommon = diagnostic.o diagnostic-color.o pretty-print.o intl.o input.o version.o
X 
X # Objects in libcommon-target.a, used by drivers and by the core
X # compiler and containing target-dependent code.
X@@ -2659,11 +2659,12 @@
X    $(GIMPLE_H) realmpfr.h $(TREE_FLOW_H)
X diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
X    version.h $(DEMANGLE_H) $(INPUT_H) intl.h $(BACKTRACE_H) $(DIAGNOSTIC_H) \
X-   diagnostic.def
X+   diagnostic.def diagnostic-color.h
X+diagnostic-color.o : diagnostic-color.c $(CONFIG_H) $(SYSTEM_H) diagnostic-color.h
X opts.o : opts.c $(OPTS_H) $(OPTIONS_H) $(DIAGNOSTIC_CORE_H) $(CONFIG_H) $(SYSTEM_H) \
X    coretypes.h dumpfile.h $(TM_H) \
X    $(DIAGNOSTIC_H) insn-attr-common.h intl.h $(COMMON_TARGET_H) \
X-   $(FLAGS_H) $(PARAMS_H) opts-diagnostic.h
X+   $(FLAGS_H) $(PARAMS_H) opts-diagnostic.h diagnostic-color.h
X opts-global.o : opts-global.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
X    $(DIAGNOSTIC_H) $(OPTS_H) $(FLAGS_H) $(GGC_H) $(TREE_H) langhooks.h \
X    $(TM_H) $(RTL_H) $(DBGCNT_H) debug.h $(LTO_STREAMER_H) output.h \
X@@ -2700,7 +2701,7 @@
X    $(OPTS_H) params.def tree-mudflap.h $(TREE_PASS_H) $(GIMPLE_H) \
X    tree-ssa-alias.h $(PLUGIN_H) realmpfr.h tree-diagnostic.h \
X    $(TREE_PRETTY_PRINT_H) opts-diagnostic.h $(COMMON_TARGET_H) \
X-   tsan.h
X+   tsan.h diagnostic-color.h
X 
X hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H)
X 
X@@ -3409,7 +3410,8 @@
X    $(PARAMS_H) $(DIAGNOSTIC_CORE_H)
X pointer-set.o: pointer-set.c pointer-set.h $(CONFIG_H) $(SYSTEM_H)
X hooks.o: hooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(HOOKS_H)
X-pretty-print.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(PRETTY_PRINT_H)
X+pretty-print.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(PRETTY_PRINT_H) \
X+   diagnostic-color.h
X errors.o : errors.c $(CONFIG_H) $(SYSTEM_H) errors.h
X dbgcnt.o: dbgcnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h \
X     $(DIAGNOSTIC_CORE_H) $(DBGCNT_H)
316c6780940ce47b4429f89b0e216eb6
echo x - files/patch-gcc_toplev.c
sed 's/^X//' >files/patch-gcc_toplev.c << '40c8cf1a67008fb27633a08c51b2dce1'
X--- gcc/toplev.c
X+++ gcc/toplev.c
X@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.  If not see
X #include "gimple.h"
X #include "tree-ssa-alias.h"
X #include "plugin.h"
X+#include "diagnostic-color.h"
X 
X #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
X #include "dbxout.h"
X@@ -1209,6 +1210,13 @@ process_options (void)
X 
X   maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT;
X 
X+  /* Default to -fdiagnostics-color=auto if GCC_COLORS is in the environment,
X+     otherwise default to -fdiagnostics-color=never.  */
X+  if (!global_options_set.x_flag_diagnostics_show_color
X+      && getenv ("GCC_COLORS"))
X+    pp_show_color (global_dc->printer)
X+      = colorize_init (DIAGNOSTICS_COLOR_AUTO);
X+
X   /* Allow the front end to perform consistency checks and do further
X      initialization based on the command line options.  This hook also
X      sets the original filename if appropriate (e.g. foo.i -> foo.c)
40c8cf1a67008fb27633a08c51b2dce1
echo x - files/patch-gcc_testsuite_lib_c-compat.exp
sed 's/^X//' >files/patch-gcc_testsuite_lib_c-compat.exp << 'e556f78dab48570f7019931dc3d7506d'
X--- gcc/testsuite/lib/c-compat.exp
X+++ gcc/testsuite/lib/c-compat.exp
X@@ -34,7 +34,7 @@
X # 
X proc compat-use-alt-compiler { } {
X     global GCC_UNDER_TEST ALT_CC_UNDER_TEST
X-    global compat_same_alt compat_alt_caret
X+    global compat_same_alt compat_alt_caret compat_alt_color
X     global TEST_ALWAYS_FLAGS
X 
X     # We don't need to do this if the alternate compiler is actually
X@@ -44,6 +44,9 @@ proc compat-use-alt-compiler { } {
X 	if { $compat_alt_caret == 0 } then {
X 	    regsub -- "-fno-diagnostics-show-caret" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
X 	}
X+ 	if { $compat_alt_color == 0 } then {
X+ 	    regsub -- "-fdiagnostics-color=never" $TEST_ALWAYS_FLAGS "" TEST_ALWAYS_FLAGS
X+ 	}
X     }
X }
X
X@@ -70,9 +73,11 @@
X     global compat_same_alt
X     global compat_have_dfp
X     global compat_alt_caret
X+    global compat_alt_color
X     global TEST_ALWAYS_FLAGS compat_save_TEST_ALWAYS_FLAGS
X 
X     set compat_alt_caret 0
X+    set compat_alt_color 0
X     set compat_save_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
X 
X     verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2
X@@ -88,6 +93,10 @@
X 		int dummy; } "-fno-diagnostics-show-caret"] != 0 } {
X 	    set compat_alt_caret 1
X 	}
X+ 	 	if { [check_no_compiler_messages_nocache compat_alt_has_color object {
X+ 	 	 	int dummy; } "-fdiagnostics-color=never"] != 0 } {
X+ 	 	 	set compat_alt_color 1
X+ 	 	}
X 	compat-use-tst-compiler
X     }
e556f78dab48570f7019931dc3d7506d
echo x - files/patch-gcc_diagnostic-core.h
sed 's/^X//' >files/patch-gcc_diagnostic-core.h << '061428f8ff88fa7105e9f778299df05e'
X--- gcc/diagnostic-core.h
X+++ gcc/diagnostic-core.h
X@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3.  If not see
X /* Constants used to discriminate diagnostics.  */
X typedef enum
X {
X-#define DEFINE_DIAGNOSTIC_KIND(K, msgid) K,
X+#define DEFINE_DIAGNOSTIC_KIND(K, msgid, C) K,
X #include "diagnostic.def"
X #undef DEFINE_DIAGNOSTIC_KIND
X   DK_LAST_DIAGNOSTIC_KIND,
061428f8ff88fa7105e9f778299df05e
echo x - files/patch-gcc_pretty-print.h
sed 's/^X//' >files/patch-gcc_pretty-print.h << '918379d4b01f7a1f008aeaeb4cb76843'
X--- gcc/pretty-print.h
X+++ gcc/pretty-print.h
X@@ -151,6 +151,9 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
X    output.  */
X #define pp_translate_identifiers(PP) pp_base (PP)->translate_identifiers
X 
X+/* True if colors should be shown.  */
X+#define pp_show_color(PP) pp_base (PP)->show_color
X+
X /* The data structure that contains the bare minimum required to do
X    proper pretty-printing.  Clients may derived from this structure
X    and add additional fields they need.  */
X@@ -194,6 +197,9 @@ struct pretty_print_info
X   /* Nonzero means identifiers are translated to the locale character
X      set on output.  */
X   bool translate_identifiers;
X+
X+  /* Nonzero means that text should be colorized.  */
X+  bool show_color;
X };
X 
X #define pp_set_line_maximum_length(PP, L) \
918379d4b01f7a1f008aeaeb4cb76843
echo x - files/patch-gcc_langhooks.c
sed 's/^X//' >files/patch-gcc_langhooks.c << '3659d50959e6980b1bc667442790564c'
X--- gcc/langhooks.c
X+++ gcc/langhooks.c
X@@ -452,14 +452,14 @@
X 		    {
X 		      if (context->show_column)
X 			pp_printf (context->printer,
X-				   _("    inlined from %qs at %s:%d:%d"),
X+				   _("    inlined from %qs at %r%s:%d:%d%R"),
X 				   identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
X-				   s.file, s.line, s.column);
X+				   "locus", s.file, s.line, s.column);
X 		      else
X 			pp_printf (context->printer,
X-				   _("    inlined from %qs at %s:%d"),
X+				   _("    inlined from %qs at %r%s:%d%R"),
X 				   identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
X-				   s.file, s.line);
X+				   "locus", s.file, s.line);
X 
X 		    }
X 		  else
3659d50959e6980b1bc667442790564c
echo x - files/patch-gcc_diagnostic.def
sed 's/^X//' >files/patch-gcc_diagnostic.def << 'aaef6f41a8c68aa86329ca09c0126fa7'
X--- gcc/diagnostic.def
X+++ gcc/diagnostic.def
X@@ -22,26 +22,26 @@
X    kind specified.  I.e. they're uninitialized.  Within the diagnostic
X    machinery, this kind also means "don't change the existing kind",
X    meaning "no change is specified".  */
X-DEFINE_DIAGNOSTIC_KIND (DK_UNSPECIFIED, "")
X+DEFINE_DIAGNOSTIC_KIND (DK_UNSPECIFIED, "", NULL)
X 
X /* If a diagnostic is set to DK_IGNORED, it won't get reported at all.
X    This is used by the diagnostic machinery when it wants to disable a
X    diagnostic without disabling the option which causes it.  */
X-DEFINE_DIAGNOSTIC_KIND (DK_IGNORED, "")
X+DEFINE_DIAGNOSTIC_KIND (DK_IGNORED, "", NULL)
X 
X /* The remainder are real diagnostic types.  */
X-DEFINE_DIAGNOSTIC_KIND (DK_FATAL, "fatal error: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_ICE, "internal compiler error: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_ERROR, "error: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_SORRY, "sorry, unimplemented: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_WARNING, "warning: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_ANACHRONISM, "anachronism: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_NOTE, "note: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_DEBUG, "debug: ")
X+DEFINE_DIAGNOSTIC_KIND (DK_FATAL, "fatal error: ", "error")
X+DEFINE_DIAGNOSTIC_KIND (DK_ICE, "internal compiler error: ", "error")
X+DEFINE_DIAGNOSTIC_KIND (DK_ERROR, "error: ", "error")
X+DEFINE_DIAGNOSTIC_KIND (DK_SORRY, "sorry, unimplemented: ", "error")
X+DEFINE_DIAGNOSTIC_KIND (DK_WARNING, "warning: ", "warning")
X+DEFINE_DIAGNOSTIC_KIND (DK_ANACHRONISM, "anachronism: ", "warning")
X+DEFINE_DIAGNOSTIC_KIND (DK_NOTE, "note: ", "note")
X+DEFINE_DIAGNOSTIC_KIND (DK_DEBUG, "debug: ", "note")
X /* These two would be re-classified as DK_WARNING or DK_ERROR, so the
X prefix does not matter.  */
X-DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ")
X-DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ")
X+DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ", NULL)
X+DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ", NULL)
X 
X 
aaef6f41a8c68aa86329ca09c0126fa7
echo x - files/patch-gcc_doc_invoke.texi
sed 's/^X//' >files/patch-gcc_doc_invoke.texi << 'ce6c7cc87b1a367f422f0c79cca89183'
X--- gcc/doc/invoke.texi
X+++ gcc/doc/invoke.texi
X@@ -226,6 +226,7 @@ Objective-C and Objective-C++ Dialects}.
X @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
X @gccoptlist{-fmessage-length=@var{n}  @gol
X -fdiagnostics-show-location=@r{[}once at r{|}every-line at r{]}  @gol
X+-fdiagnostics-color=@r{[}auto at r{|}never at r{|}always at r{]}  @gol
X -fno-diagnostics-show-option -fno-diagnostics-show-caret}
X 
X @item Warning Options
X@@ -2956,6 +2957,77 @@ messages reporter to emit the same source location information (as
X prefix) for physical lines that result from the process of breaking
X a message which is too long to fit on a single line.
X 
X+ at item -fdiagnostics-color[=@var{WHEN}]
X+ at itemx -fno-diagnostics-color
X+ at opindex fdiagnostics-color
X+ at cindex highlight, color, colour
X+ at vindex GCC_COLORS @r{environment variable}
X+Use color in diagnostics.  @var{WHEN} is @samp{never}, @samp{always},
X+or @samp{auto}.  The default is @samp{never} if @env{GCC_COLORS} environment
X+variable isn't present in the environment, and @samp{auto} otherwise.
X+ at samp{auto} means to use color only when the standard error is a terminal.
X+The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
X+aliases for @option{-fdiagnostics-color=always} and
X+ at option{-fdiagnostics-color=never}, respectively.
X+
X+The colors are defined by the environment variable @env{GCC_COLORS}.
X+Its value is a colon-separated list of capabilities and Select Graphic
X+Rendition (SGR) substrings. SGR commands are interpreted by the
X+terminal or terminal emulator.  (See the section in the documentation
X+of your text terminal for permitted values and their meanings as
X+character attributes.)  These substring values are integers in decimal
X+representation and can be concatenated with semicolons.
X+Common values to concatenate include
X+ at samp{1} for bold,
X+ at samp{4} for underline,
X+ at samp{5} for blink,
X+ at samp{7} for inverse,
X+ at samp{39} for default foreground color,
X+ at samp{30} to @samp{37} for foreground colors,
X+ at samp{90} to @samp{97} for 16-color mode foreground colors,
X+ at samp{38;5;0} to @samp{38;5;255}
X+for 88-color and 256-color modes foreground colors,
X+ at samp{49} for default background color,
X+ at samp{40} to @samp{47} for background colors,
X+ at samp{100} to @samp{107} for 16-color mode background colors,
X+and @samp{48;5;0} to @samp{48;5;255}
X+for 88-color and 256-color modes background colors.
X+
X+The default @env{GCC_COLORS} is
X+ at samp{error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01}
X+where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
X+ at samp{01;36} is bold cyan, @samp{01;32} is bold green and
X+ at samp{01} is bold. Setting @env{GCC_COLORS} to the empty
X+string disables colors.
X+Supported capabilities are as follows.
X+
X+ at table @code
X+ at item error=
X+ at vindex error GCC_COLORS @r{capability}
X+SGR substring for error: markers.
X+
X+ at item warning=
X+ at vindex warning GCC_COLORS @r{capability}
X+SGR substring for warning: markers.
X+
X+ at item note=
X+ at vindex note GCC_COLORS @r{capability}
X+SGR substring for note: markers.
X+
X+ at item caret=
X+ at vindex caret GCC_COLORS @r{capability}
X+SGR substring for caret line.
X+
X+ at item locus=
X+ at vindex locus GCC_COLORS @r{capability}
X+SGR substring for location information, @samp{file:line} or
X+ at samp{file:line:column} etc.
X+
X+ at item quote=
X+ at vindex quote GCC_COLORS @r{capability}
X+SGR substring for information printed within quotes.
X+ at end table
X+
X @item -fno-diagnostics-show-option
X @opindex fno-diagnostics-show-option
X @opindex fdiagnostics-show-option
ce6c7cc87b1a367f422f0c79cca89183
echo x - files/patch-gcc_diagnostic-color.h
sed 's/^X//' >files/patch-gcc_diagnostic-color.h << '969da4dce556f7982f64542e38d373cc'
X--- /dev/null
X+++ gcc/diagnostic-color.h
X@@ -0,0 +1,66 @@
X+/* Copyright (C) 2013 Free Software Foundation, Inc.
X+   Contributed by Manuel Lopez-Ibanez <manu at gcc.gnu.org>
X+
X+This file is part of GCC.
X+
X+GCC is free software; you can redistribute it and/or modify it under
X+the terms of the GNU General Public License as published by the Free
X+Software Foundation; either version 3, or (at your option) any later
X+version.
X+
X+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
X+WARRANTY; without even the implied warranty of MERCHANTABILITY or
X+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
X+for more details.
X+
X+You should have received a copy of the GNU General Public License
X+along with GCC; see the file COPYING3.  If not see
X+<http://www.gnu.org/licenses/>.  */
X+
X+/* Based on code from: */
X+/* grep.c - main driver file for grep.
X+   Copyright (C) 1992, 1997-2002, 2004-2013 Free Software Foundation, Inc.
X+
X+   This program is free software; you can redistribute it and/or modify
X+   it under the terms of the GNU General Public License as published by
X+   the Free Software Foundation; either version 3, or (at your option)
X+   any later version.
X+
X+   This program is distributed in the hope that it will be useful,
X+   but WITHOUT ANY WARRANTY; without even the implied warranty of
X+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X+   GNU General Public License for more details.
X+
X+   You should have received a copy of the GNU General Public License
X+   along with this program; if not, write to the Free Software
X+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
X+   02110-1301, USA.
X+
X+   Written July 1992 by Mike Haertel.  */
X+
X+#ifndef GCC_DIAGNOSTIC_COLOR_H
X+#define GCC_DIAGNOSTIC_COLOR_H
X+
X+/* How often diagnostics are prefixed by their locations:
X+   o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported;
X+   o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit only once;
X+   o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit each time a physical
X+   line is started.  */
X+typedef enum
X+{
X+  DIAGNOSTICS_COLOR_NO       = 0,
X+  DIAGNOSTICS_COLOR_YES      = 1,
X+  DIAGNOSTICS_COLOR_AUTO     = 2
X+} diagnostic_color_rule_t;
X+
X+const char *colorize_start (bool, const char *, size_t);
X+const char *colorize_stop (bool);
X+bool colorize_init (diagnostic_color_rule_t);
X+
X+inline const char *
X+colorize_start (bool show_color, const char *name)
X+{
X+  return colorize_start (show_color, name, strlen (name));
X+}
X+
X+#endif /* ! GCC_DIAGNOSTIC_COLOR_H */
969da4dce556f7982f64542e38d373cc
echo x - files/patch-gcc_dwarf2out.c
sed 's/^X//' >files/patch-gcc_dwarf2out.c << 'ad4d1a4ca20ce1fbed8348f859eeb78b'
X--- gcc/dwarf2out.c
X+++ gcc/dwarf2out.c
X@@ -18828,6 +18828,7 @@ gen_producer_string (void)
X       case OPT_fdiagnostics_show_location_:
X       case OPT_fdiagnostics_show_option:
X       case OPT_fdiagnostics_show_caret:
X+      case OPT_fdiagnostics_color_:
X       case OPT_fverbose_asm:
X       case OPT____:
X       case OPT__sysroot_:
ad4d1a4ca20ce1fbed8348f859eeb78b
echo x - files/patch-gcc_pretty-print.c
sed 's/^X//' >files/patch-gcc_pretty-print.c << 'a410b22ff12fea749baa3bd690b09af9'
X--- ./gcc/pretty-print.c.orig	2013-01-10 21:38:27.000000000 +0100
X+++ ./gcc/pretty-print.c	2014-02-17 21:27:57.000000000 +0100
X@@ -23,6 +23,7 @@
X #include "coretypes.h"
X #include "intl.h"
X #include "pretty-print.h"
X+#include "diagnostic-color.h"
X 
X #if HAVE_ICONV
X #include <iconv.h>
X@@ -226,6 +227,8 @@
X    %c: character.
X    %s: string.
X    %p: pointer.
X+   %r: if pp_show_color(pp), switch to color identified by const char *.
X+   %R: if pp_show_color(pp), reset color.
X    %m: strerror(text->err_no) - does not consume a value from args_ptr.
X    %%: '%'.
X    %<: opening quote.
X@@ -300,18 +303,37 @@
X 	  continue;
X 
X 	case '<':
X-	  obstack_grow (&buffer->chunk_obstack,
X-			open_quote, strlen (open_quote));
X-	  p++;
X-	  continue;
X+	  {
X+	    obstack_grow (&buffer->chunk_obstack,
X+	        open_quote, strlen (open_quote));
X+	    const char *colorstr
X+	      = colorize_start (pp_show_color (pp), "quote");
X+	    obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr));
X+	    p++;
X+	    continue;
X+	  }
X 
X 	case '>':
X+	  {
X+	    const char *colorstr = colorize_stop (pp_show_color (pp));
X+	    obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr));
X+	  }
X+	  /* FALLTHRU */
X 	case '\'':
X 	  obstack_grow (&buffer->chunk_obstack,
X 			close_quote, strlen (close_quote));
X 	  p++;
X 	  continue;
X 
X+	case 'R':
X+	  {
X+	    const char *colorstr = colorize_stop (pp_show_color (pp));
X+	    obstack_grow (&buffer->chunk_obstack, colorstr,
X+	        strlen (colorstr));
X+	    p++;
X+	    continue;
X+	  }
X+
X 	case 'm':
X 	  {
X 	    const char *errstr = xstrerror (text->err_no);
X@@ -466,10 +488,19 @@
X       gcc_assert (!wide || precision == 0);
X 
X       if (quote)
X-	pp_string (pp, open_quote);
X+        {
X+          pp_string (pp, open_quote);
X+          pp_string (pp, colorize_start (pp_show_color (pp), "quote"));
X+        }
X 
X       switch (*p)
X 	{
X+	case 'r':
X+	  pp_string (pp, colorize_start (pp_show_color (pp),
X+	      va_arg (*text->args_ptr,
X+	          const char *)));
X+	  break;
X+
X 	case 'c':
X 	  pp_character (pp, va_arg (*text->args_ptr, int));
X 	  break;
X@@ -563,7 +594,10 @@
X 	}
X 
X       if (quote)
X-	pp_string (pp, close_quote);
X+	    {
X+	      pp_string (pp, colorize_stop (pp_show_color (pp)));
X+	      pp_string (pp, close_quote);
X+	    }
X 
X       obstack_1grow (&buffer->chunk_obstack, '\0');
X       *formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *);
a410b22ff12fea749baa3bd690b09af9
echo x - files/patch-gcc_opts.c
sed 's/^X//' >files/patch-gcc_opts.c << 'c013264529888ccebdaefbb212b56d6a'
X--- gcc/opts.c
X+++ gcc/opts.c
X@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
X #include "flags.h"
X #include "params.h"
X #include "diagnostic.h"
X+#include "diagnostic-color.h"
X #include "opts-diagnostic.h"
X #include "insn-attr-common.h"
X #include "common/common-target.h"
X@@ -1497,6 +1498,11 @@ common_handle_option (struct gcc_options *opts,
X       dc->show_caret = value;
X       break;
X 
X+    case OPT_fdiagnostics_color_:
X+      pp_show_color (dc->printer)
X+       = colorize_init ((diagnostic_color_rule_t) value);
X+      break;
X+
X     case OPT_fdiagnostics_show_option:
X       dc->show_option_requested = value;
X       break;
c013264529888ccebdaefbb212b56d6a
echo x - files/patch-gcc_testsuite_lib_prune.exp
sed 's/^X//' >files/patch-gcc_testsuite_lib_prune.exp << 'a62f02ad894cd7784e76bd9581241ad8'
X--- gcc/testsuite/lib/prune.exp
X+++ gcc/testsuite/lib/prune.exp
X@@ -19,7 +19,7 @@
X if ![info exists TEST_ALWAYS_FLAGS] {
X     set TEST_ALWAYS_FLAGS ""
X }
X-set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret $TEST_ALWAYS_FLAGS"
X+set TEST_ALWAYS_FLAGS "-fno-diagnostics-show-caret -fdiagnostics-color=never $TEST_ALWAYS_FLAGS"
X 
X proc prune_gcc_output { text } {
X     #send_user "Before:$text\n"
a62f02ad894cd7784e76bd9581241ad8
exit



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ports-bugs mailing list