This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH driver/diagnostics] init color earlier, add color to driver
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Dodji Seketeli <dodji at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Wed, 3 Dec 2014 08:59:10 +0100
- Subject: Re: [PATCH driver/diagnostics] init color earlier, add color to driver
- Authentication-results: sourceware.org; auth=none
- References: <CAESRpQA5BYi1+ZYomGFwAMkY+6n7YbKPQS1YsC=C3u5A2DZZpw at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Dec 02, 2014 at 12:40:12AM +0100, Manuel López-Ibáñez wrote:
> 2014-12-02 Manuel López-Ibáñez <manu@gcc.gnu.org>
>
> * diagnostic.c (diagnostic_color_init): New.
> * diagnostic.h: Declare.
> * gcc.c (driver::global_initializations): Use it.
> (driver_handle_option): Handle -fdiagnostics-color_.
> * toplev.c: Do not include diagnostic-color.h.
> (process_options): Do not initialize color diagnostics here.
> * common.opt (fdiagnostics-color=): Add Driver.
> * opts-global.c (init_options_once): Initialize color here.
>
>
> A possible improvement (in my opinion) would be to have
>
> void
> diagnostic_color_init (diagnostic_context *context,
> int value = DIAGNOSTICS_COLOR_DEFAULT)
> {
> /* If DIAGNOSTICS_COLOR_DEFAULT is -1, default to -fdiagnostics-color=auto
> if GCC_COLORS is in the environment, otherwise default to
> -fdiagnostics-color=never, for other values default to that
> -fdiagnostics-color={never,auto,always}. */
> switch (value)
> {
> case -1:
> if (!getenv ("GCC_COLORS"))
> break;
> value = DIAGNOSTICS_COLOR_AUTO;
> /* FALLTHRU */
> default:
> pp_show_color (context->printer)
> = colorize_init ((diagnostic_color_rule_t) value);
> break;
> }
> }
I think using a default argument for this is fine, though of course
you need to declare the default argument in the header containing
the prototype, not in the function definition.
Ok with that change.
Jakub