Re: [PATCH 2/3] color.c: support bright aixterm colors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eyal Soha <shawarmakarma@xxxxxxxxx> writes:

> +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...

> +	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).

> +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.

> @@ -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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux