X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fpicsmap.c;h=3c4eb697a4de710a91be75b4e3aa3732bff09dbb;hp=624eda88959080ce6126945e62f1f0982a690160;hb=d61c3c6a831d18ef0ed6f797ac97d60fffc2f158;hpb=02f1dee48fe8af6ce054388fba739aa4f975004e;ds=sidebyside diff --git a/test/picsmap.c b/test/picsmap.c index 624eda88..3c4eb697 100644 --- a/test/picsmap.c +++ b/test/picsmap.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2017-2018,2019 Free Software Foundation, Inc. * + * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2017,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: picsmap.c,v 1.131 2019/12/14 23:51:39 tom Exp $ + * $Id: picsmap.c,v 1.134 2020/07/11 23:01:49 tom Exp $ * * Author: Thomas E. Dickey * @@ -954,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) { @@ -961,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; }