From b8ed2f71905f840c6f41c12723dc13972a87866b Mon Sep 17 00:00:00 2001 From: handa Date: Fri, 12 Oct 2007 05:41:03 +0000 Subject: [PATCH] (read_rgb_txt): Check also /etc/X11/rgb.txt. Downcase color names. --- src/m17n-gd.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/m17n-gd.c b/src/m17n-gd.c index 600b049..0604178 100644 --- a/src/m17n-gd.c +++ b/src/m17n-gd.c @@ -68,7 +68,7 @@ static void read_rgb_txt () { FILE *fp; - int r, g, b; + int r, g, b, i; /* At first, support HTML 4.0 color names. */ msymbol_put (msymbol ("black"), M_rgb, (void *) 0x000000); @@ -88,11 +88,18 @@ read_rgb_txt () msymbol_put (msymbol ("teal"), M_rgb, (void *) 0x008080); msymbol_put (msymbol ("aqua"), M_rgb, (void *) 0x00FFFF); - fp = fopen ("/usr/lib/X11/rgb.txt", "r"); - if (! fp) - fp = fopen ("/usr/X11R6/lib/X11/rgb.txt", "r"); - if (! fp) - return; + { + char *rgb_path[] + = {"/usr/lib/X11/rgb.txt", "/usr/X11R6/lib/X11/rgb.txt", + "/etc/X11/rgb.txt" }; + + fp = NULL; + for (i = 0; i < (sizeof rgb_path) / (sizeof rgb_path[0]); i++) + if ((fp = fopen ("/usr/lib/X11/rgb.txt", "r"))) + break; + if (! fp) + return; + } while (1) { char buf[256]; @@ -114,6 +121,8 @@ read_rgb_txt () buf[0] = c; fgets (buf + 1, 255, fp); len = strlen (buf); + for (i = 0; i < len; i++) + buf[i] = tolower (buf[i]); if (buf[len - 1] == '\n') buf[len - 1] = '\0'; b |= (r << 16) | (g << 8); -- 1.7.10.4