X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fpicsmap.c;fp=test%2Fpicsmap.c;h=3c4eb697a4de710a91be75b4e3aa3732bff09dbb;hp=432fbf7a5790d4894b98438fa372995d6073478a;hb=d61c3c6a831d18ef0ed6f797ac97d60fffc2f158;hpb=04d942c3d98cf0a929c6afb17be8c10d4ae39af0 diff --git a/test/picsmap.c b/test/picsmap.c index 432fbf7a..3c4eb697 100644 --- a/test/picsmap.c +++ b/test/picsmap.c @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: picsmap.c,v 1.132 2020/02/02 23:34:34 tom Exp $ + * $Id: picsmap.c,v 1.134 2020/07/11 23:01:49 tom Exp $ * * Author: Thomas E. Dickey * @@ -955,6 +955,20 @@ parse_rgb(char **data) return result; } +#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c)) + +static int +CaselessCmp(const char *a, const char *b) +{ /* strcasecmp isn't portable */ + while (*a && *b) { + int cmp = LOWERCASE(*a) - LOWERCASE(*b); + if (cmp != 0) + break; + a++, b++; + } + return LOWERCASE(*a) - LOWERCASE(*b); +} + static RGB_NAME * lookup_rgb(const char *name) { @@ -962,7 +976,7 @@ lookup_rgb(const char *name) if (rgb_table != 0) { int n; for (n = 0; rgb_table[n].name != 0; ++n) { - if (!strcasecmp(name, rgb_table[n].name)) { + if (!CaselessCmp(name, rgb_table[n].name)) { result = &rgb_table[n]; break; }