Some charsets require special hash function

New file ctype-win1250ch, I forgot to commit it in my previous changes 
parent 00dee516
......@@ -92,6 +92,8 @@ typedef struct charset_info_st
int (*strcasecmp)(struct charset_info_st *, const char *, const char *);
int (*strncasecmp)(struct charset_info_st *, const char *, const char *, uint);
/* Hash calculation */
uint (*hash_caseup)(struct charset_info_st *cs, const byte *key, uint len);
char max_sort_char; /* For LIKE otimization */
} CHARSET_INFO;
......@@ -275,6 +277,9 @@ int my_strncasecmp_utf8(CHARSET_INFO *cs, const char *s,const char *t,uint l);
int my_utf8_uni (CHARSET_INFO *cs, my_wc_t *p, const uchar *s, const uchar *e);
int my_uni_utf8 (CHARSET_INFO *cs, my_wc_t wc, uchar *b, uchar *e);
uint my_hash_caseup_utf8(struct charset_info_st *cs, const byte *key, uint len);
#endif
#define _U 01 /* Upper case */
......
......@@ -59,7 +59,12 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
hash->flags=flags;
hash->charset=charset;
if (flags & HASH_CASE_INSENSITIVE)
hash->calc_hashnr=calc_hashnr_caseup;
{
if (charset->hash_caseup)
hash->calc_hashnr=charset->hash_caseup;
else
hash->calc_hashnr=calc_hashnr_caseup;
}
else
hash->calc_hashnr=calc_hashnr;
DBUG_RETURN(0);
......
......@@ -1732,6 +1732,28 @@ void my_caseup_utf8(CHARSET_INFO *cs, char *s, uint slen)
}
}
uint my_hash_caseup_utf8(CHARSET_INFO *cs, const byte *s, uint slen)
{
my_wc_t wc;
register uint nr=1, nr2=4;
int res;
const char *e=s+slen;
while ((s < e) && (res=my_utf8_uni(cs,&wc, (uchar *)s, (uchar*)e))>0 )
{
int plane = (wc>>8) & 0xFF;
wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].toupper : wc;
nr^= (((nr & 63)+nr2)*(wc & 0xFF))+ (nr << 8);
nr2+=3;
nr^= (((nr & 63)+nr2)*(wc >> 8))+ (nr << 8);
nr2+=3;
s+=res;
}
return nr;
}
void my_caseup_str_utf8(CHARSET_INFO * cs, char * s)
{
my_caseup_utf8(cs, s, strlen(s));
......@@ -1938,7 +1960,7 @@ int main()
test_mb(cs,(uchar*)str);
printf("orig :'%s'\n",str);
pr1;2cintf("orig :'%s'\n",str);
my_caseup_utf8(cs,str,15);
printf("caseup :'%s'\n",str);
......
This diff is collapsed.
......@@ -2829,6 +2829,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -2859,6 +2860,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_mb,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
0
},
#endif
......@@ -2889,6 +2891,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -2919,6 +2922,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -2949,6 +2953,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -2979,6 +2984,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3009,6 +3015,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3039,6 +3046,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3069,6 +3077,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3099,6 +3108,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3129,6 +3139,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_mb,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3159,6 +3170,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_mb,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3189,6 +3201,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_mb,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3219,6 +3232,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3249,6 +3263,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3279,6 +3294,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3309,6 +3325,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3339,6 +3356,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3369,6 +3387,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3399,6 +3418,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3429,6 +3449,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3459,6 +3480,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3489,6 +3511,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3519,6 +3542,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3549,6 +3573,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3579,6 +3604,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3609,6 +3635,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_mb,
my_strcasecmp_mb,
my_strncasecmp_mb,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3639,6 +3666,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_utf8,
my_strcasecmp_utf8,
my_strncasecmp_utf8,
my_hash_caseup_utf8,/* hash_caseup */
0
},
#endif
......@@ -3669,6 +3697,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3699,6 +3728,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3729,6 +3759,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3759,6 +3790,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3789,6 +3821,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3819,6 +3852,7 @@ CHARSET_INFO compiled_charsets[] = {
my_casedn_8bit,
my_strcasecmp_8bit,
my_strncasecmp_8bit,
NULL, /* hash_caseup */
0
},
#endif
......@@ -3850,6 +3884,7 @@ CHARSET_INFO compiled_charsets[] = {
NULL,
NULL,
NULL,
NULL, /* hash_caseup */
0
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment