diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-11 09:49:03 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-12-11 09:49:03 +0800 |
commit | b54b6d5d4b176a137b6095024d3db80ede286555 (patch) | |
tree | 81fe98fd8b50f5eac57e45c9f74f6911509d9ad3 | |
parent | 9c92e958fd4f6a5d25cbab9d80e0fee8aa70c478 (diff) | |
download | pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.tar pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.tar.gz pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.tar.bz2 pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.tar.lz pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.tar.xz pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.tar.zst pttbbs-b54b6d5d4b176a137b6095024d3db80ede286555.zip |
- 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
-rw-r--r-- | include/fnv_hash.h | 25 | ||||
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | mbbsd/read.c | 3 | ||||
-rw-r--r-- | mbbsd/stuff.c | 6 |
4 files changed, 33 insertions, 2 deletions
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); diff --git a/mbbsd/read.c b/mbbsd/read.c index eb58e360..9e1dbb14 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -1,6 +1,5 @@ /* $Id$ */ #include "bbs.h" -#include "fnv_hash.h" static int headers_size; static fileheader_t *headers = NULL; @@ -221,7 +220,7 @@ getkeep(const char *s, int def_topline, int def_cursline) static struct keepsome preserv_keepblock; static struct keepsome *keeplist = &preserv_keepblock; struct keeploc_t *p; - unsigned int key=fnv1a_32_str(s, FNV1_32_INIT); + unsigned key=DBCS_StringHash(s); int i; if (def_cursline >= 0) { diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c index 4e5fd8cb..19049c8b 100644 --- a/mbbsd/stuff.c +++ b/mbbsd/stuff.c @@ -961,6 +961,12 @@ StringHash(const char *s) return fnv1a_32_strcase(s, FNV1_32_INIT); } +unsigned +DBCS_StringHash(const char *s) +{ + return fnv1a_32_dbcs_strcase(s, FNV1_32_INIT); +} + inline int *intbsearch(int key, const int *base0, int nmemb) { /* §ï¦Û /usr/src/lib/libc/stdlib/bsearch.c , |