diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-10-10 14:36:09 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2016-10-10 14:36:09 +0400 |
commit | 5058ced5df7a4ee3ff011577829fb2e4a6f47843 (patch) | |
tree | 8f90cd07e71cef5dc09adfd825712f812f978f57 /strings | |
parent | a6f032af5778018051d41fc8ba7e9c983b4b7fbf (diff) | |
download | mariadb-git-5058ced5df7a4ee3ff011577829fb2e4a6f47843.tar.gz |
MDEV-7769 MY_CHARSET_INFO refactoring# On branch 10.2
Part 3 (final): removing MY_CHARSET_HANDLER::well_formed_len().
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-cp932.c | 1 | ||||
-rw-r--r-- | strings/ctype-euc_kr.c | 1 | ||||
-rw-r--r-- | strings/ctype-eucjpms.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 | 22 | ||||
-rw-r--r-- | strings/ctype-mb.ic | 69 | ||||
-rw-r--r-- | strings/ctype-simple.c | 11 | ||||
-rw-r--r-- | strings/ctype-sjis.c | 1 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 1 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 66 | ||||
-rw-r--r-- | strings/ctype-ujis.c | 1 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 47 | ||||
-rw-r--r-- | strings/ctype.c | 26 | ||||
-rw-r--r-- | strings/my_vsnprintf.c | 3 |
18 files changed, 16 insertions, 239 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index dd66da224ba..22cb83a8806 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6775,7 +6775,6 @@ static MY_CHARSET_HANDLER my_charset_big5_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_big5, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_big5, /* mb_wc */ diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 5655edd6063..0bbbd282530 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -535,7 +535,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_8bit, my_charpos_8bit, - my_well_formed_len_8bit, my_lengthsp_binary, my_numcells_8bit, my_mb_wc_bin, diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 83f8d40c480..46226f92ba7 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -34731,7 +34731,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_cp932, my_lengthsp_8bit, my_numcells_cp932, my_mb_wc_cp932, /* mb_wc */ diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index e2a50da2ed4..1af182db9aa 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -10021,7 +10021,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_euckr, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_euc_kr, /* mb_wc */ diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index 47d03bd5d99..f70dc69bafa 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -67559,7 +67559,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_eucjpms, my_lengthsp_8bit, my_numcells_eucjpms, my_mb_wc_eucjpms, /* mb_wc */ diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 832c6c7f038..42235a54e69 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -6426,7 +6426,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_gb2312, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_gb2312, /* mb_wc */ diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index d24b77950c2..ae454591d08 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -10708,7 +10708,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_gbk, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_gbk, diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 6f71c7a0c76..12871c2b7c7 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -398,7 +398,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_8bit, my_charpos_8bit, - my_well_formed_len_8bit, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_latin1, diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index d78e758010d..6438273bc4b 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -401,28 +401,6 @@ size_t my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), } -size_t my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, - size_t pos, int *error) -{ - const char *b_start= b; - *error= 0; - while (pos) - { - my_wc_t wc; - int mb_len; - - if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) - { - *error= b < e ? 1 : 0; - break; - } - b+= mb_len; - pos--; - } - return (size_t) (b - b_start); -} - - /* Append a badly formed piece of string. Bad bytes are fixed to '?'. diff --git a/strings/ctype-mb.ic b/strings/ctype-mb.ic index 2df9c9d5e49..4806331c737 100644 --- a/strings/ctype-mb.ic +++ b/strings/ctype-mb.ic @@ -30,7 +30,6 @@ #ifdef DEFINE_ASIAN_ROUTINES -#define DEFINE_WELL_FORMED_LEN #define DEFINE_WELL_FORMED_CHAR_LENGTH #define DEFINE_CHARLEN #define DEFINE_NATIVE_TO_MB_VARLEN @@ -96,73 +95,7 @@ MY_FUNCTION_NAME(charlen)(CHARSET_INFO *cs __attribute__((unused)), /* Wrong byte sequence */ return MY_CS_ILSEQ; } -#endif /* DEFINE_WELL_FORMED_LEN */ - - -#ifdef DEFINE_WELL_FORMED_LEN -/** - Returns well formed length of a character string with - variable character length for character sets with: - - mbminlen == 1 - - mbmaxlen == 2, 3, or 4 -*/ -static size_t -MY_FUNCTION_NAME(well_formed_len)(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - size_t nchars, int *error) -{ - const char *b0= b; - - DBUG_ASSERT(cs->mbminlen == 1); - DBUG_ASSERT(cs->mbmaxlen <= 4); - - for (*error= 0 ; b < e && nchars-- ; ) - { - if ((uchar) b[0] < 128) - { - b++; /* Single byte ASCII character */ - continue; - } - - if (b + 2 <= e && IS_MB2_CHAR(b[0], b[1])) - { - b+= 2; /* Double byte character */ - continue; - } - -#ifdef IS_MB3_CHAR - if (b + 3 <= e && IS_MB3_CHAR(b[0], b[1], b[2])) - { - b+= 3; /* Three-byte character */ - continue; - } -#endif - -#ifdef IS_MB4_CHAR - if (b + 4 <= e && IS_MB4_CHAR(b[0], b[1], b[2], b[3])) - { - b+= 4; /* Four-byte character */ - continue; - } -#endif - -#ifdef IS_8BIT_CHAR - if (IS_8BIT_CHAR(b[0])) - { - b++; /* Single byte non-ASCII character, e.g. half width kana in sjis */ - continue; - } -#endif - - /* Wrong byte sequence */ - *error= 1; - break; - } - return b - b0; -} - -#endif /* DEFINE_WELL_FORMED_LEN */ - +#endif /* DEFINE_CHARLEN */ #ifdef DEFINE_WELL_FORMED_CHAR_LENGTH diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index b142aab18a6..99f26731851 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1143,16 +1143,6 @@ size_t my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), } -size_t my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *start, const char *end, - size_t nchars, int *error) -{ - size_t nbytes= (size_t) (end-start); - *error= 0; - return MY_MIN(nbytes, nchars); -} - - size_t my_well_formed_char_length_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *start, const char *end, @@ -2064,7 +2054,6 @@ MY_CHARSET_HANDLER my_charset_8bit_handler= my_cset_init_8bit, my_numchars_8bit, my_charpos_8bit, - my_well_formed_len_8bit, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_8bit, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 94fd69c79c0..36aab369c4a 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -34110,7 +34110,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_sjis, my_lengthsp_8bit, my_numcells_sjis, my_mb_wc_sjis, /* mb_wc */ diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 72a33036085..4dbb66d89c5 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -880,7 +880,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_8bit, my_charpos_8bit, - my_well_formed_len_8bit, my_lengthsp_8bit, my_numcells_8bit, my_mb_wc_tis620, /* mb_wc */ diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 9d8353103f0..e154545e4f6 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1490,27 +1490,6 @@ my_charpos_utf16(CHARSET_INFO *cs, } -static size_t -my_well_formed_len_utf16(CHARSET_INFO *cs, - const char *b, const char *e, - size_t nchars, int *error) -{ - const char *b0= b; - uint charlen; - *error= 0; - - for ( ; nchars; b+= charlen, nchars--) - { - if (!(charlen= my_ismbchar(cs, b, e))) - { - *error= b < e ? 1 : 0; - break; - } - } - return (size_t) (b - b0); -} - - static int my_wildcmp_utf16_ci(CHARSET_INFO *cs, const char *str,const char *str_end, @@ -1629,7 +1608,6 @@ MY_CHARSET_HANDLER my_charset_utf16_handler= NULL, /* init */ my_numchars_utf16, my_charpos_utf16, - my_well_formed_len_utf16, my_lengthsp_mb2, my_numcells_mb, my_utf16_uni, /* mb_wc */ @@ -1963,7 +1941,6 @@ static MY_CHARSET_HANDLER my_charset_utf16le_handler= NULL, /* init */ my_numchars_utf16, my_charpos_utf16, - my_well_formed_len_utf16, my_lengthsp_utf16le, my_numcells_mb, my_utf16le_uni, /* mb_wc */ @@ -2636,34 +2613,6 @@ my_charpos_utf32(CHARSET_INFO *cs __attribute__((unused)), } -static size_t -my_well_formed_len_utf32(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - size_t nchars, int *error) -{ - /* Ensure string length is divisible by 4 */ - const char *b0= b; - size_t length= e - b; - DBUG_ASSERT((length % 4) == 0); - *error= 0; - nchars*= 4; - if (length > nchars) - { - length= nchars; - e= b + nchars; - } - for (; b < e; b+= 4) - { - if (!IS_UTF32_MBHEAD4(b[0], b[1])) - { - *error= 1; - return b - b0; - } - } - return length; -} - - static void my_fill_utf32(CHARSET_INFO *cs, char *s, size_t slen, int fill) @@ -2809,7 +2758,6 @@ MY_CHARSET_HANDLER my_charset_utf32_handler= NULL, /* init */ my_numchars_utf32, my_charpos_utf32, - my_well_formed_len_utf32, my_lengthsp_utf32, my_numcells_mb, my_utf32_uni, @@ -3248,19 +3196,6 @@ size_t my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), } -static -size_t my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - size_t nchars, int *error) -{ - /* Ensure string length is dividable with 2 */ - size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1; - *error= 0; - nchars*= 2; - return MY_MIN(nbytes, nchars); -} - - static size_t my_well_formed_char_length_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e, @@ -3403,7 +3338,6 @@ MY_CHARSET_HANDLER my_charset_ucs2_handler= NULL, /* init */ my_numchars_ucs2, my_charpos_ucs2, - my_well_formed_len_ucs2, my_lengthsp_mb2, my_numcells_mb, my_ucs2_uni, /* mb_wc */ diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index 8c08e906284..4c553d15526 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -67303,7 +67303,6 @@ static MY_CHARSET_HANDLER my_charset_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_ujis, my_lengthsp_8bit, my_numcells_eucjp, my_mb_wc_euc_jp, /* mb_wc */ diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 39d3521baa4..ac262b81eb1 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -5421,27 +5421,6 @@ int my_charlen_utf8(CHARSET_INFO *cs __attribute__((unused)), return MY_CS_ILSEQ; } -static size_t -my_well_formed_len_utf8(CHARSET_INFO *cs, const char *b, const char *e, - size_t pos, int *error) -{ - const char *b_start= b; - *error= 0; - while (pos) - { - int mb_len; - - if ((mb_len= my_charlen_utf8(cs, (uchar*) b, (uchar*) e)) <= 0) - { - *error= b < e ? 1 : 0; - break; - } - b+= mb_len; - pos--; - } - return (size_t) (b - b_start); -} - #define MY_FUNCTION_NAME(x) my_ ## x ## _utf8 #define CHARLEN(cs,str,end) my_charlen_utf8(cs,str,end) @@ -5656,7 +5635,6 @@ MY_CHARSET_HANDLER my_charset_utf8_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_utf8, my_lengthsp_8bit, my_numcells_mb, my_utf8_uni, @@ -7276,7 +7254,6 @@ static MY_CHARSET_HANDLER my_charset_filename_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_mb, my_lengthsp_8bit, my_numcells_mb, my_mb_wc_filename, @@ -7885,29 +7862,6 @@ my_charlen_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), } -static -size_t my_well_formed_len_utf8mb4(CHARSET_INFO *cs, - const char *b, const char *e, - size_t pos, int *error) -{ - const char *b_start= b; - *error= 0; - while (pos) - { - int mb_len; - - if ((mb_len= my_charlen_utf8mb4(cs, (uchar*) b, (uchar*) e)) <= 0) - { - *error= b < e ? 1 : 0; - break; - } - b+= mb_len; - pos--; - } - return (size_t) (b - b_start); -} - - #define MY_FUNCTION_NAME(x) my_ ## x ## _utf8mb4 #define CHARLEN(cs,str,end) my_charlen_utf8mb4(cs,str,end) #define DEFINE_WELL_FORMED_CHAR_LENGTH_USING_CHARLEN @@ -8033,7 +7987,6 @@ MY_CHARSET_HANDLER my_charset_utf8mb4_handler= NULL, /* init */ my_numchars_mb, my_charpos_mb, - my_well_formed_len_utf8mb4, my_lengthsp_8bit, my_numcells_mb, my_mb_wc_utf8mb4, diff --git a/strings/ctype.c b/strings/ctype.c index 7d9789e48e2..7348cbfa1f9 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -1138,7 +1138,9 @@ my_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, size_t my_convert_fix(CHARSET_INFO *to_cs, char *to, size_t to_length, CHARSET_INFO *from_cs, const char *from, size_t from_length, - size_t nchars, MY_STRCONV_STATUS *status) + size_t nchars, + MY_STRCOPY_STATUS *copy_status, + MY_STRCONV_STATUS *conv_status) { int cnvres; my_wc_t wc; @@ -1151,8 +1153,8 @@ my_convert_fix(CHARSET_INFO *to_cs, char *to, size_t to_length, DBUG_ASSERT(to_cs != &my_charset_bin); DBUG_ASSERT(from_cs != &my_charset_bin); - status->m_native_copy_status.m_well_formed_error_pos= NULL; - status->m_cannot_convert_error_pos= NULL; + copy_status->m_well_formed_error_pos= NULL; + conv_status->m_cannot_convert_error_pos= NULL; for ( ; nchars; nchars--) { @@ -1161,8 +1163,8 @@ my_convert_fix(CHARSET_INFO *to_cs, char *to, size_t to_length, from+= cnvres; else if (cnvres == MY_CS_ILSEQ) { - if (!status->m_native_copy_status.m_well_formed_error_pos) - status->m_native_copy_status.m_well_formed_error_pos= from; + if (!copy_status->m_well_formed_error_pos) + copy_status->m_well_formed_error_pos= from; from++; wc= '?'; } @@ -1172,8 +1174,8 @@ my_convert_fix(CHARSET_INFO *to_cs, char *to, size_t to_length, A correct multibyte sequence detected But it doesn't have Unicode mapping. */ - if (!status->m_cannot_convert_error_pos) - status->m_cannot_convert_error_pos= from; + if (!conv_status->m_cannot_convert_error_pos) + conv_status->m_cannot_convert_error_pos= from; from+= (-cnvres); wc= '?'; } @@ -1182,8 +1184,8 @@ my_convert_fix(CHARSET_INFO *to_cs, char *to, size_t to_length, if ((uchar *) from >= from_end) break; // End of line // Incomplete byte sequence - if (!status->m_native_copy_status.m_well_formed_error_pos) - status->m_native_copy_status.m_well_formed_error_pos= from; + if (!copy_status->m_well_formed_error_pos) + copy_status->m_well_formed_error_pos= from; from++; wc= '?'; } @@ -1192,8 +1194,8 @@ outp: to+= cnvres; else if (cnvres == MY_CS_ILUNI && wc != '?') { - if (!status->m_cannot_convert_error_pos) - status->m_cannot_convert_error_pos= from_prev; + if (!conv_status->m_cannot_convert_error_pos) + conv_status->m_cannot_convert_error_pos= from_prev; wc= '?'; goto outp; } @@ -1203,6 +1205,6 @@ outp: break; } } - status->m_native_copy_status.m_source_end_pos= from; + copy_status->m_source_end_pos= from; return to - to_start; } diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 846803d9b24..ad270bd9b64 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -205,8 +205,7 @@ static char *process_str_arg(CHARSET_INFO *cs, char *to, const char *end, plen= strnlen(par, width); if (left_len <= plen) plen = left_len - 1; - plen= cs->cset->well_formed_len(cs, par, par + plen, - width, &well_formed_error); + plen= my_well_formed_length(cs, par, par + plen, width, &well_formed_error); if (print_type & ESCAPED_ARG) to= backtick_string(cs, to, end, par, plen, '`'); else |