diff options
author | unknown <bar@bar.intranet.mysql.r18.ru> | 2004-02-06 16:59:25 +0400 |
---|---|---|
committer | unknown <bar@bar.intranet.mysql.r18.ru> | 2004-02-06 16:59:25 +0400 |
commit | faa8a41b1db57e643617eda8c49803f6e1287f87 (patch) | |
tree | 1de54a5d40a817616ee8991ff03ebb355c4f1d18 /strings | |
parent | e5ab70702c082c77401052f940b18b5f6d50a8c3 (diff) | |
download | mariadb-git-faa8a41b1db57e643617eda8c49803f6e1287f87.tar.gz |
Problem fix:
http://bugs.mysql.com/bug.php?id=2366
Wrong utf8 behaviour when data is trancated
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-big5.c | 1 | ||||
-rw-r--r-- | strings/ctype-bin.c | 1 | ||||
-rw-r--r-- | strings/ctype-euc_kr.c | 1 | ||||
-rw-r--r-- | strings/ctype-gb2312.c | 1 | ||||
-rw-r--r-- | strings/ctype-gbk.c | 1 | ||||
-rw-r--r-- | strings/ctype-latin1.c | 1 | ||||
-rw-r--r-- | strings/ctype-mb.c | 16 | ||||
-rw-r--r-- | strings/ctype-simple.c | 10 | ||||
-rw-r--r-- | strings/ctype-sjis.c | 1 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 7 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 12 | ||||
-rw-r--r-- | strings/ctype-ujis.c | 1 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 1 |
13 files changed, 52 insertions, 2 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 8d4081fb2aa..574156a99ed 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6245,6 +6245,7 @@ static MY_CHARSET_HANDLER my_charset_big5_handler= mbcharlen_big5, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_mb_wc_big5, /* mb_wc */ my_wc_mb_big5, /* wc_mb */ diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 43575bbc277..fc22938d46e 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -347,6 +347,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, + my_wellformedlen_8bit, my_lengthsp_8bit, my_mb_wc_bin, my_wc_mb_bin, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 366a5d500ed..278e8529e83 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8653,6 +8653,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_euc_kr, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_mb_wc_euc_kr, /* mb_wc */ my_wc_mb_euc_kr, /* wc_mb */ diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 44a58b2b906..722f00f0f7a 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5704,6 +5704,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_gb2312, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_mb_wc_gb2312, /* mb_wc */ my_wc_mb_gb2312, /* wc_mb */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 5475c3bd363..9e71a18e531 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9900,6 +9900,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_gbk, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_mb_wc_gbk, my_wc_mb_gbk, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index c00ded21575..933737b5f61 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -180,6 +180,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_8bit, my_numchars_8bit, my_charpos_8bit, + my_wellformedlen_8bit, my_lengthsp_8bit, my_mb_wc_latin1, my_wc_mb_latin1, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index b5e8c4598a0..377bf311d38 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -274,6 +274,22 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), return pos ? e+2-b0 : b-b0; } +uint my_wellformedlen_mb(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, uint pos) +{ + uint mblen; + const char *b0=b; + + while (pos && b<e) + { + b+= (mblen= my_ismbchar(cs,b,e)) ? mblen : 1; + pos--; + } + return b-b0; +} + + + uint my_instr_mb(CHARSET_INFO *cs, const char *b, uint b_length, const char *s, uint s_length, diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 62eb1418970..fb2dee99ba5 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1020,6 +1020,15 @@ uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), return pos; } +uint my_wellformedlen_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *b, + const char *e, + uint nchars) +{ + uint nbytes= e-b; + return nbytes < nchars ? nbytes : nchars; +} + uint my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *ptr, uint length) { @@ -1096,6 +1105,7 @@ MY_CHARSET_HANDLER my_charset_8bit_handler= my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, + my_wellformedlen_8bit, my_lengthsp_8bit, my_mb_wc_8bit, my_wc_mb_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 42f32fe739b..feff0fff227 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4489,6 +4489,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_sjis, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_mb_wc_sjis, /* mb_wc */ my_wc_mb_sjis, /* wc_mb */ diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 09552a0dc23..d577b964405 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -874,7 +874,8 @@ NULL,NULL,NULL,NULL,NULL,NULL,NULL,plFF static -int my_mb_wc_tis620(CHARSET_INFO *cs,my_wc_t *wc, +int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t *wc, const unsigned char *str, const unsigned char *end __attribute__((unused))) { @@ -886,7 +887,8 @@ int my_mb_wc_tis620(CHARSET_INFO *cs,my_wc_t *wc, } static -int my_wc_mb_tis620(CHARSET_INFO *cs,my_wc_t wc, +int my_wc_mb_tis620(CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, unsigned char *str, unsigned char *end __attribute__((unused))) { @@ -919,6 +921,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, + my_wellformedlen_8bit, my_lengthsp_8bit, my_mb_wc_tis620, /* mb_wc */ my_wc_mb_tis620, /* wc_mb */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 775501027d0..bb74e0cf56b 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1002,6 +1002,17 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), } static +uint my_wellformedlen_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b, + const char *e, + uint nchars) +{ + uint nbytes= (e-b) & ~ (uint)1; + nchars*= 2; + return nbytes < nchars ? nbytes : nchars; +} + +static void my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), char *s, uint l, int fill) { @@ -1287,6 +1298,7 @@ static MY_CHARSET_HANDLER my_charset_ucs2_handler= my_mbcharlen_ucs2, /* mbcharlen */ my_numchars_ucs2, my_charpos_ucs2, + my_wellformedlen_ucs2, my_lengthsp_ucs2, my_ucs2_uni, /* mb_wc */ my_uni_ucs2, /* wc_mb */ diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index f6928e9426e..f27ddcf3e30 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8444,6 +8444,7 @@ static MY_CHARSET_HANDLER my_charset_handler= mbcharlen_ujis, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_mb_wc_euc_jp, /* mb_wc */ my_wc_mb_euc_jp, /* wc_mb */ diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 8004fba75b7..ef9719bf040 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1969,6 +1969,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_mbcharlen_utf8, my_numchars_mb, my_charpos_mb, + my_wellformedlen_mb, my_lengthsp_8bit, my_utf8_uni, my_uni_utf8, |