summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/colors.c10
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;