From b54b6d5d4b176a137b6095024d3db80ede286555 Mon Sep 17 00:00:00 2001 From: piaip Date: Tue, 11 Dec 2007 01:49:03 +0000 Subject: - search: must update SR name to match new DBCS aware search git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3663 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/fnv_hash.h | 25 +++++++++++++++++++++++++ include/proto.h | 1 + 2 files changed, 26 insertions(+) (limited to 'include') diff --git a/include/fnv_hash.h b/include/fnv_hash.h index 837fd66c..c85b3c27 100644 --- a/include/fnv_hash.h +++ b/include/fnv_hash.h @@ -70,6 +70,31 @@ fnv1a_32_strcase(const char *str, Fnv32_t hval) return hval; } +static __inline Fnv32_t +fnv1a_32_dbcs_strcase(const char *str, Fnv32_t hval) +{ + const unsigned char *s = (const unsigned char *)str; + Fnv32_t c; + char isDBCS = 0; + + while ((c = *s++) != 0) { + if (isDBCS) + { + // 2nd DBCS + isDBCS = 0; + } else { + // ASCII? + if ( c < 0x80) + c = toupper(c); + else + isDBCS = 1; + } + hval ^= c; + hval *= FNV_32_PRIME; + } + return hval; +} + static __inline Fnv64_t fnv_64_buf(const void *buf, size_t len, Fnv64_t hval) { diff --git a/include/proto.h b/include/proto.h index 3f80eacc..41012158 100644 --- a/include/proto.h +++ b/include/proto.h @@ -811,6 +811,7 @@ int Goodbye(void); /* toolkit */ unsigned StringHash(const char *s); +unsigned DBCS_StringHash(const char *s); /* passwd */ int passwd_init(void); -- cgit v1.2.3