summaryrefslogtreecommitdiffstats
path: root/generic/tkColor.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-02-15 20:33:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-02-15 20:33:58 (GMT)
commit05750b46ee02ad06be61476b42f8a1a8d8a87597 (patch)
tree31fe161db5699e5d076d9a6dbf02882e9db7aad0 /generic/tkColor.c
parentd0aa23eb9005cbc9b4e706ab70b5082be80bad35 (diff)
parent505d8dc8bc999b995961dbd32c518620d843bdfe (diff)
downloadtk-05750b46ee02ad06be61476b42f8a1a8d8a87597.zip
tk-05750b46ee02ad06be61476b42f8a1a8d8a87597.tar.gz
tk-05750b46ee02ad06be61476b42f8a1a8d8a87597.tar.bz2
[Bug 3486474]: Inconsistent color scaling
Diffstat (limited to 'generic/tkColor.c')
-rw-r--r--generic/tkColor.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c
index f06c43f..8893dfe 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -809,3 +809,58 @@ TkDebugColor(tkwin, name)
}
return resultPtr;
}
+
+#ifndef __WIN32__
+/* This function is not necessary for Win32,
+ * since XParseColor already does the right thing */
+Status
+TkParseColor(display, map, spec, colorPtr)
+ Display * display; /* The display */
+ Colormap map; /* Color map */
+ _Xconst char* spec; /* String to be parsed */
+ XColor * colorPtr;
+{
+ if (*spec == '#') {
+ char buf[14];
+ buf[0] = '#'; buf[13] = '\0';
+ if (!*(++spec) || !*(++spec) || !*(++spec)) {
+ /* Not at least 3 hex digits, so invalid */
+ return 0;
+ } else if (!*(++spec)) {
+ /* Exactly 3 hex digits */
+ buf[9] = buf[10] = buf[11] = buf[12] = *(--spec);
+ buf[5] = buf[6] = buf[7] = buf[8] = *(--spec);
+ buf[1] = buf[2] = buf[3] = buf[4] = *(--spec);
+ spec = buf;
+ } else if (!*(++spec) || !*(++spec)) {
+ /* Not at least 6 hex digits, so invalid */
+ return 0;
+ } else if (!*(++spec)) {
+ /* Exactly 6 hex digits */
+ buf[10] = buf[12] = *(--spec);
+ buf[9] = buf[11] = *(--spec);
+ buf[6] = buf[8] = *(--spec);
+ buf[5] = buf[7] = *(--spec);
+ buf[2] = buf[4] = *(--spec);
+ buf[1] = buf[3] = *(--spec);
+ spec = buf;
+ } else if (!*(++spec) || !*(++spec)) {
+ /* Not at least 9 hex digits, so invalid */
+ return 0;
+ } else if (!*(++spec)) {
+ /* Exactly 9 hex digits */
+ buf[11] = *(--spec);
+ buf[10] = *(--spec);
+ buf[9] = buf[12] = *(--spec);
+ buf[7] = *(--spec);
+ buf[6] = *(--spec);
+ buf[5] = buf[8] = *(--spec);
+ buf[3] = *(--spec);
+ buf[2] = *(--spec);
+ buf[1] = buf[4] = *(--spec);
+ spec = buf;
+ }
+ }
+ return XParseColor(display, map, spec, colorPtr);
+}
+#endif /* __WIN32__ */