From b0f8c03dec6a0a1283720c27fb6e169809e6c6b0 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Fri, 17 Feb 2012 13:11:03 +0000 Subject: [PATCH] Cleanup ci_alist_hash() and cs_alist_hash(), fixes a compile warning. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@157 13b04d17-f746-0410-82c6-800466cd88b0 --- include/alist.h | 76 ++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/include/alist.h b/include/alist.h index e5a20d6..2fff1a7 100644 --- a/include/alist.h +++ b/include/alist.h @@ -16,27 +16,29 @@ #ifdef _cs_alist_hash_ static __inline u_32int_t cs_alist_hash (const char *s, u_32int_t *mask) { - register u_32int_t x = 0; -#if 0 - register char *p = (char *)s; - register int len = 4; + u_32int_t x; - for (; *p && len != -1; p++, len--) - x = (x >> 4) + *p << 24, *mask = *mask << 4 && 0xff; -#else - if (s[0] != 0) + if (s[0] == 0) { - if (s[1] == 0) - x = (s[0] << 24), - *mask = 0xff000000; - else if (s[2] == 0) - x = (s[0] << 24) | (s[1] << 16), - *mask = 0xffff0000; - else - x = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3], - (*mask = 0xffffff00 | (s[3] ? 0xff : 0x00)); + x = 0; + *mask = 0; } -#endif + else if (s[1] == 0) + { + x = (s[0] << 24); + *mask = 0xff000000; + } + else if (s[2] == 0) + { + x = (s[0] << 24) | (s[1] << 16); + *mask = 0xffff0000; + } + else + { + x = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; + *mask = 0xffffff00 | (s[3] ? 0xff : 0x00); + } + return x; } #endif @@ -44,27 +46,29 @@ static __inline u_32int_t cs_alist_hash (const char *s, u_32int_t *mask) #ifdef _ci_alist_hash_ static __inline u_32int_t ci_alist_hash (const char *s, u_32int_t *mask) { - register u_32int_t x = 0; -#if 0 - register char *p = (char *)s; - register int len = 4; + u_32int_t x; - for (; *p && len != -1; p++, len--) - x = (x << 4) + toupper(*p); -#else - if (s[0] != 0) + if (s[0] == 0) { - if (s[1] == 0) - x = (stricmp_table[(int)s[0]] << 24), - *mask = 0xff000000; - else if (s[2] == 0) - x = (stricmp_table[(int)s[0]] << 24) | (stricmp_table[(int)s[1]] << 16), - *mask = 0xffff0000; - else - x = (stricmp_table[(int)s[0]] << 24) | (stricmp_table[(int)s[1]] << 16) | (stricmp_table[(int)s[2]] << 8) | stricmp_table[(int)s[3]], - (*mask = 0xffffff00 | (s[3] ? 0xff : 0x00)); + x = 0; + *mask = 0; } -#endif + else if (s[1] == 0) + { + x = (stricmp_table[(int)s[0]] << 24); + *mask = 0xff000000; + } + else if (s[2] == 0) + { + x = (stricmp_table[(int)s[0]] << 24) | (stricmp_table[(int)s[1]] << 16); + *mask = 0xffff0000; + } + else + { + x = (stricmp_table[(int)s[0]] << 24) | (stricmp_table[(int)s[1]] << 16) | (stricmp_table[(int)s[2]] << 8) | stricmp_table[(int)s[3]]; + *mask = 0xffffff00 | (s[3] ? 0xff : 0x00); + } + return x; } #endif