diff options
author | nijtmans@users.sourceforge.net <jan.nijtmans> | 2012-03-13 15:05:36 (GMT) |
---|---|---|
committer | nijtmans@users.sourceforge.net <jan.nijtmans> | 2012-03-13 15:05:36 (GMT) |
commit | 3413e494817d5066c49efa90e03c338c6fc66d42 (patch) | |
tree | 772b8075deb27d7d47476028882a3664f45222f7 /xlib | |
parent | 8985b5e8e9994b2228c0d534178c2da0df8b40f8 (diff) | |
download | tk-3413e494817d5066c49efa90e03c338c6fc66d42.zip tk-3413e494817d5066c49efa90e03c338c6fc66d42.tar.gz tk-3413e494817d5066c49efa90e03c338c6fc66d42.tar.bz2 |
make sure that "burly wood" is not a valid color
Diffstat (limited to 'xlib')
-rw-r--r-- | xlib/xcolors.c | 18 |
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; } |