summaryrefslogtreecommitdiffstats
path: root/xlib
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-13 15:05:36 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-03-13 15:05:36 (GMT)
commit351670ca0e9f135b473dce52ff9e1ae76d55f787 (patch)
tree772b8075deb27d7d47476028882a3664f45222f7 /xlib
parent88d781b19e842d53856a2b7bac01acde702c821f (diff)
downloadtk-351670ca0e9f135b473dce52ff9e1ae76d55f787.zip
tk-351670ca0e9f135b473dce52ff9e1ae76d55f787.tar.gz
tk-351670ca0e9f135b473dce52ff9e1ae76d55f787.tar.bz2
make sure that "burly wood" is not a valid color
Diffstat (limited to 'xlib')
-rw-r--r--xlib/xcolors.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/xlib/xcolors.c b/xlib/xcolors.c
index e0e7f6e..cc5ad69 100644
--- a/xlib/xcolors.c
+++ b/xlib/xcolors.c
@@ -732,13 +732,20 @@ _strtoi64(const char *spec, char **p, int base)
static int colorcmp(const char *spec, const char *pname) {
int r;
int c, d;
+ int notequal = 0;
do {
d = *pname++;
+ c = (*spec == ' ');
+ if (c) {
+ spec++;
+ }
if ((d >= 'A') && (d <= 'Z')) {
d += 'a' - 'A';
- if (*spec == ' ') {
- spec++;
- }
+ } else if (c) {
+ /* A space doesn't match a lowercase, but we don't know
+ * yet whether we should return a negative or positive
+ * number. That depends on what follows. */
+ notequal = 1;
}
c = *spec++;
if ((c >= 'A') && (c <= 'Z')) {
@@ -746,6 +753,11 @@ static int colorcmp(const char *spec, const char *pname) {
}
r = c - d;
} while(!r && c);
+ if (!r && notequal) {
+ /* Strings are equal, but difference in spacings only. We should still
+ * report not-equal, so "burly wood" is not a valid color */
+ r = 1;
+ }
return r;
}