[CGit] [PATCH v2 3/6] new_filter: determine extra_args from filter type

Lars Hjemli hjemli at gmail.com
Sun Mar 6 15:50:17 CET 2011


On Fri, Mar 4, 2011 at 01:31, Ferry Huberts <mailings at hupie.com> wrote:
> -struct cgit_filter *new_filter(const char *cmd, int extra_args)
> +struct cgit_filter *new_filter(const char *cmd, filter_type filtertype)
>  {
>        int i = 0;
>        struct cgit_filter *f;
> +       int extra_args;
>
>        if (!cmd || !cmd[0])
>                return NULL;
>
> +       switch (filtertype) {
> +               case SOURCE:
> +                       extra_args = 1;
> +                       break;
> +
> +               case ABOUT:
> +               case COMMIT:
> +               default:
> +                       extra_args = 0;
> +                       break;
> +       }
> +

Not sure if I like this since it is the caller who knows how many
extra args it will need. But the patch avoids duplicate magic numbers,
so I'll have to think about this one a little more.

--
larsh


More information about the CGit mailing list