diff src/objects-msw.c @ 288:e11d67e05968 r21-0b42

Import from CVS: tag r21-0b42
author cvs
date Mon, 13 Aug 2007 10:35:54 +0200
parents 57709be46d1b
children 4b85ae5eabfb
line wrap: on
line diff
--- a/src/objects-msw.c	Mon Aug 13 10:35:07 2007 +0200
+++ b/src/objects-msw.c	Mon Aug 13 10:35:54 2007 +0200
@@ -775,14 +775,25 @@
     {
       unsigned int r,g,b;
 
-      if (sscanf(name, "rgb:%04x/%04x/%04x", &r, &g, &b) <0)
+      if (sscanf(name, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3)
+	{
+	  int len = strlen (name);
+	  if (len == 18)
+	    {
+	      r /= 257;
+	      g /= 257;
+	      b /= 257;
+	    }
+	  else if (len == 15)
+	    {
+	      r /= 17;
+	      g /= 17;
+	      b /= 17;
+	    }
+	  return (PALETTERGB (r, g, b));
+	}
+      else 
 	return -1;
-
-      r /= 257;
-      g /= 257;
-      b /= 257;
-
-      return (PALETTERGB (r, g, b));
     }
   else if (*name)	/* Can't be an empty string */
     {