mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Adding a shared include file ctype-mb.ic and removing a number
of very similar copies of my_well_formed_len_xxx(), implemented for big5, cp932, euckr, eucjpms, gb2312m gbk, sjis, ujis.
This commit is contained in:
parent
d8c1165c28
commit
a7ed8523e3
9 changed files with 184 additions and 353 deletions
|
|
@ -176,10 +176,18 @@ static const uchar sort_order_cp932[]=
|
|||
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377'
|
||||
};
|
||||
|
||||
#define iscp932head(c) ((0x81<=(c) && (c)<=0x9f) || \
|
||||
((0xe0<=(c)) && (c)<=0xfc))
|
||||
#define iscp932tail(c) ((0x40<=(c) && (c)<=0x7e) || \
|
||||
(0x80<=(c) && (c)<=0xfc))
|
||||
#define iscp932head(c) ((0x81 <= (uchar) (c) && (uchar) (c) <= 0x9f) || \
|
||||
(0xe0 <= (uchar) (c) && (uchar) (c) <= 0xfc))
|
||||
#define iscp932tail(c) ((0x40 <= (uchar) (c) && (uchar) (c) <= 0x7e) || \
|
||||
(0x80 <= (uchar) (c) && (uchar) (c) <= 0xfc))
|
||||
|
||||
#define iscp932kata(c) (0xA1 <= (uchar) (c) && (uchar) (c) <= 0xDF)
|
||||
|
||||
#define MY_FUNCTION_NAME(x) my_ ## x ## _cp932
|
||||
#define IS_8BIT_CHAR(x) iscp932kata(x)
|
||||
#define IS_MB2_CHAR(x,y) (iscp932head(x) && iscp932tail(y))
|
||||
#define WELL_FORMED_LEN
|
||||
#include "ctype-mb.ic"
|
||||
|
||||
|
||||
static uint ismbchar_cp932(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
|
@ -34711,50 +34719,6 @@ size_t my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)),
|
|||
return clen;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns a well formed length of a cp932 string.
|
||||
cp932 additional characters are also accepted.
|
||||
*/
|
||||
|
||||
static
|
||||
size_t my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)),
|
||||
const char *b, const char *e,
|
||||
size_t pos, int *error)
|
||||
{
|
||||
const char *b0= b;
|
||||
*error= 0;
|
||||
while (pos-- && b < e)
|
||||
{
|
||||
/*
|
||||
Cast to int8 for extra safety.
|
||||
"char" can be unsigned by default
|
||||
on some platforms.
|
||||
*/
|
||||
if (((int8)b[0]) >= 0)
|
||||
{
|
||||
/* Single byte ascii character */
|
||||
b++;
|
||||
}
|
||||
else if (iscp932head((uchar)*b) && (e-b)>1 && iscp932tail((uchar)b[1]))
|
||||
{
|
||||
/* Double byte character */
|
||||
b+= 2;
|
||||
}
|
||||
else if (((uchar)*b) >= 0xA1 && ((uchar)*b) <= 0xDF)
|
||||
{
|
||||
/* Half width kana */
|
||||
b++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wrong byte sequence */
|
||||
*error= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (size_t) (b - b0);
|
||||
}
|
||||
|
||||
|
||||
static MY_COLLATION_HANDLER my_collation_ci_handler =
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue