summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <bar@eagle.intranet.mysql.r18.ru>2005-03-25 16:23:16 +0400
committerunknown <bar@eagle.intranet.mysql.r18.ru>2005-03-25 16:23:16 +0400
commitedd28b0cb6ba8aa552e51114c3b6279b921dad86 (patch)
tree679a5173d3990339914ca7a833ee285dbdfb6586 /strings
parent1b04234e828045bd0ff5fedf6c0a55a2993804db (diff)
parent90aa6e00a730483e9aa324990d28780571601b58 (diff)
downloadmariadb-git-edd28b0cb6ba8aa552e51114c3b6279b921dad86.tar.gz
Merge eagle.intranet.mysql.r18.ru:/home/bar/mysql-4.1
into eagle.intranet.mysql.r18.ru:/home/bar/mysql-5.0 strings/ctype-big5.c: Auto merged
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-big5.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 793c48bb988..f5ef82a7600 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6287,6 +6287,43 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
return 2;
}
+
+/*
+ Returns a well formed length of a BIG5 string.
+ CP950 and HKSCS additional characters are also accepted.
+*/
+static
+uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
+ const char *b, const char *e, uint pos)
+{
+ const char *b0= b;
+ const char *emb= e - 1; /* Last possible end of an MB character */
+ 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 ((b < emb) && isbig5code((uchar)*b, (uchar)b[1]))
+ {
+ /* Double byte character */
+ b+= 2;
+ }
+ else
+ {
+ /* Wrong byte sequence */
+ break;
+ }
+ }
+ return b - b0;
+}
+
+
static MY_COLLATION_HANDLER my_collation_big5_chinese_ci_handler =
{
NULL, /* init */
@@ -6308,7 +6345,7 @@ static MY_CHARSET_HANDLER my_charset_big5_handler=
mbcharlen_big5,
my_numchars_mb,
my_charpos_mb,
- my_well_formed_len_mb,
+ my_well_formed_len_big5,
my_lengthsp_8bit,
my_numcells_8bit,
my_mb_wc_big5, /* mb_wc */