diff --git a/src/common/kernel/curse.c b/src/common/kernel/curse.c index d437a1e76..50583f91b 100644 --- a/src/common/kernel/curse.c +++ b/src/common/kernel/curse.c @@ -46,6 +46,7 @@ #include #include #include +#include /* spells includes */ #include @@ -228,10 +229,22 @@ typedef struct cursetype_list { #define CMAXHASH 63 cursetype_list * cursetypes[CMAXHASH]; +static char * +strlower(const char * str) +{ + static char result[128]; + char * pos = result; + while (*str) { + *pos++ = (char)tolower(*(unsigned char*)str++); + } + *pos=0; + return result; +} + void ct_register(const curse_type * ct) { - unsigned int hash = hashstring(ct->cname) % CMAXHASH; + unsigned int hash = hashstring(strlower(ct->cname)) % CMAXHASH; cursetype_list ** ctlp = &cursetypes[hash]; while (*ctlp) { cursetype_list * ctl = *ctlp; @@ -245,7 +258,8 @@ ct_register(const curse_type * ct) const curse_type * ct_find(const char *c) { - unsigned int hash = hashstring(c) % CMAXHASH; + char * lower = strlower(c); + unsigned int hash = hashstring(lower) % CMAXHASH; cursetype_list * ctl = cursetypes[hash]; while (ctl) { int k = min(strlen(c), strlen(ctl->type->cname));