diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-12-01 18:20:12 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-12-01 18:20:12 +0100 |
commit | 8ace53dd73ea48a106ef28590b743d16e81f7867 (patch) | |
tree | 19a1cac6157d57b3f51cf93718d3f61732b800cc /src/colors.c | |
parent | b348116e2d6f072c528f0e04e00037681a40ca71 (diff) |
fix #RGB color parsing
Diffstat (limited to 'src/colors.c')
-rw-r--r-- | src/colors.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/colors.c b/src/colors.c index f293249d..ea1c3391 100644 --- a/src/colors.c +++ b/src/colors.c @@ -204,7 +204,7 @@ static const struct key { #define NCOLORS (sizeof(color_keyword) / sizeof(struct key)) /* - * Parse a color in hex (RRGGBB) + * Parse a color in hex (RRGGBB) or (RGB) * * Return Value: * parsed color if successful (err = 0), @@ -217,9 +217,13 @@ static int32_t Color_parse_hex (const char *s, int32_t default_color, int *err) *err = 1; ret_color = strtol(s, &tail, 16); - if (tail - s == 6 || tail - s == 3) + if (tail - s == 6) *err = 0; - else + else if (tail - s == 3) { /* #RGB as allowed by CSS */ + *err = 0; + ret_color = ((ret_color & 0xf00) << 12) | + ((ret_color & 0x0f0) << 8) | ((ret_color & 0x00f) << 4); + } else ret_color = default_color; return ret_color; |