Das ging so natürlich nicht... Weil man bei ct_find ja abkürzen darf. Bessere Lösung in Sicht.

This commit is contained in:
Enno Rehling 2004-01-15 22:45:26 +00:00
parent 4349ce9456
commit 21c3da74e1
1 changed files with 3 additions and 17 deletions

View File

@ -226,25 +226,12 @@ typedef struct cursetype_list {
const curse_type * type; const curse_type * type;
} cursetype_list; } cursetype_list;
#define CMAXHASH 63 cursetype_list * cursetypes[256];
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 void
ct_register(const curse_type * ct) ct_register(const curse_type * ct)
{ {
unsigned int hash = hashstring(strlower(ct->cname)) % CMAXHASH; unsigned int hash = tolower(ct->cname[0]);
cursetype_list ** ctlp = &cursetypes[hash]; cursetype_list ** ctlp = &cursetypes[hash];
while (*ctlp) { while (*ctlp) {
cursetype_list * ctl = *ctlp; cursetype_list * ctl = *ctlp;
@ -258,8 +245,7 @@ ct_register(const curse_type * ct)
const curse_type * const curse_type *
ct_find(const char *c) ct_find(const char *c)
{ {
char * lower = strlower(c); unsigned int hash = tolower(c[0]);
unsigned int hash = hashstring(lower) % CMAXHASH;
cursetype_list * ctl = cursetypes[hash]; cursetype_list * ctl = cursetypes[hash];
while (ctl) { while (ctl) {
int k = min(strlen(c), strlen(ctl->type->cname)); int k = min(strlen(c), strlen(ctl->type->cname));