summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-07-22 21:13:15 +0500
committerunknown <bar@mysql.com>2005-07-22 21:13:15 +0500
commit1c4da828d49af0de4df559573bb37b9f153efdce (patch)
treeb90c6f6cc4c0da22fd4690eaed32cebde6a95878 /strings
parent29f42518f2db1e05a1120cebeb2624fda91376d8 (diff)
parentbf45b6ba8477a9a910ec530c126569c208d5c0a1 (diff)
downloadmariadb-git-1c4da828d49af0de4df559573bb37b9f153efdce.tar.gz
Merge mysql.com:/usr/home/bar/mysql-4.1.b11987
into mysql.com:/usr/home/bar/mysql-5.0 strings/ctype-gbk.c: Auto merged
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-gbk.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index f941aabaf69..a4bcce19432 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -9938,6 +9938,43 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
}
+/*
+ Returns well formed length of a GBK string.
+*/
+static
+uint my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)),
+ const char *b, const char *e,
+ uint pos, int *error)
+{
+ const char *b0= b;
+ const char *emb= e - 1; /* Last possible end of an MB character */
+
+ *error= 0;
+ while (pos-- && b < e)
+ {
+ if ((uchar) b[0] < 128)
+ {
+ /* Single byte ascii character */
+ b++;
+ }
+ else if ((b < emb) && isgbkcode((uchar)*b, (uchar)b[1]))
+ {
+ /* Double byte character */
+ b+= 2;
+ }
+ else
+ {
+ /* Wrong byte sequence */
+ *error= 1;
+ break;
+ }
+ }
+ return b - b0;
+}
+
+
+
+
static MY_COLLATION_HANDLER my_collation_ci_handler =
{
NULL, /* init */
@@ -9960,7 +9997,7 @@ static MY_CHARSET_HANDLER my_charset_handler=
mbcharlen_gbk,
my_numchars_mb,
my_charpos_mb,
- my_well_formed_len_mb,
+ my_well_formed_len_gbk,
my_lengthsp_8bit,
my_numcells_8bit,
my_mb_wc_gbk,