1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-21581 Helper functions and methods for CHARSET_INFO

This commit is contained in:
Alexander Barkov
2020-01-26 20:27:13 +04:00
parent dd68ba74f3
commit f1e13fdc8d
118 changed files with 1416 additions and 1025 deletions

View File

@@ -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. */