diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-01-26 20:27:13 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-01-28 12:29:23 +0400 |
commit | f1e13fdc8d9e78f4529aa60b6a9b49c6ff063c66 (patch) | |
tree | ce84da1deeea573be5be7db7d739a4c9ba9b40f8 /strings | |
parent | dd68ba74f357aca074609cbd77491ed4ba390369 (diff) | |
download | mariadb-git-f1e13fdc8d9e78f4529aa60b6a9b49c6ff063c66.tar.gz |
MDEV-21581 Helper functions and methods for CHARSET_INFO
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-mb.c | 59 | ||||
-rw-r--r-- | strings/ctype-simple.c | 10 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 4 | ||||
-rw-r--r-- | strings/ctype-uca.c | 12 | ||||
-rw-r--r-- | strings/ctype-uca.ic | 4 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 23 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 8 | ||||
-rw-r--r-- | strings/ctype.c | 15 | ||||
-rw-r--r-- | strings/json_lib.c | 31 | ||||
-rw-r--r-- | strings/my_strchr.c | 5 | ||||
-rw-r--r-- | strings/my_vsnprintf.c | 4 | ||||
-rw-r--r-- | strings/strcoll.ic | 7 |
12 files changed, 93 insertions, 89 deletions
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index f2683726151..e7a218bdc47 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -158,7 +158,7 @@ int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t) if (*s++ != *t++) return 1; } - else if (my_charlen(cs, t, t + cs->mbmaxlen) > 1) + else if (my_ci_charlen(cs, (const uchar *) t, (const uchar *) t + cs->mbmaxlen) > 1) return 1; else if (map[(uchar) *s++] != map[(uchar) *t++]) return 1; @@ -354,8 +354,8 @@ my_append_fix_badly_formed_tail(CHARSET_INFO *cs, for ( ; nchars; nchars--) { int chlen; - if ((chlen= cs->cset->charlen(cs, (const uchar*) from, - (const uchar *) from_end)) > 0) + if ((chlen= my_ci_charlen(cs, (const uchar*) from, + (const uchar *) from_end)) > 0) { /* Found a valid character */ /* chlen == 1..MBMAXLEN */ DBUG_ASSERT(chlen <= (int) cs->mbmaxlen); @@ -381,7 +381,7 @@ bad: if (!status->m_well_formed_error_pos) status->m_well_formed_error_pos= from; - if ((chlen= cs->cset->wc_mb(cs, '?', (uchar*) to, (uchar *) to_end)) <= 0) + if ((chlen= my_ci_wc_mb(cs, '?', (uchar*) to, (uchar *) to_end)) <= 0) break; /* Question mark does not fit into the destination */ to+= chlen; from++; @@ -403,8 +403,7 @@ my_copy_fix_mb(CHARSET_INFO *cs, size_t fixed_length; set_if_smaller(src_length, dst_length); - well_formed_nchars= cs->cset->well_formed_char_length(cs, - src, src + src_length, + well_formed_nchars= my_ci_well_formed_char_length(cs, src, src + src_length, nchars, status); DBUG_ASSERT(well_formed_nchars <= nchars); memmove(dst, src, (well_formed_length= status->m_source_end_pos - src)); @@ -450,8 +449,8 @@ uint my_instr_mb(CHARSET_INFO *cs, { int mb_len; - if (!cs->coll->strnncoll(cs, (uchar*) b, s_length, - (uchar*) s, s_length, 0)) + if (!my_ci_strnncoll(cs, (const uchar *) b, s_length, + (const uchar *) s, s_length, 0)) { if (nmatch) { @@ -660,7 +659,7 @@ my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), static void pad_max_char(CHARSET_INFO *cs, char *str, char *end) { char buf[10]; - char buflen= cs->cset->native_to_mb(cs, cs->max_sort_char, (uchar*) buf, + char buflen= my_ci_native_to_mb(cs, cs->max_sort_char, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); do @@ -875,7 +874,7 @@ my_like_range_generic(CHARSET_INFO *cs, { my_wc_t wc, wc2; int res; - if ((res= cs->cset->mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) + if ((res= my_ci_mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) { if (res == MY_CS_ILSEQ) /* Bad sequence */ return TRUE; /* min_length and max_length are not important */ @@ -885,7 +884,7 @@ my_like_range_generic(CHARSET_INFO *cs, if (wc == (my_wc_t) escape) { - if ((res= cs->cset->mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) + if ((res= my_ci_mb_wc(cs, &wc, (uchar*) ptr, (uchar*) end)) <= 0) { if (res == MY_CS_ILSEQ) return TRUE; /* min_length and max_length are not important */ @@ -899,26 +898,24 @@ my_like_range_generic(CHARSET_INFO *cs, ptr+= res; /* Put escape character to min_str and max_str */ - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; /* No space */ min_str+= res; - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; /* No space */ max_str+= res; continue; } else if (wc == (my_wc_t) w_one) { - if ((res= cs->cset->wc_mb(cs, cs->min_sort_char, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, cs->min_sort_char, + (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; min_str+= res; - if ((res= cs->cset->wc_mb(cs, cs->max_sort_char, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, cs->max_sort_char, + (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; max_str+= res; continue; @@ -939,7 +936,7 @@ my_like_range_generic(CHARSET_INFO *cs, if (contractions && my_uca_can_be_contraction_head(contractions, wc) && - (res= cs->cset->mb_wc(cs, &wc2, (uchar*) ptr, (uchar*) end)) > 0) + (res= my_ci_mb_wc(cs, &wc2, (uchar*) ptr, (uchar*) end)) > 0) { const uint16 *weight; if ((wc2 == (my_wc_t) w_one || wc2 == (my_wc_t) w_many)) @@ -964,13 +961,11 @@ my_like_range_generic(CHARSET_INFO *cs, charlen--; /* Put contraction head */ - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; min_str+= res; - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; max_str+= res; wc= wc2; /* Prepare to put contraction tail */ @@ -978,12 +973,10 @@ my_like_range_generic(CHARSET_INFO *cs, } /* Normal character, or contraction tail */ - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) min_str, (uchar*) min_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) min_str, (uchar*) min_end)) <= 0) goto pad_set_lengths; min_str+= res; - if ((res= cs->cset->wc_mb(cs, wc, - (uchar*) max_str, (uchar*) max_end)) <= 0) + if ((res= my_ci_wc_mb(cs, wc, (uchar*) max_str, (uchar*) max_end)) <= 0) goto pad_set_lengths; max_str+= res; } @@ -1000,9 +993,9 @@ pad_min_max: Make sure to call fill() with proper "length" argument. */ res_length_diff= res_length % cs->mbminlen; - cs->cset->fill(cs, min_str, min_end - min_str - res_length_diff, + my_ci_fill(cs, min_str, min_end - min_str - res_length_diff, cs->min_sort_char); - cs->cset->fill(cs, max_str, max_end - max_str - res_length_diff, + my_ci_fill(cs, max_str, max_end - max_str - res_length_diff, cs->max_sort_char); /* In case of incomplete characters set the remainder to 0x00's */ @@ -1354,7 +1347,7 @@ size_t my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) { int mb_len; uint pg; - if ((mb_len= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) + if ((mb_len= my_ci_mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0) { mb_len= 1; /* Let's think a wrong sequence takes 1 dysplay cell */ b++; @@ -1381,7 +1374,7 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, const uchar *s, const uchar *e) { my_wc_t wc; - int res= cs->cset->mb_wc(cs, &wc, s, e); + int res= my_ci_mb_wc(cs, &wc, s, e); if (res <= 0 || wc > 0xFFFF) *ctype= 0; else diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 17cb51ff8cb..ccf6f12b415 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -1,5 +1,5 @@ /* Copyright (c) 2002, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1446,7 +1446,7 @@ my_cset_init_8bit(struct charset_info_st *cs, MY_CHARSET_LOADER *loader) cs->caseup_multiply= 1; cs->casedn_multiply= 1; cs->pad_char= ' '; - if (!cs->to_lower || !cs->to_upper || !cs->ctype || !cs->tab_to_uni) + if (!cs->to_lower || !cs->to_upper || !cs->m_ctype || !cs->tab_to_uni) return TRUE; return create_fromuni(cs, loader); } @@ -1496,7 +1496,7 @@ int my_mb_ctype_8bit(CHARSET_INFO *cs, int *ctype, *ctype= 0; return MY_CS_TOOSMALL; } - *ctype= cs->ctype[*s + 1]; + *ctype= cs->m_ctype[*s + 1]; return 1; } @@ -2022,14 +2022,14 @@ my_strxfrm_pad_desc_and_reverse(CHARSET_INFO *cs, if (nweights && frmend < strend && (flags & MY_STRXFRM_PAD_WITH_SPACE)) { uint fill_length= MY_MIN((uint) (strend - frmend), nweights * cs->mbminlen); - cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char); + my_ci_fill(cs, (char*) frmend, fill_length, cs->pad_char); frmend+= fill_length; } my_strxfrm_desc_and_reverse(str, frmend, flags, level); if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && frmend < strend) { size_t fill_length= strend - frmend; - cs->cset->fill(cs, (char*) frmend, fill_length, cs->pad_char); + my_ci_fill(cs, (char*) frmend, fill_length, cs->pad_char); frmend= strend; } return frmend - str; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index cbf50c638fd..a046bf352c4 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. Copyright (C) 2003 by Sathit Jittanupat <jsat66@hotmail.com,jsat66@yahoo.com> * solving bug crash with long text field string @@ -613,7 +613,7 @@ my_strnxfrm_tis620(CHARSET_INFO *cs, if ((flags & MY_STRXFRM_PAD_TO_MAXLEN) && len < dstlen0) { size_t fill_length= dstlen0 - len; - cs->cset->fill(cs, (char*) dst + len, fill_length, cs->pad_char); + my_ci_fill(cs, (char*) dst + len, fill_length, cs->pad_char); len= dstlen0; } return len; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 99a0d0f46ae..94b73335a4f 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -1,5 +1,5 @@ /* Copyright (c) 2004, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2015, MariaDB + Copyright (c) 2009, 2020, MariaDB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -31507,8 +31507,7 @@ my_uca_scanner_contraction_find(my_uca_scanner *scanner, my_wc_t *wc) flag<<= 1) { int mblen; - if ((mblen= scanner->cs->cset->mb_wc(scanner->cs, &wc[clen], - s, scanner->send)) <= 0) + if ((mblen= my_ci_mb_wc(scanner->cs, &wc[clen], s, scanner->send)) <= 0) break; beg[clen]= s= s + mblen; if (!my_uca_can_be_contraction_part(&scanner->level->contractions, @@ -32343,8 +32342,7 @@ static my_coll_lexem_num my_coll_lexem_next(MY_COLL_LEXEM *lexem) { CHARSET_INFO *cs= &my_charset_utf8mb3_general_ci; my_wc_t wc; - int nbytes= cs->cset->mb_wc(cs, &wc, - (uchar *) beg, (uchar *) lexem->end); + int nbytes= my_ci_mb_wc(cs, &wc, (uchar *) beg, (uchar *) lexem->end); if (nbytes > 0) { rc= MY_COLL_LEXEM_CHAR; @@ -33720,7 +33718,7 @@ static my_bool my_coll_init_uca(struct charset_info_st *cs, MY_CHARSET_LOADER *loader) { cs->pad_char= ' '; - cs->ctype= my_charset_utf8mb3_unicode_ci.ctype; + cs->m_ctype= my_charset_utf8mb3_unicode_ci.m_ctype; if (!cs->caseinfo) cs->caseinfo= &my_unicase_default; return create_tailoring(cs, loader); @@ -33774,7 +33772,7 @@ static void my_uca_handler_map(struct charset_info_st *cs, instead of generic. */ #define MY_FUNCTION_NAME(x) my_uca_ ## x ## _generic -#define MY_MB_WC(scanner, wc, beg, end) (scanner->cs->cset->mb_wc(scanner->cs, wc, beg, end)) +#define MY_MB_WC(scanner, wc, beg, end) (my_ci_mb_wc(scanner->cs, wc, beg, end)) #define MY_LIKE_RANGE my_like_range_generic #define MY_UCA_ASCII_OPTIMIZE 0 #define MY_UCA_COMPILE_CONTRACTIONS 1 diff --git a/strings/ctype-uca.ic b/strings/ctype-uca.ic index b7108eb7f9d..e47f1e1fd82 100644 --- a/strings/ctype-uca.ic +++ b/strings/ctype-uca.ic @@ -1,5 +1,5 @@ /* - Copyright (c) 2018 MariaDB Corporation + Copyright (c) 2018, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -671,7 +671,7 @@ MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs, */ if (flags & MY_STRXFRM_PAD_WITH_SPACE) - srclen= cs->cset->lengthsp(cs, (const char*) src, srclen); + srclen= my_ci_lengthsp(cs, (const char*) src, srclen); dst= MY_FUNCTION_NAME(strnxfrm_onelevel)(cs, &cs->uca->level[0], dst, de, nweights, src, srclen, flags); diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 71530b0a7c1..e4234a9582a 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1,5 +1,5 @@ /* Copyright (c) 2003, 2013, Oracle and/or its affiliates - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2020, MariaDB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -143,12 +143,12 @@ my_copy_incomplete_char(CHARSET_INFO *cs, Make sure we didn't pad to an incorrect character. */ - if (cs->cset->charlen(cs, (uchar *) dst, (uchar *) dst + cs->mbminlen) == + if (my_ci_charlen(cs, (uchar *) dst, (uchar *) dst + cs->mbminlen) == (int) cs->mbminlen) return MY_CHAR_COPY_OK; if (fix && - cs->cset->wc_mb(cs, '?', (uchar *) dst, (uchar *) dst + cs->mbminlen) == + my_ci_wc_mb(cs, '?', (uchar *) dst, (uchar *) dst + cs->mbminlen) == (int) cs->mbminlen) return MY_CHAR_COPY_FIXED; @@ -733,7 +733,7 @@ my_l10tostr_mb2_or_mb4(CHARSET_INFO *cs, for ( db= dst, de= dst + len ; (dst < de) && *p ; p++) { - int cnvres= cs->cset->wc_mb(cs,(my_wc_t)p[0],(uchar*) dst, (uchar*) de); + int cnvres= my_ci_wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); if (cnvres > 0) dst+= cnvres; else @@ -796,7 +796,7 @@ cnv: for ( db= dst, de= dst + len ; (dst < de) && *p ; p++) { - int cnvres= cs->cset->wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); + int cnvres= my_ci_wc_mb(cs, (my_wc_t) p[0], (uchar*) dst, (uchar*) de); if (cnvres > 0) dst+= cnvres; else @@ -1057,7 +1057,7 @@ my_fill_mb2(CHARSET_INFO *cs, char *s, size_t slen, int fill) DBUG_ASSERT((slen % 2) == 0); - buflen= cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf, + buflen= my_ci_wc_mb(cs, (my_wc_t) fill, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); @@ -1367,7 +1367,7 @@ static void my_hash_sort_utf16(CHARSET_INFO *cs, const uchar *s, size_t slen, ulong *nr1, ulong *nr2) { - size_t lengthsp= cs->cset->lengthsp(cs, (const char *) s, slen); + size_t lengthsp= my_ci_lengthsp(cs, (const char *) s, slen); my_hash_sort_utf16_nopad(cs, s, lengthsp, nr1, nr2); } @@ -1402,7 +1402,7 @@ static int my_charlen_utf16(CHARSET_INFO *cs, const uchar *str, const uchar *end) { my_wc_t wc; - return cs->cset->mb_wc(cs, &wc, str, end); + return my_ci_mb_wc(cs, &wc, str, end); } @@ -1492,7 +1492,7 @@ static void my_hash_sort_utf16_bin(CHARSET_INFO *cs, const uchar *pos, size_t len, ulong *nr1, ulong *nr2) { - size_t lengthsp= cs->cset->lengthsp(cs, (const char *) pos, len); + size_t lengthsp= my_ci_lengthsp(cs, (const char *) pos, len); my_hash_sort_utf16_nopad_bin(cs, pos, lengthsp, nr1, nr2); } @@ -1733,7 +1733,7 @@ struct charset_info_st my_charset_utf16_nopad_bin= #define MY_FUNCTION_NAME(x) my_ ## x ## _utf16le_general_ci #define DEFINE_STRNXFRM_UNICODE #define DEFINE_STRNXFRM_UNICODE_NOPAD -#define MY_MB_WC(cs, pwc, s, e) (cs->cset->mb_wc(cs, pwc, s, e)) +#define MY_MB_WC(cs, pwc, s, e) (my_ci_mb_wc(cs, pwc, s, e)) #define OPTIMIZE_ASCII 0 #define UNICASE_MAXCHAR MY_UNICASE_INFO_DEFAULT_MAXCHAR #define UNICASE_PAGE0 my_unicase_default_page00 @@ -2599,8 +2599,7 @@ void my_fill_utf32(CHARSET_INFO *cs, #ifdef DBUG_ASSERT_EXISTS buflen= #endif - cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf, - (uchar*) buf + sizeof(buf)); + my_ci_wc_mb(cs, (my_wc_t) fill, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen == 4); while (s < e) { diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index bef6d198e22..3329b6d23ef 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2009, 2020, MariaDB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -4647,7 +4647,7 @@ my_strnxfrm_unicode_full_bin_internal(CHARSET_INFO *cs, for (; dst < de && *nweights; (*nweights)--) { int res; - if ((res= cs->cset->mb_wc(cs, &wc, src, se)) <= 0) + if ((res= my_ci_mb_wc(cs, &wc, src, se)) <= 0) break; src+= res; *dst++= (uchar) (wc >> 16); @@ -5332,7 +5332,7 @@ my_fill_utf8mb3_mb(CHARSET_INFO *cs, char *str, size_t length, int fill) { char *end= str + length; char buf[10]; - char buflen= cs->cset->native_to_mb(cs, (my_wc_t) fill, (uchar*) buf, + char buflen= my_ci_native_to_mb(cs, (my_wc_t) fill, (uchar*) buf, (uchar*) buf + sizeof(buf)); DBUG_ASSERT(buflen > 0); for ( ; str + buflen <= end ; ) @@ -7026,7 +7026,7 @@ static int my_charlen_filename(CHARSET_INFO *cs, const uchar *str, const uchar *end) { my_wc_t wc; - return cs->cset->mb_wc(cs, &wc, str, end); + return my_ci_mb_wc(cs, &wc, str, end); } diff --git a/strings/ctype.c b/strings/ctype.c index 40736ed4b5a..3fbe4143da2 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2014, SkySQL Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -434,7 +434,7 @@ scan_one_character(const char *s, const char *e, my_wc_t *wc) } else /* Non-escaped character */ { - int rc= cs->cset->mb_wc(cs, wc, (uchar *) s, (uchar *) e); + int rc= my_ci_mb_wc(cs, wc, (uchar *) s, (uchar *) e); if (rc > 0) return (size_t) rc; } @@ -639,7 +639,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len) break; case _CS_CTYPEMAP: fill_uchar(i->ctype,MY_CS_CTYPE_TABLE_SIZE,attr,len); - i->cs.ctype=i->ctype; + i->cs.m_ctype=i->ctype; break; /* Special purpose commands */ @@ -867,8 +867,7 @@ my_string_metadata_get_mb(MY_STRING_METADATA *metadata, metadata->char_length++) { my_wc_t wc; - int mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) str, - (const uchar *) strend); + int mblen= my_ci_mb_wc(cs, &wc, (const uchar *) str, (const uchar *) strend); if (mblen > 0) /* Assigned character */ { if (wc > 0x7F) @@ -929,7 +928,7 @@ my_string_repertoire(CHARSET_INFO *cs, const char *str, size_t length) my_wc_t wc; int chlen; for (; - (chlen= cs->cset->mb_wc(cs, &wc, (uchar*) str, (uchar*) strend)) > 0; + (chlen= my_ci_mb_wc(cs, &wc, (uchar*) str, (uchar*) strend)) > 0; str+= chlen) { if (wc > 0x7F) @@ -1053,7 +1052,7 @@ my_wc_to_printable_generic(CHARSET_INFO *cs, my_wc_t wc, if (my_is_printable(wc)) { - int mblen= cs->cset->wc_mb(cs, wc, str, end); + int mblen= my_ci_wc_mb(cs, wc, str, end); if (mblen > 0) return mblen; } @@ -1068,7 +1067,7 @@ my_wc_to_printable_generic(CHARSET_INFO *cs, my_wc_t wc, str0= str; for (i= 0; i < length; i++) { - if (cs->cset->wc_mb(cs, tmp[i], str, end) != (int) cs->mbminlen) + if (my_ci_wc_mb(cs, tmp[i], str, end) != (int) cs->mbminlen) { DBUG_ASSERT(0); return MY_CS_ILSEQ; diff --git a/strings/json_lib.c b/strings/json_lib.c index be2aa168e35..ea9961a15d0 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -1,3 +1,18 @@ +/* Copyright (c) 2016, 2020, MariaDB Corporation. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + #include <my_global.h> #include <string.h> #include <m_ctype.h> @@ -1510,8 +1525,7 @@ int json_append_ascii(CHARSET_INFO *json_cs, while (ascii < ascii_end) { int c_len; - if ((c_len= json_cs->cset->wc_mb(json_cs, (my_wc_t) *ascii, - json, json_end)) > 0) + if ((c_len= my_ci_wc_mb(json_cs, (my_wc_t) *ascii, json, json_end)) > 0) { json+= c_len; ascii++; @@ -1537,7 +1551,7 @@ int json_unescape(CHARSET_INFO *json_cs, while (json_read_string_const_chr(&s) == 0) { int c_len; - if ((c_len= res_cs->cset->wc_mb(res_cs, s.c_next, res, res_end)) > 0) + if ((c_len= my_ci_wc_mb(res_cs, s.c_next, res, res_end)) > 0) { res+= c_len; continue; @@ -1548,7 +1562,7 @@ int json_unescape(CHARSET_INFO *json_cs, Result charset doesn't support the json's character. Let's replace it with the '?' symbol. */ - if ((c_len= res_cs->cset->wc_mb(res_cs, '?', res, res_end)) > 0) + if ((c_len= my_ci_wc_mb(res_cs, '?', res, res_end)) > 0) { res+= c_len; continue; @@ -1607,14 +1621,14 @@ int json_escape(CHARSET_INFO *str_cs, { my_wc_t c_chr; int c_len; - if ((c_len= str_cs->cset->mb_wc(str_cs, &c_chr, str, str_end)) > 0) + if ((c_len= my_ci_mb_wc(str_cs, &c_chr, str, str_end)) > 0) { enum json_esc_char_classes c_class; str+= c_len; if (c_chr >= 0x60 || (c_class= json_escape_chr_map[c_chr]) == ESC_) { - if ((c_len= json_cs->cset->wc_mb(json_cs, c_chr, json, json_end)) > 0) + if ((c_len= my_ci_wc_mb(json_cs, c_chr, json, json_end)) > 0) { json+= c_len; continue; @@ -1629,9 +1643,8 @@ int json_escape(CHARSET_INFO *str_cs, c_class= ESC_U; } - if ((c_len= json_cs->cset->wc_mb(json_cs, '\\', json, json_end)) <= 0 || - (c_len= json_cs->cset->wc_mb(json_cs, - (c_class == ESC_BS) ? c_chr : c_class, + if ((c_len= my_ci_wc_mb(json_cs, '\\', json, json_end)) <= 0 || + (c_len= my_ci_wc_mb(json_cs, (c_class == ESC_BS) ? c_chr : c_class, json+= c_len, json_end)) <= 0) { /* JSON buffer is depleted. */ diff --git a/strings/my_strchr.c b/strings/my_strchr.c index 6b1564c7ee1..323cbd0a37f 100644 --- a/strings/my_strchr.c +++ b/strings/my_strchr.c @@ -1,5 +1,5 @@ /* Copyright (c) 2005, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +38,8 @@ const char *acc_end= (ACC) + (LEN); \ for (ptr_str= (STR) ; ptr_str < (END) ; ptr_str+= mbl) \ { \ - mbl= my_charlen_fix((CS), ptr_str, (END)); \ + mbl= my_ci_charlen_fix((CS), (const uchar *) ptr_str, \ + (const uchar *) (END)); \ if (mbl < 2) \ { \ DBUG_ASSERT(mbl == 1); \ diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 5a161612bc5..add0bd422e8 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2009-2011, Monty Program Ab + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -167,7 +167,7 @@ static char *backtick_string(CHARSET_INFO *cs, char *to, const char *end, for ( ; par < par_end; par+= char_len) { uchar c= *(uchar *) par; - char_len= my_charlen_fix(cs, par, par_end); + char_len= my_ci_charlen_fix(cs, (const uchar *) par, (const uchar *) par_end); if (char_len == 1 && c == (uchar) quote_char ) { if (start + 1 >= end) diff --git a/strings/strcoll.ic b/strings/strcoll.ic index e7d614ebdf5..d30535de0d5 100644 --- a/strings/strcoll.ic +++ b/strings/strcoll.ic @@ -1,5 +1,6 @@ /* Copyright (c) 2015, MariaDB Foundation + Copyright (c) 2015, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -156,7 +157,7 @@ bad: Compare two strings according to the collation, without handling the PAD SPACE property. - Note, cs->coll->strnncoll() is usually used to compare identifiers. + Note, strnncoll() is usually used to compare identifiers. Perhaps we should eventually (in 10.2?) create a new collation my_charset_utf8mb3_general_ci_no_pad and have only one comparison function in MY_COLLATION_HANDLER. @@ -307,11 +308,11 @@ MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs, for (; dst < de && src < se && nweights; nweights--) { - if (my_charlen(cs, (const char *) src, (const char *) se) > 1) + if (my_ci_charlen(cs, src, se) > 1) { /* Note, it is safe not to check (src < se) - in the code below, because my_charlen() would + in the code below, because my_ci_charlen() would not return 2 if src was too short */ uint16 e= WEIGHT_MB2_FRM(src[0], src[1]); |