diff options
author | unknown <bar@mysql.com/bar.myoffice.izhnet.ru> | 2007-06-07 17:55:55 +0500 |
---|---|---|
committer | unknown <bar@mysql.com/bar.myoffice.izhnet.ru> | 2007-06-07 17:55:55 +0500 |
commit | af0a3afe054cc2be3600180cfdeef28761be2f7e (patch) | |
tree | 6e38a11989e338107855129634fe59859fd19419 /mysys/charset.c | |
parent | c3ba8178b5c8d9c3d885119f4a1f4bc103513578 (diff) | |
download | mariadb-git-af0a3afe054cc2be3600180cfdeef28761be2f7e.tar.gz |
Bug#28916 LDML doesn't work for utf8
and is not described in the manual
- Adding missing initialization for utf8 collations
- Minor code clean-ups: renaming variables,
moving code into a new separate function.
- Adding test, to check that both ucs2 and utf8 user
defined collations work (ucs2_test_ci and utf8_test_ci)
- Adding Vietnamese collation as a complex user defined
collation example.
include/m_ctype.h:
Renaming variable names to match collation names (for convenience).
mysys/charset-def.c:
- Removing redundant declarations for variables declared in m_ctype.h
- Renaming variable names to match collation names (for convenience).
mysys/charset.c:
- Renaming "new" to "newcs", to avoid using C reserved word as a variable name
- Moving UCA initialization code into a separate function
- The bug fix itself: adding initialization of utf8 collations
strings/ctype-uca.c:
Renaming variable names to match collation names (for convenience).
strings/ctype.c:
Increasing buffer size to fit tailoring for languages
with complex rules (e.g. Vietnamese).
mysql-test/r/ctype_ldml.result:
Adding test case
mysql-test/std_data/Index.xml:
Adding Index.xml example with user defined collations.
mysql-test/t/ctype_ldml-master.opt:
Adding OPT file for the test case,
to use the example Index.xml file.
mysql-test/t/ctype_ldml.test:
Adding test case
Diffstat (limited to 'mysys/charset.c')
-rw-r--r-- | mysys/charset.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index cce97677b14..9ea17c6515c 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -202,6 +202,19 @@ static my_bool simple_cs_is_full(CHARSET_INFO *cs) } +static void +copy_uca_collation(CHARSET_INFO *to, CHARSET_INFO *from) +{ + to->cset= from->cset; + to->coll= from->coll; + to->strxfrm_multiply= from->strxfrm_multiply; + to->min_sort_char= from->min_sort_char; + to->max_sort_char= from->max_sort_char; + to->mbminlen= from->mbminlen; + to->mbmaxlen= from->mbmaxlen; +} + + static int add_collation(CHARSET_INFO *cs) { if (cs->name && (cs->number || @@ -225,29 +238,30 @@ static int add_collation(CHARSET_INFO *cs) if (!(all_charsets[cs->number]->state & MY_CS_COMPILED)) { - CHARSET_INFO *new= all_charsets[cs->number]; + CHARSET_INFO *newcs= all_charsets[cs->number]; if (cs_copy_data(all_charsets[cs->number],cs)) return MY_XML_ERROR; if (!strcmp(cs->csname,"ucs2") ) { #if defined(HAVE_CHARSET_ucs2) && defined(HAVE_UCA_COLLATIONS) - new->cset= my_charset_ucs2_general_uca.cset; - new->coll= my_charset_ucs2_general_uca.coll; - new->strxfrm_multiply= my_charset_ucs2_general_uca.strxfrm_multiply; - new->min_sort_char= my_charset_ucs2_general_uca.min_sort_char; - new->max_sort_char= my_charset_ucs2_general_uca.max_sort_char; - new->mbminlen= 2; - new->mbmaxlen= 2; - new->state |= MY_CS_AVAILABLE | MY_CS_LOADED; + copy_uca_collation(newcs, &my_charset_ucs2_unicode_ci); + newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED; #endif } + else if (!strcmp(cs->csname, "utf8")) + { +#if defined (HAVE_CHARSET_utf8) && defined(HAVE_UCA_COLLATIONS) + copy_uca_collation(newcs, &my_charset_utf8_unicode_ci); + newcs->state|= MY_CS_AVAILABLE | MY_CS_LOADED; +#endif + } else { uchar *sort_order= all_charsets[cs->number]->sort_order; simple_cs_init_functions(all_charsets[cs->number]); - new->mbminlen= 1; - new->mbmaxlen= 1; + newcs->mbminlen= 1; + newcs->mbmaxlen= 1; if (simple_cs_is_full(all_charsets[cs->number])) { all_charsets[cs->number]->state |= MY_CS_LOADED; |