summaryrefslogtreecommitdiffstats
path: root/generic/tkColor.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-26 12:21:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-26 12:21:00 (GMT)
commit344dce41c2bb55fa7708a2257500ab98ef51829e (patch)
tree82c582be8e0a2a20bfec9b42a17d5bd863e4222c /generic/tkColor.c
parentf7b1124c07e651cda35446f85222b3001bf1808c (diff)
parent64231492f3d4efcbc7b9874442e69a650d730591 (diff)
downloadtk-344dce41c2bb55fa7708a2257500ab98ef51829e.zip
tk-344dce41c2bb55fa7708a2257500ab98ef51829e.tar.gz
tk-344dce41c2bb55fa7708a2257500ab98ef51829e.tar.bz2
implement for Unix as well
Diffstat (limited to 'generic/tkColor.c')
-rw-r--r--generic/tkColor.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c
index 6a0ea7a..c538365 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -826,8 +826,41 @@ TkDebugColor(
}
#ifndef __WIN32__
+
/* This function is not necessary for Win32,
* since XParseColor already does the right thing */
+
+#undef XParseColor
+
+static CONST char *CONST webColors[] = {
+ /* 'a' */ "qua\0#0000ffffffff",
+ /* 'b' */ NULL,
+ /* 'c' */ "rimson\0#dcdc14143c3c",
+ /* 'd' */ NULL,
+ /* 'e' */ NULL,
+ /* 'f' */ "uchsia\0#ffff0000ffff",
+ /* 'g' */ "reen\0#000080800000",
+ /* 'h' */ NULL,
+ /* 'i' */ "ndigo\0#4b4b00008282",
+ /* 'j' */ NULL,
+ /* 'k' */ NULL,
+ /* 'l' */ "ime\0#0000ffff0000",
+ /* 'm' */ "aroon\0#808000000000",
+ /* 'n' */ NULL,
+ /* 'o' */ "live\0#808080800000",
+ /* 'p' */ "urple\0#808000008080",
+ /* 'q' */ NULL,
+ /* 'r' */ NULL,
+ /* 's' */ "ilver\0#c0c0c0c0c0c0",
+ /* 't' */ "eal\0#000080808080",
+ /* 'u' */ NULL,
+ /* 'v' */ NULL,
+ /* 'w' */ NULL,
+ /* 'x' */ NULL,
+ /* 'y' */ NULL,
+ /* 'z' */ NULL
+};
+
Status
TkParseColor(
Display *display, /* The display */
@@ -880,12 +913,30 @@ TkParseColor(
} else {
name -= 13;
}
- } else {
- if (strlen(name) > 99) {
- /* Don't bother to parse this. [Bug 2809525]*/
- return 0;
+ goto done;
+ } else if (((*name - 'A') & 0xdf) < sizeof(webColors)/sizeof(webColors[0])) {
+ if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf)
+ && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf)
+ && !name[4]) {
+ name = "#808080808080";
+ goto done;
+ } else {
+ const char *p = webColors[((*name - 'A') & 0x1f)];
+ if (p) {
+ const char *q = name;
+ while (!((*p - *(++q)) & 0xdf)) {
+ if (!*p++) {
+ name = p;
+ goto done;
+ }
+ }
+ }
}
}
+ if (strlen(name) > 99) {
+ return 0;
+ }
+done:
return XParseColor(display, map, name, color);
}
#endif /* __WIN32__ */