Re: [PATCH v6 02/11] Add git-column and column mode parsing
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Feb 28, 2012, 11:00 UTC
- Message-ID
- <CACsJy8AAi7N39a1zrKpTGoFJbySxUZvh2JZRyhyE-0tXk3-sGA@mail.gmail.com>
- In-Reply-To
- <4F4BE300.2060302@ramsay1.demon.co.uk>
2012/2/28 Ramsay Jones <ramsay@ramsay1.demon.co.uk>:
Show 29 quoted lines
> Nguyễn Thái Ngọc Duy wrote:
> [...]
>> +static int parse_option(const char *arg, int len,
>> + unsigned int *mode, int stdout_is_tty)
>> +{
>> + struct colopt opts[] = {
>> + { ENABLE, "always", 1 },
>> + { ENABLE, "never", 0 },
>> + { ENABLE, "auto", -1 },
>> + };
>
> Hmm, I don't recognise this table from last time ...
>
>> + }
>> + }
>> +
>> + name_len = strlen(opts[i].name);
>> + if (arg_len != name_len ||
>> + strncmp(arg_str, opts[i].name, name_len))
>> + continue;
>> +
>> + switch (opts[i].type) {
>> + case ENABLE:
>> + return set_enable_bit(mode, opts[i].value,
>> + stdout_is_tty);
>
> given the above table, can the following case limbs ever be reached?
> (the "no" prefix is only applied to the OPTION type, so most of the
> above code seems to be useless now ...)Not in this patch, no. The table is extended later on with more modes and options.
Show 13 quoted lines
>
>> + case MODE:
>> + return set_mode(mode, opts[i].value);
>> + case OPTION:
>> + return set_option(mode, opts[i].value, set);
>> + default:
>> + die("BUG: Unknown option type %d", opts[i].type);
>> + }
>> + }
>> +
>> + return error("unsupported style '%s'", arg);
>> +}
>> +-- Duy