X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fresources.c;h=5bcd2c27c3c8b4d0df0585640cecb6ce253276ba;hb=f65151994eba80ecabcdac6eef6fa0dde7e2d45b;hp=d13fb820e3b2764f0c28475ee53cc5d65629a7e8;hpb=6bb727f03bff0389fbb1349d7df4c9d8d7532959;p=xscreensaver diff --git a/utils/resources.c b/utils/resources.c index d13fb820..5bcd2c27 100644 --- a/utils/resources.c +++ b/utils/resources.c @@ -1,5 +1,5 @@ /* xscreensaver, Copyright (c) 1992, 1997, 1998 - * Jamie Zawinski + * Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -75,7 +75,7 @@ get_boolean_resource (char *res_name, char *res_class) if (!strcmp (buf,"off") || !strcmp (buf, "false") || !strcmp (buf,"no")) return 0; fprintf (stderr, "%s: %s must be boolean, not %s.\n", - progname, res_class, buf); + progname, res_name, buf); return 0; } @@ -84,12 +84,28 @@ get_integer_resource (char *res_name, char *res_class) { int val; char c, *s = get_string_resource (res_name, res_class); + char *ss = s; if (!s) return 0; - if (1 == sscanf (s, " %d %c", &val, &c)) + + while (*ss && *ss <= ' ') ss++; /* skip whitespace */ + + if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X')) /* 0x: parse as hex */ { - free (s); - return val; + if (1 == sscanf (ss+2, "%x %c", &val, &c)) + { + free (s); + return val; + } } + else /* else parse as dec */ + { + if (1 == sscanf (ss, "%d %c", &val, &c)) + { + free (s); + return val; + } + } + fprintf (stderr, "%s: %s must be an integer, not %s.\n", progname, res_name, s); free (s); @@ -143,9 +159,10 @@ get_pixel_resource (char *res_name, char *res_class, return color.pixel; DEFAULT: if (s) free (s); - return (strcmp (res_class, "Background") - ? WhitePixel (dpy, DefaultScreen (dpy)) - : BlackPixel (dpy, DefaultScreen (dpy))); + return ((strlen(res_class) >= 10 && + !strcmp ("Background", res_class + strlen(res_class) - 10)) + ? BlackPixel (dpy, DefaultScreen (dpy)) + : WhitePixel (dpy, DefaultScreen (dpy))); }