Re: [PATCH 2/3] color.c: support bright aixterm colors
flat view
From: Junio C Hamano <hidden>
Date: 2020-01-23 22:54:29
Eyal Soha [off-list ref] writes:
quoted hunk
+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...
quoted hunk
+ 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).
quoted hunk
+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.
quoted hunk
@@ -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.