diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2013-10-23 20:25:52 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2013-10-23 20:25:52 +0400 |
commit | 426d246f5b8a4c598a913838b625e05e63ccb41f (patch) | |
tree | 16792dd3268c0ec0fb02837c761a535af1938b1f /strings/ctype-big5.c | |
parent | de8e306b6921ab32aedde957594e570166a7fce1 (diff) | |
download | mariadb-git-426d246f5b8a4c598a913838b625e05e63ccb41f.tar.gz |
MDEV-5163 Merge WEIGHT_STRING function from MySQL-5.6
Diffstat (limited to 'strings/ctype-big5.c')
-rw-r--r-- | strings/ctype-big5.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index cf9fc339280..38bdf86c64a 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -925,31 +925,35 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), } -static size_t my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), - uchar *dest, size_t len, - const uchar *src, size_t srclen) +static size_t +my_strnxfrm_big5(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, uint nweights, + const uchar *src, size_t srclen, uint flags) { - uint16 e; - size_t dstlen= len; - uchar *dest_end= dest + dstlen; - - len = srclen; - while (len-- && dest < dest_end) + uchar *d0= dst; + uchar *de= dst + dstlen; + const uchar *se= src + srclen; + const uchar *sort_order= cs->sort_order; + + for (; dst < de && src < se && nweights; nweights--) { - if ((len > 0) && isbig5code(*src, *(src+1))) + if (cs->cset->ismbchar(cs, (const char*) src, (const char*) se)) { - e = big5strokexfrm((uint16) big5code(*src, *(src+1))); - *dest++ = big5head(e); - if (dest < dest_end) - *dest++ = big5tail(e); - src +=2; - len--; - } else - *dest++ = sort_order_big5[(uchar) *src++]; + /* + Note, it is safe not to check (src < se) + in the code below, because ismbchar() would + not return TRUE if src was too short + */ + uint16 e= big5strokexfrm((uint16) big5code(*src, *(src + 1))); + *dst++= big5head(e); + if (dst < de) + *dst++= big5tail(e); + src+= 2; + } + else + *dst++= sort_order ? sort_order[*src++] : *src++; } - if (dstlen > srclen) - bfill(dest, dstlen - srclen, ' '); - return dstlen; + return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0); } #if 0 @@ -6948,6 +6952,7 @@ struct charset_info_st my_charset_big5_chinese_ci= 0xF9D5, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ + 1, /* levels_for_order */ &my_charset_big5_handler, &my_collation_big5_chinese_ci_handler }; @@ -6980,6 +6985,7 @@ struct charset_info_st my_charset_big5_bin= 0xF9FE, /* max_sort_char */ ' ', /* pad char */ 1, /* escape_with_backslash_is_dangerous */ + 1, /* levels_for_order */ &my_charset_big5_handler, &my_collation_mb_bin_handler }; |