diff options
| author | Alexander Barkov <bar@mariadb.org> | 2016-05-17 15:27:10 +0400 |
|---|---|---|
| committer | Alexander Barkov <bar@mariadb.org> | 2016-05-17 15:27:10 +0400 |
| commit | e7ff281d2e954f9ab7f08a3e1a425a3c59e8f796 (patch) | |
| tree | e8e3903a609daef952785e28e5c876bafd52ba7b /strings | |
| parent | 7e66a24dfb381290d59786c36e1dc478ad365bd1 (diff) | |
| download | mariadb-git-e7ff281d2e954f9ab7f08a3e1a425a3c59e8f796.tar.gz | |
MDEV-6353 my_ismbchar() and my_mbcharlen() refactoring
Diffstat (limited to 'strings')
| -rw-r--r-- | strings/ctype-big5.c | 7 | ||||
| -rw-r--r-- | strings/ctype-bin.c | 8 | ||||
| -rw-r--r-- | strings/ctype-cp932.c | 7 | ||||
| -rw-r--r-- | strings/ctype-euc_kr.c | 7 | ||||
| -rw-r--r-- | strings/ctype-eucjpms.c | 7 | ||||
| -rw-r--r-- | strings/ctype-gb2312.c | 7 | ||||
| -rw-r--r-- | strings/ctype-gbk.c | 6 | ||||
| -rw-r--r-- | strings/ctype-latin1.c | 1 | ||||
| -rw-r--r-- | strings/ctype-mb.c | 2 | ||||
| -rw-r--r-- | strings/ctype-simple.c | 8 | ||||
| -rw-r--r-- | strings/ctype-sjis.c | 7 | ||||
| -rw-r--r-- | strings/ctype-tis620.c | 1 | ||||
| -rw-r--r-- | strings/ctype-ucs2.c | 34 | ||||
| -rw-r--r-- | strings/ctype-ujis.c | 7 | ||||
| -rw-r--r-- | strings/ctype-utf8.c | 86 | ||||
| -rw-r--r-- | strings/my_strchr.c | 5 | ||||
| -rw-r--r-- | strings/my_vsnprintf.c | 3 |
17 files changed, 17 insertions, 186 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 962931913a2..9ae394eeedc 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -848,12 +848,6 @@ static uint16 big5strokexfrm(uint16 i) } -static uint mbcharlen_big5(CHARSET_INFO *cs __attribute__((unused)), uint c) -{ - return (isbig5head(c)? 2 : 1); -} - - /* page 0 0xA140-0xC7FC */ static const uint16 tab_big5_uni0[]={ 0x3000,0xFF0C,0x3001,0x3002,0xFF0E,0x2022,0xFF1B,0xFF1A, @@ -6731,7 +6725,6 @@ static MY_COLLATION_HANDLER my_collation_handler_big5_bin= static MY_CHARSET_HANDLER my_charset_big5_handler= { NULL, /* init */ - mbcharlen_big5, my_numchars_mb, my_charpos_mb, my_well_formed_len_big5, diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 8331de34ee4..aab7f2b7448 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -225,13 +225,6 @@ static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)), } -uint my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), - uint c __attribute__((unused))) -{ - return 1; -} - - static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, const uchar *str, @@ -510,7 +503,6 @@ static MY_COLLATION_HANDLER my_collation_binary_handler = static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, my_well_formed_len_8bit, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 2163662269d..151fac8a052 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -191,12 +191,6 @@ static const uchar sort_order_cp932[]= #include "ctype-mb.ic" -static uint mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (iscp932head((uchar) c) ? 2 : 1); -} - - #define cp932code(c,d) ((((uint) (uchar)(c)) << 8) | (uint) (uchar) (d)) @@ -34687,7 +34681,6 @@ static MY_COLLATION_HANDLER my_collation_handler_cp932_bin= static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_cp932, my_numchars_mb, my_charpos_mb, my_well_formed_len_cp932, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 19ed586ea49..d2389136c49 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -210,12 +210,6 @@ static const uchar sort_order_euc_kr[]= #include "ctype-mb.ic" -static uint mbcharlen_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (iseuc_kr_head(c) ? 2 : 1); -} - - static MY_UNICASE_CHARACTER cA3[256]= { {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, /* xx00 */ @@ -9979,7 +9973,6 @@ static MY_COLLATION_HANDLER my_collation_handler_euckr_bin= static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_euc_kr, my_numchars_mb, my_charpos_mb, my_well_formed_len_euckr, diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 469d3a5be6c..caafd1d13b4 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -221,12 +221,6 @@ static const uchar sort_order_eucjpms[]= #include "strcoll.ic" -static uint mbcharlen_eucjpms(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (iseucjpms(c)? 2: iseucjpms_ss2(c)? 2: iseucjpms_ss3(c)? 3: 1); -} - - /* Case info pages for JIS-X-0208 range */ static MY_UNICASE_CHARACTER cA2[256]= @@ -67511,7 +67505,6 @@ static MY_COLLATION_HANDLER my_collation_eucjpms_bin_handler = static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_eucjpms, my_numchars_mb, my_charpos_mb, my_well_formed_len_eucjpms, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index a77237c1791..dbb92fabc4b 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -173,12 +173,6 @@ static const uchar sort_order_gb2312[]= #include "ctype-mb.ic" -static uint mbcharlen_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (isgb2312head(c)? 2 : 1); -} - - static MY_UNICASE_CHARACTER cA2[256]= { {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, /* xx00 */ @@ -6385,7 +6379,6 @@ static MY_COLLATION_HANDLER my_collation_handler_gb2312_bin= static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_gb2312, my_numchars_mb, my_charpos_mb, my_well_formed_len_gb2312, diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index e4e015a59d2..617d72dc4d9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -3451,11 +3451,6 @@ static uint16 gbksortorder(uint16 i) } -static uint mbcharlen_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (isgbkhead(c)? 2 : 1); -} - /* page 0 0x8140-0xFE4F */ static const uint16 tab_gbk_uni0[]={ 0x4E02,0x4E04,0x4E05,0x4E06,0x4E0F,0x4E12,0x4E17,0x4E1F, @@ -10666,7 +10661,6 @@ static MY_COLLATION_HANDLER my_collation_handler_gbk_bin= static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_gbk, my_numchars_mb, my_charpos_mb, my_well_formed_len_gbk, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index aba63d97abb..fe255349530 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -396,7 +396,6 @@ int my_wc_mb_latin1(CHARSET_INFO *cs __attribute__((unused)), static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - my_mbcharlen_8bit, my_numchars_8bit, my_charpos_8bit, my_well_formed_len_8bit, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 3fa66cb0b2f..56b3309ca10 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -230,7 +230,7 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t) if (*s++ != *t++) return 1; } - else if (my_mbcharlen(cs, *t) > 1) + else if (my_charlen(cs, t, t + cs->mbmaxlen) > 1) return 1; else if (map[(uchar) *s++] != map[(uchar) *t++]) return 1; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 5e5a345a638..f405c4f327b 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1059,6 +1059,13 @@ size_t my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) break; } return (size_t) (str - str0); + case MY_SEQ_NONSPACES: + for ( ; str < end ; str++) + { + if (my_isspace(cs, *str)) + break; + } + return (size_t) (str - str0); default: return 0; } @@ -1916,7 +1923,6 @@ my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs, MY_CHARSET_HANDLER my_charset_8bit_handler= { my_cset_init_8bit, - my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, my_well_formed_len_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index ebcea22d242..e0546146008 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -192,12 +192,6 @@ static const uchar sort_order_sjis[]= #include "ctype-mb.ic" -static uint mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (issjishead((uchar) c) ? 2 : 1); -} - - #define sjiscode(c,d) ((((uint) (uchar)(c)) << 8) | (uint) (uchar) (d)) @@ -34066,7 +34060,6 @@ static MY_COLLATION_HANDLER my_collation_handler_sjis_bin= static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_sjis, my_numchars_mb, my_charpos_mb, my_well_formed_len_sjis, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 711bb21773e..82fd864b05d 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -834,7 +834,6 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - my_mbcharlen_8bit, /* mbcharlen */ my_numchars_8bit, my_charpos_8bit, my_well_formed_len_8bit, diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 74e474cc28c..06dab08a772 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1049,6 +1049,9 @@ my_scan_mb2(CHARSET_INFO *cs __attribute__((unused)), { } return (size_t) (str - str0); + case MY_SEQ_NONSPACES: + DBUG_ASSERT(0); /* Not implemented */ + /* pass through */ default: return 0; } @@ -1431,15 +1434,6 @@ my_charlen_utf16(CHARSET_INFO *cs, const uchar *str, const uchar *end) /* Defines my_well_formed_char_length_utf16 */ -static uint -my_mbcharlen_utf16(CHARSET_INFO *cs __attribute__((unused)), - uint c __attribute__((unused))) -{ - DBUG_ASSERT(0); - return MY_UTF16_HIGH_HEAD(c) ? 4 : 2; -} - - static size_t my_numchars_utf16(CHARSET_INFO *cs, const char *b, const char *e) @@ -1567,7 +1561,6 @@ static MY_COLLATION_HANDLER my_collation_utf16_bin_handler = MY_CHARSET_HANDLER my_charset_utf16_handler= { NULL, /* init */ - my_mbcharlen_utf16, /* mbcharlen */ my_numchars_utf16, my_charpos_utf16, my_well_formed_len_utf16, @@ -1789,7 +1782,6 @@ static MY_COLLATION_HANDLER my_collation_utf16le_bin_handler = static MY_CHARSET_HANDLER my_charset_utf16le_handler= { NULL, /* init */ - my_mbcharlen_utf16, my_numchars_utf16, my_charpos_utf16, my_well_formed_len_utf16, @@ -2083,14 +2075,6 @@ my_charlen_utf32(CHARSET_INFO *cs __attribute__((unused)), /* Defines my_well_formed_char_length_utf32 */ -static uint -my_mbcharlen_utf32(CHARSET_INFO *cs __attribute__((unused)) , - uint c __attribute__((unused))) -{ - return 4; -} - - static int my_vsnprintf_utf32(char *dst, size_t n, const char* fmt, va_list ap) { @@ -2484,6 +2468,9 @@ my_scan_utf32(CHARSET_INFO *cs, str+= res; } return (size_t) (str - str0); + case MY_SEQ_NONSPACES: + DBUG_ASSERT(0); /* Not implemented */ + /* pass through */ default: return 0; } @@ -2525,7 +2512,6 @@ static MY_COLLATION_HANDLER my_collation_utf32_bin_handler = MY_CHARSET_HANDLER my_charset_utf32_handler= { NULL, /* init */ - my_mbcharlen_utf32, my_numchars_utf32, my_charpos_utf32, my_well_formed_len_utf32, @@ -2862,13 +2848,6 @@ my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), } -static uint my_mbcharlen_ucs2(CHARSET_INFO *cs __attribute__((unused)) , - uint c __attribute__((unused))) -{ - return 2; -} - - static size_t my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) @@ -3003,7 +2982,6 @@ static MY_COLLATION_HANDLER my_collation_ucs2_bin_handler = MY_CHARSET_HANDLER my_charset_ucs2_handler= { NULL, /* init */ - my_mbcharlen_ucs2, /* mbcharlen */ my_numchars_ucs2, my_charpos_ucs2, my_well_formed_len_ucs2, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index b24fdb3075f..786ae991aef 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -220,12 +220,6 @@ static const uchar sort_order_ujis[]= #include "strcoll.ic" -static uint mbcharlen_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c) -{ - return (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 1); -} - - static size_t my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) @@ -67255,7 +67249,6 @@ static MY_COLLATION_HANDLER my_collation_ujis_bin_handler = static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* init */ - mbcharlen_ujis, my_numchars_mb, my_charpos_mb, my_well_formed_len_ujis, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 3a5616b7323..b6a7a0d0347 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -5426,21 +5426,6 @@ my_weight_mb3_utf8_general_mysql500_ci(uchar b0, uchar b1, uchar b2) #include "strcoll.ic" -static uint my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)), - uint c) -{ - if (c < 0x80) - return 1; - else if (c < 0xc2) - return 0; /* Illegal mb head */ - else if (c < 0xe0) - return 2; - else if (c < 0xf0) - return 3; - return 0; /* Illegal mb head */; -} - - static MY_COLLATION_HANDLER my_collation_utf8_general_ci_handler = { NULL, /* init */ @@ -5491,7 +5476,6 @@ static MY_COLLATION_HANDLER my_collation_utf8_bin_handler = MY_CHARSET_HANDLER my_charset_utf8_handler= { NULL, /* init */ - my_mbcharlen_utf8, my_numchars_mb, my_charpos_mb, my_well_formed_len_utf8, @@ -7045,7 +7029,6 @@ static MY_COLLATION_HANDLER my_collation_filename_handler = static MY_CHARSET_HANDLER my_charset_filename_handler= { NULL, /* init */ - my_mbcharlen_utf8, my_numchars_mb, my_charpos_mb, my_well_formed_len_mb, @@ -7111,57 +7094,6 @@ struct charset_info_st my_charset_filename= }; -#ifdef MY_TEST_UTF8 -#include <stdio.h> - -static void test_mb(CHARSET_INFO *cs, uchar *s) -{ - while(*s) - { - if (my_ismbhead_utf8(cs,*s)) - { - uint len=my_mbcharlen_utf8(cs,*s); - while(len--) - { - printf("%c",*s); - s++; - } - printf("\n"); - } - else - { - printf("%c\n",*s); - s++; - } - } -} - -int main() -{ - char str[1024]=" utf8 test проба ПЕРА по-РУССКИ"; - CHARSET_INFO *cs; - - test_mb(cs,(uchar*)str); - - printf("orig :'%s'\n",str); - - my_caseup_utf8(cs,str,15); - printf("caseup :'%s'\n",str); - - my_caseup_str_utf8(cs,str); - printf("caseup_str:'%s'\n",str); - - my_casedn_utf8(cs,str,15); - printf("casedn :'%s'\n",str); - - my_casedn_str_utf8(cs,str); - printf("casedn_str:'%s'\n",str); - - return 0; -} - -#endif - #endif /* HAVE_CHARSET_UTF8 */ @@ -7755,23 +7687,6 @@ size_t my_well_formed_len_utf8mb4(CHARSET_INFO *cs, #include "strcoll.ic" -static uint -my_mbcharlen_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), uint c) -{ - if (c < 0x80) - return 1; - if (c < 0xc2) - return 0; /* Illegal mb head */ - if (c < 0xe0) - return 2; - if (c < 0xf0) - return 3; - if (c < 0xf8) - return 4; - return 0; /* Illegal mb head */; -} - - static MY_COLLATION_HANDLER my_collation_utf8mb4_general_ci_handler= { NULL, /* init */ @@ -7807,7 +7722,6 @@ static MY_COLLATION_HANDLER my_collation_utf8mb4_bin_handler = MY_CHARSET_HANDLER my_charset_utf8mb4_handler= { NULL, /* init */ - my_mbcharlen_utf8mb4, my_numchars_mb, my_charpos_mb, my_well_formed_len_utf8mb4, diff --git a/strings/my_strchr.c b/strings/my_strchr.c index 0305ef89542..2365731fa03 100644 --- a/strings/my_strchr.c +++ b/strings/my_strchr.c @@ -38,7 +38,7 @@ const char *acc_end= (ACC) + (LEN); \ for (ptr_str= (STR) ; ptr_str < (END) ; ptr_str+= mbl) \ { \ - mbl= my_mbcharlen((CS), *(uchar*)ptr_str); \ + mbl= my_charlen_fix((CS), ptr_str, (END)); \ if (mbl < 2) \ { \ DBUG_ASSERT(mbl == 1); \ @@ -63,10 +63,9 @@ end: \ char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end, pchar c) { - uint mbl; while (str < end) { - mbl= my_mbcharlen(cs, *(uchar *)str); + uint mbl= my_ismbchar(cs, str, end); if (mbl < 2) { if (*str == c) diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 4178b20789d..75514a90925 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -168,8 +168,7 @@ static char *backtick_string(CHARSET_INFO *cs, char *to, const char *end, for ( ; par < par_end; par+= char_len) { uchar c= *(uchar *) par; - if (!(char_len= my_mbcharlen(cs, c))) - char_len= 1; + char_len= my_charlen_fix(cs, par, par_end); if (char_len == 1 && c == (uchar) quote_char ) { if (start + 1 >= end) |
