From 4349ce9456204374fb969268f3d34bcff0ee82b2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 15 Jan 2004 22:29:41 +0000 Subject: [PATCH] bugfix non-case-sensitive ct_find --- src/common/kernel/curse.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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));