summaryrefslogtreecommitdiff
path: root/os/oscolor.c
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:49:22 +0000
commitd568221710959cf7d783e6ff0fb80fb43a231124 (patch)
tree8d6f039393294c6ffac8533639afdebe5d68bfc1 /os/oscolor.c
parent9508a382f8a9f241dab097d921b6d290c1c3a776 (diff)
XFree86 4.3.0.1
Diffstat (limited to 'os/oscolor.c')
-rw-r--r--os/oscolor.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/os/oscolor.c b/os/oscolor.c
index f5fd61bc5..62676f84b 100644
--- a/os/oscolor.c
+++ b/os/oscolor.c
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/os/oscolor.c,v 3.8 2002/05/31 18:46:06 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -107,11 +108,11 @@ OsLookupColor(screen, name, len, pred, pgreen, pblue)
if(!rgb_dbm)
return(0);
- /* we use Xalloc here so that we can compile with cc without alloca
+ /* we use xalloc here so that we can compile with cc without alloca
* when otherwise using gcc */
if (len < sizeof(buf))
lowername = buf;
- else if (!(lowername = (char *)Xalloc(len + 1)))
+ else if (!(lowername = (char *)xalloc(len + 1)))
return(0);
CopyISOLatin1Lowered ((unsigned char *) lowername, (unsigned char *) name,
(int)len);
@@ -125,7 +126,7 @@ OsLookupColor(screen, name, len, pred, pgreen, pblue)
#endif
if (len >= sizeof(buf))
- Xfree(lowername);
+ xfree(lowername);
if(dbent.dptr)
{
@@ -175,7 +176,7 @@ lookup(name, len, create)
Bool create;
{
unsigned int h = 0, g;
- dbEntryPtr entry, *prev;
+ dbEntryPtr entry, *prev = NULL;
char *str = name;
if (!(name = (char*)ALLOCATE_LOCAL(len +1))) return NULL;
@@ -189,7 +190,7 @@ lookup(name, len, create)
}
h %= HASHSIZE;
- if ( entry = hashTab[h] )
+ if ( (entry = hashTab[h]) )
{
for( ; entry; prev = (dbEntryPtr*)entry, entry = entry->link )
if (! strcmp(name, entry->name) ) break;
@@ -197,7 +198,7 @@ lookup(name, len, create)
else
prev = &(hashTab[h]);
- if (!entry && create && (entry = (dbEntryPtr)Xalloc(sizeof(dbEntry) +len)))
+ if (!entry && create && (entry = (dbEntryPtr)xalloc(sizeof(dbEntry) +len)))
{
*prev = entry;
entry->link = NULL;
@@ -224,10 +225,16 @@ OsInitColors()
if (!was_here)
{
+#ifndef __UNIXOS2__
path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5);
strcpy(path, rgbPath);
strcat(path, ".txt");
-
+#else
+ char *tmp = (char*)__XOS2RedirRoot(rgbPath);
+ path = (char*)ALLOCATE_LOCAL(strlen(tmp) +5);
+ strcpy(path, tmp);
+ strcat(path, ".txt");
+#endif
if (!(rgb = fopen(path, "r")))
{
ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
@@ -238,13 +245,17 @@ OsInitColors()
while(fgets(line, sizeof(line), rgb))
{
lineno++;
+#ifndef __UNIXOS2__
if (sscanf(line,"%d %d %d %[^\n]\n", &red, &green, &blue, name) == 4)
+#else
+ if (sscanf(line,"%d %d %d %[^\n\r]\n", &red, &green, &blue, name) == 4)
+#endif
{
if (red >= 0 && red <= 0xff &&
green >= 0 && green <= 0xff &&
blue >= 0 && blue <= 0xff)
{
- if (entry = lookup(name, strlen(name), TRUE))
+ if ((entry = lookup(name, strlen(name), TRUE)))
{
entry->red = (red * 65535) / 255;
entry->green = (green * 65535) / 255;
@@ -252,8 +263,7 @@ OsInitColors()
}
}
else
- ErrorF("Value for \"%s\" out of range: %s:%d\n",
- name, path, lineno);
+ ErrorF("Value out of range: %s:%d\n", path, lineno);
}
else if (*line && *line != '#' && *line != '!')
ErrorF("Syntax Error: %s:%d\n", path, lineno);
@@ -280,7 +290,7 @@ OsLookupColor(screen, name, len, pred, pgreen, pblue)
{
dbEntryPtr entry;
- if (entry = lookup(name, len, FALSE))
+ if ((entry = lookup(name, len, FALSE)))
{
*pred = entry->red;
*pgreen = entry->green;