On Tue, Dec 02, 2014 at 12:40:12AM +0100, Manuel López-Ibáñez wrote:
> 2014-12-02  Manuel López-Ibáñez  <m...@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

Reply via email to