Re: [PATCH 2/3] color.c: support bright aixterm colors
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 23, 2020, 22:54 UTC
- Message-ID
- <xmqqo8ut3hsu.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20200121165623.151880-2-shawarmakarma@gmail.com>
Eyal Soha <shawarmakarma@gmail.com> writes:
Show 9 quoted lines
> +static int parse_ansi_color(struct color *out, const char *name, int len)
> {
> /* Positions in array must match ANSI color codes */
> static const char * const color_names[] = {
> "black", "red", "green", "yellow",
> "blue", "magenta", "cyan", "white"
> };
> +
> + int color_offset = COLOR_FOREGROUND_ANSI;No need for the blank line before this line, but a blank line after the last decl/defn is a good idea. You'd need to define "int i" here, too, as...
Show 6 quoted lines
> + if (strncasecmp(name, "bright", 6) == 0) {
> + color_offset = COLOR_FOREGROUND_BRIGHT_ANSI;
> + name += 6;
> + len -= 6;
> + }
> + for (int i = 0; i < ARRAY_SIZE(color_names); i++) {... we do not (unfortunately) allow declaring a variable in the set-up part of a for loop yet (see Documentation/CodingGuidelines).
Show 5 quoted lines
> +static int parse_color(struct color *out, const char *name, int len)
> +{
> char *end;
> int i;
> long val;With the removal of the loop, "int i" no longer is used in this function. Remove its defn here.
Show 13 quoted lines
> @@ -96,12 +120,8 @@ static int parse_color(struct color *out, const char *name, int len)
> }
>
> /* Then pick from our human-readable color names... */
> - for (i = 0; i < ARRAY_SIZE(color_names); i++) {
> - if (match_word(name, len, color_names[i])) {
> - out->type = COLOR_ANSI;
> - out->value = i + COLOR_FOREGROUND_ANSI;
> - return 0;
> - }
> + if (parse_ansi_color(out, name, len) == 0) {
> + return 0;
> }Thanks.