summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixColor.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixColor.c')
-rw-r--r--unix/tkUnixColor.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/unix/tkUnixColor.c b/unix/tkUnixColor.c
index 9474c95..43500ad 100644
--- a/unix/tkUnixColor.c
+++ b/unix/tkUnixColor.c
@@ -10,7 +10,7 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tkInt.h"
+#include "tkUnixInt.h"
#include "tkColor.h"
/*
@@ -137,16 +137,23 @@ TkpGetColor(
XColor screen;
if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) {
- const char *p = tkWebColors[((*name - 'A') & 0x1f)];
- if (p) {
- const char *q = name;
- while (!((*p - *(++q)) & 0xdf)) {
- if (!*p++) {
- name = p;
- goto gotWebColor;
+ if (!((name[0] - 'G') & 0xdf) && !((name[1] - 'R') & 0xdf)
+ && !((name[2] - 'A') & 0xdb) && !((name[3] - 'Y') & 0xdf)
+ && !name[4]) {
+ name = "#808080808080";
+ goto gotWebColor;
+ } else {
+ const char *p = tkWebColors[((*name - 'A') & 0x1f)];
+ if (p) {
+ const char *q = name;
+ while (!((*p - *(++q)) & 0xdf)) {
+ if (!*p++) {
+ name = p;
+ goto gotWebColor;
+ }
}
}
- }
+ }
}
if (strlen(name) > 99) {
/* Don't bother to parse this. [Bug 2809525]*/
@@ -178,7 +185,7 @@ TkpGetColor(
}
}
- tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
+ tkColPtr = ckalloc(sizeof(TkColor));
tkColPtr->color = color;
return tkColPtr;
@@ -213,7 +220,7 @@ TkpGetColorByValue(
{
Display *display = Tk_Display(tkwin);
Colormap colormap = Tk_Colormap(tkwin);
- TkColor *tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
+ TkColor *tkColPtr = ckalloc(sizeof(TkColor));
tkColPtr->color.red = colorPtr->red;
tkColPtr->color.green = colorPtr->green;
@@ -271,7 +278,7 @@ FindClosestColor(
for (stressPtr = dispPtr->stressPtr; ; stressPtr = stressPtr->nextPtr) {
if (stressPtr == NULL) {
- stressPtr = (TkStressedCmap *) ckalloc(sizeof(TkStressedCmap));
+ stressPtr = ckalloc(sizeof(TkStressedCmap));
stressPtr->colormap = colormap;
template.visualid = XVisualIDFromVisual(Tk_Visual(tkwin));
@@ -283,8 +290,8 @@ FindClosestColor(
stressPtr->numColors = visInfoPtr->colormap_size;
XFree((char *) visInfoPtr);
- stressPtr->colorPtr = (XColor *) ckalloc((unsigned)
- (stressPtr->numColors * sizeof(XColor)));
+ stressPtr->colorPtr =
+ ckalloc(stressPtr->numColors * sizeof(XColor));
for (i = 0; i < stressPtr->numColors; i++) {
stressPtr->colorPtr[i].pixel = (unsigned long) i;
}
@@ -392,8 +399,8 @@ DeleteStressedCmap(
} else {
prevPtr->nextPtr = stressPtr->nextPtr;
}
- ckfree((char *) stressPtr->colorPtr);
- ckfree((char *) stressPtr);
+ ckfree(stressPtr->colorPtr);
+ ckfree(stressPtr);
return;
}
}
@@ -433,6 +440,7 @@ TkpCmapStressed(
return 0;
}
+
/*
* Local Variables:
* mode: c