Commit 4fd893e5 authored by unknown's avatar unknown

charset<->unicode conversion tables and routines

some warnings fixes


include/m_ctype.h:
  New charset conversion fields in CHARSET_INFO
mysys/hash.c:
  Fix for "unused argument" warning
strings/ctype-big5.c:
  Fix for "unused argument" warning
strings/ctype-czech.c:
  Fix for "unused argument" warning
strings/ctype-euc_kr.c:
  Fix for "unused argument" warning
strings/ctype-gb2312.c:
  Fix for "unused argument" warning
strings/ctype-gbk.c:
  Fix for "unused argument" warning
strings/ctype-latin1_de.c:
  Fix for "unused argument" warning
strings/ctype-simple.c:
  8bit<->unicode convertion routines
strings/ctype-sjis.c:
  Fix for "unused argument" warning
strings/ctype-tis620.c:
  Fix for "unused argument" warning
strings/ctype-ujis.c:
  Fix for "unused argument" warning
strings/ctype-utf8.c:
  Fix for "unused argument" warning
strings/ctype.c:
  8bit <-> unicode conversion tables
parent 48f99348
......@@ -42,7 +42,11 @@ typedef struct unicase_info_st {
#define MY_CS_TOOSMALL -1
#define MY_CS_TOOFEW(n) (-1-(n))
typedef struct my_uni_idx_st {
uint16 from;
uint16 to;
uchar *tab;
} MY_UNI_IDX;
typedef struct charset_info_st
......@@ -53,7 +57,10 @@ typedef struct charset_info_st
uchar *to_lower;
uchar *to_upper;
uchar *sort_order;
uint16 *tab_to_uni;
MY_UNI_IDX *tab_from_uni;
/* Collation routines */
uint strxfrm_multiply;
int (*strnncoll)(struct charset_info_st *,
const uchar *, uint, const uchar *, uint);
......@@ -62,12 +69,19 @@ typedef struct charset_info_st
my_bool (*like_range)(struct charset_info_st *,
const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
/* Multibyte routines */
uint mbmaxlen;
int (*ismbchar)(struct charset_info_st *, const char *, const char *);
my_bool (*ismbhead)(struct charset_info_st *, uint);
int (*mbcharlen)(struct charset_info_st *, uint);
/* Unicode convertion */
int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc,
const unsigned char *s,const unsigned char *e);
int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc,
unsigned char *s,unsigned char *e);
/* Functions for case convertion */
void (*caseup_str)(struct charset_info_st *, char *);
void (*casedn_str)(struct charset_info_st *, char *);
......@@ -106,6 +120,12 @@ extern void my_casedn_8bit(CHARSET_INFO *, char *, uint);
extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
extern int my_strncasecmp_8bit(CHARSET_INFO * cs, const char *, const char *, uint);
int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc,
const unsigned char *s,const unsigned char *e);
int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
unsigned char *s, unsigned char *e);
#ifdef USE_MB
/* Functions for multibyte charsets */
extern void my_caseup_str_mb(CHARSET_INFO *, char *);
......@@ -229,7 +249,7 @@ int my_strcasecmp_utf8(CHARSET_INFO *cs, const char *s, const char *t);
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 pwc , uchar *b, uchar *e);
int my_uni_utf8 (CHARSET_INFO *cs, my_wc_t wc, uchar *b, uchar *e);
#endif
#define _U 01 /* Upper case */
......
......@@ -114,7 +114,8 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
/* Calc hashvalue for a key */
static uint calc_hashnr(CHARSET_INFO *cs, const byte *key,uint length)
static uint calc_hashnr(CHARSET_INFO *cs __attribute__((unused)),
const byte *key,uint length)
{
register uint nr=1, nr2=4;
while (length--)
......
......@@ -215,7 +215,7 @@ static uint16 big5strokexfrm(uint16 i)
return 0xA140;
}
int my_strnncoll_big5(CHARSET_INFO *cs,
int my_strnncoll_big5(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
......@@ -239,7 +239,7 @@ int my_strnncoll_big5(CHARSET_INFO *cs,
return (int) (len1-len2);
}
int my_strnxfrm_big5(CHARSET_INFO *cs,
int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
......@@ -328,7 +328,7 @@ int my_strxfrm_big5(uchar * dest, const uchar * src, int len)
#define wild_one '_'
#define wild_many '%'
my_bool my_like_range_big5(CHARSET_INFO *cs,
my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
......@@ -378,17 +378,18 @@ my_bool my_like_range_big5(CHARSET_INFO *cs,
return 0;
}
int ismbchar_big5(CHARSET_INFO *cs,const char* p, const char *e)
int ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)),
const char* p, const char *e)
{
return (isbig5head(*(p)) && (e)-(p)>1 && isbig5tail(*((p)+1))? 2: 0);
}
my_bool ismbhead_big5(CHARSET_INFO *cs, uint c)
my_bool ismbhead_big5(CHARSET_INFO *cs __attribute__((unused)), uint c)
{
return isbig5head(c);
}
int mbcharlen_big5(CHARSET_INFO *cs, uint c)
int mbcharlen_big5(CHARSET_INFO *cs __attribute__((unused)), uint c)
{
return (isbig5head(c)? 2: 0);
}
......
......@@ -282,7 +282,7 @@ int my_strxfrm_czech(uchar * dest, const uchar * src, int len)
/* Function strnncoll, actually strcoll, with Czech sorting, which expect
the length of the strings being specified */
int my_strnncoll_czech(CHARSET_INFO *cs,
int my_strnncoll_czech(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
......@@ -308,7 +308,7 @@ int my_strnncoll_czech(CHARSET_INFO *cs,
/* Function strnxfrm, actually strxfrm, with Czech sorting, which expect
the length of the strings being specified */
int my_strnxfrm_czech(CHARSET_INFO *cs,
int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
......@@ -378,7 +378,7 @@ int my_strnxfrm_czech(CHARSET_INFO *cs,
#define EXAMPLE
my_bool my_like_range_czech(CHARSET_INFO *cs,
my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
......
......@@ -183,19 +183,20 @@ uchar NEAR sort_order_euc_kr[]=
#define iseuc_kr(c) ((0xa1<=(uchar)(c) && (uchar)(c)<=0xfe))
int ismbchar_euc_kr(CHARSET_INFO *cs,const char* p, const char *e)
int ismbchar_euc_kr(CHARSET_INFO *cs __attribute__((unused)),
const char* p, const char *e)
{
return ((*(uchar*)(p)<0x80)? 0:\
iseuc_kr(*(p)) && (e)-(p)>1 && iseuc_kr(*((p)+1))? 2:\
0);
}
my_bool ismbhead_euc_kr(CHARSET_INFO *cs,uint c)
my_bool ismbhead_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (iseuc_kr(c));
}
int mbcharlen_euc_kr(CHARSET_INFO *cs,uint c)
int mbcharlen_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (iseuc_kr(c) ? 2 : 0);
}
......
......@@ -166,17 +166,18 @@ uchar NEAR sort_order_gb2312[]=
#define isgb2312tail(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe)
int ismbchar_gb2312(CHARSET_INFO *cs,const char* p, const char *e)
int ismbchar_gb2312(CHARSET_INFO *cs __attribute__((unused)),
const char* p, const char *e)
{
return (isgb2312head(*(p)) && (e)-(p)>1 && isgb2312tail(*((p)+1))? 2: 0);
}
my_bool ismbhead_gb2312(CHARSET_INFO *cs,uint c)
my_bool ismbhead_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return isgb2312head(c);
}
int mbcharlen_gb2312(CHARSET_INFO *cs,uint c)
int mbcharlen_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (isgb2312head(c)? 2:0);
}
......
......@@ -2582,7 +2582,7 @@ static uint16 gbksortorder(uint16 i)
}
int my_strnncoll_gbk(CHARSET_INFO *cs,
int my_strnncoll_gbk(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
......@@ -2609,7 +2609,7 @@ int my_strnncoll_gbk(CHARSET_INFO *cs,
}
int my_strnxfrm_gbk(CHARSET_INFO *cs,
int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
......@@ -2653,7 +2653,7 @@ int my_strnxfrm_gbk(CHARSET_INFO *cs,
#define wild_one '_'
#define wild_many '%'
extern my_bool my_like_range_gbk(CHARSET_INFO *cs,
extern my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
......@@ -2704,17 +2704,18 @@ extern my_bool my_like_range_gbk(CHARSET_INFO *cs,
}
int ismbchar_gbk(CHARSET_INFO *cs,const char* p, const char *e)
int ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)),
const char* p, const char *e)
{
return (isgbkhead(*(p)) && (e)-(p)>1 && isgbktail(*((p)+1))? 2: 0);
}
my_bool ismbhead_gbk(CHARSET_INFO *cs,uint c)
my_bool ismbhead_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return isgbkhead(c);
}
int mbcharlen_gbk(CHARSET_INFO *cs,uint c)
int mbcharlen_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (isgbkhead(c)? 2:0);
}
......
......@@ -164,7 +164,7 @@ uchar sort_order_latin1_de[] = {
}
int my_strnncoll_latin1_de(CHARSET_INFO *cs,
int my_strnncoll_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
......@@ -238,7 +238,7 @@ int my_strnncoll_latin1_de(CHARSET_INFO *cs,
}
int my_strnxfrm_latin1_de(CHARSET_INFO *cs,
int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
......@@ -303,7 +303,7 @@ int my_strnxfrm_latin1_de(CHARSET_INFO *cs,
#define wild_one '_'
#define wild_many '%'
my_bool my_like_range_latin1_de(CHARSET_INFO *cs,
my_bool my_like_range_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr, uint ptr_length,
pchar escape, uint res_length,
char *min_str, char *max_str,
......
......@@ -85,3 +85,26 @@ int my_strncasecmp_8bit(CHARSET_INFO * cs,
while (len-- != 0 && my_toupper(cs,(uchar)*s++) == my_toupper(cs,(uchar)*t++)) ;
return (int) len+1;
}
int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc,
const unsigned char *str,
const unsigned char *end __attribute__((unused)))
{
*wc=cs->tab_to_uni[*str];
return (!wc[0] && str[0]) ? MY_CS_ILSEQ : 1;
}
int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc,
unsigned char *s,
unsigned char *e __attribute__((unused)))
{
MY_UNI_IDX *idx;
for(idx=cs->tab_from_uni; idx->tab ; idx++){
if(idx->from<=wc && idx->to>=wc){
s[0]=idx->tab[wc-idx->from];
return (!s[0] && wc) ? MY_CS_ILUNI : 1;
}
}
return MY_CS_ILUNI;
}
......@@ -183,17 +183,18 @@ uchar NEAR sort_order_sjis[]=
(0x80<=(c) && (c)<=0xfc))
int ismbchar_sjis(CHARSET_INFO *cs,const char* p, const char *e)
int ismbchar_sjis(CHARSET_INFO *cs __attribute__((unused)),
const char* p, const char *e)
{
return (issjishead((uchar) *p) && (e-p)>1 && issjistail((uchar)p[1]) ? 2: 0);
}
my_bool ismbhead_sjis(CHARSET_INFO *cs,uint c)
my_bool ismbhead_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return issjishead((uchar) c);
}
int mbcharlen_sjis(CHARSET_INFO *cs,uint c)
int mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (issjishead((uchar) c) ? 2: 0);
}
......@@ -201,7 +202,7 @@ int mbcharlen_sjis(CHARSET_INFO *cs,uint c)
#define sjiscode(c,d) ((((uint) (uchar)(c)) << 8) | (uint) (uchar) (d))
int my_strnncoll_sjis(CHARSET_INFO *cs,
int my_strnncoll_sjis(CHARSET_INFO *cs __attribute__((unused)),
const uchar *s1, uint len1,
const uchar *s2, uint len2)
{
......@@ -226,7 +227,7 @@ int my_strnncoll_sjis(CHARSET_INFO *cs,
return len1 - len2;
}
int my_strnxfrm_sjis(CHARSET_INFO *cs,
int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)),
uchar *dest, uint len,
const uchar *src, uint srclen)
{
......@@ -265,7 +266,7 @@ int my_strnxfrm_sjis(CHARSET_INFO *cs,
#define wild_one '_'
#define wild_many '%'
my_bool my_like_range_sjis(CHARSET_INFO *cs,
my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
......
......@@ -537,7 +537,7 @@ static uchar* thai2sortable(const uchar * tstr,uint len)
Arg: 2 Strings and it compare length
Ret: strcmp result
*/
int my_strnncoll_tis620(CHARSET_INFO *cs,
int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)),
const uchar * s1, uint len1,
const uchar * s2, uint len2)
{
......@@ -555,7 +555,7 @@ int my_strnncoll_tis620(CHARSET_INFO *cs,
Arg: Destination buffer, source string, dest length and source length
Ret: Conveted string size
*/
int my_strnxfrm_tis620(CHARSET_INFO *cs,
int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)),
uchar * dest, uint len,
const uchar * src, uint srclen)
{
......@@ -613,7 +613,7 @@ int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
#define wild_one '_'
#define wild_many '%'
my_bool my_like_range_tis620(CHARSET_INFO *cs,
my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)),
const char *ptr, uint ptr_length, pchar escape,
uint res_length, char *min_str, char *max_str,
uint *min_length, uint *max_length)
......
......@@ -183,7 +183,8 @@ uchar NEAR sort_order_ujis[]=
#define isujis_ss3(c) (((c)&0xff) == 0x8f)
int ismbchar_ujis(CHARSET_INFO *cs,const char* p, const char *e)
int ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)),
const char* p, const char *e)
{
return ((*(uchar*)(p)<0x80)? 0:\
isujis(*(p)) && (e)-(p)>1 && isujis(*((p)+1))? 2:\
......@@ -192,12 +193,12 @@ int ismbchar_ujis(CHARSET_INFO *cs,const char* p, const char *e)
0);
}
my_bool ismbhead_ujis(CHARSET_INFO *cs,uint c)
my_bool ismbhead_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (isujis(c) || isujis_ss2(c) || isujis_ss3(c));
}
int mbcharlen_ujis(CHARSET_INFO *cs,uint c)
int mbcharlen_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c)
{
return (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 0);
}
......
......@@ -1571,7 +1571,7 @@ uchar to_upper_utf8[] = {
};
int my_utf8_uni (__attribute__((unused)) CHARSET_INFO *cs,
int my_utf8_uni (CHARSET_INFO *cs __attribute__((unused)) ,
my_wc_t * pwc, const uchar *s, const uchar *e)
{
unsigned char c = s[0];
......@@ -1673,7 +1673,7 @@ int my_utf8_uni (__attribute__((unused)) CHARSET_INFO *cs,
return MY_CS_ILSEQ;
}
int my_uni_utf8 (__attribute__((unused)) CHARSET_INFO *cs,
int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) ,
my_wc_t wc, uchar *r, uchar *e)
{
int count;
......@@ -1879,12 +1879,12 @@ int my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e)
return (res>1) ? res : 0;
}
my_bool my_ismbhead_utf8(__attribute__((unused)) CHARSET_INFO *cs, uint ch)
my_bool my_ismbhead_utf8(CHARSET_INFO *cs __attribute__((unused)) , uint ch)
{
return ( ch >= 0xc2 );
}
int my_mbcharlen_utf8(__attribute__((unused)) CHARSET_INFO *cs, uint c)
int my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)) , uint c)
{
if (c < 0x80)
return 1;
......
This diff is collapsed.
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