aboutsummaryrefslogtreecommitdiff
path: root/src/colors.c
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-08-20 23:24:19 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-08-20 23:24:19 +0200
commitf5c598b518d1f906148534d015f50075d3e8242d (patch)
tree21dd70add5b366c3dd80641b77f6b18e0baa009e /src/colors.c
parente98d02a01ffeb18ede86af025e51ae1ec011c75a (diff)
parent5f0fc0e48b8cbee7e1795935da0abff6627fd498 (diff)
merge
Diffstat (limited to 'src/colors.c')
-rw-r--r--src/colors.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/colors.c b/src/colors.c
index 9a4c8c8e..5b647bb2 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),
@@ -219,7 +219,12 @@ static int32_t Color_parse_hex (const char *s, int32_t default_color, int *err)
ret_color = strtol(s, &tail, 16);
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 & 0xf00) << 8) |
+ ((ret_color & 0x0f0) << 8) | ((ret_color & 0x0f0) << 4) |
+ ((ret_color & 0x00f) << 4) | ((ret_color & 0x00f) << 0);
+ } else
ret_color = default_color;
return ret_color;
@@ -241,7 +246,7 @@ int32_t a_Color_parse (const char *subtag, int32_t default_color, int *err)
int ret, low, mid, high, st = 1;
/* skip leading spaces */
- for (cp = subtag; isspace(*cp); cp++);
+ for (cp = subtag; dIsspace(*cp); cp++);
ret_color = default_color;
if (*cp == '#') {