diff options
Diffstat (limited to 'strings/conf_to_src.c')
-rw-r--r-- | strings/conf_to_src.c | 87 |
1 files changed, 50 insertions, 37 deletions
diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index b4999ef7278..22b9cda058a 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -78,7 +78,7 @@ static uint get_collation_number(const char *name) cs < all_charsets + array_elements(all_charsets); cs++) { - if (cs->name && !strcmp(cs->name, name)) + if (cs->coll_name.str && !strcmp(cs->coll_name.str, name)) return cs->number; } return 0; @@ -93,8 +93,8 @@ get_charset_number_internal(const char *charset_name, uint cs_flags) cs < all_charsets + array_elements(all_charsets); cs++) { - if (cs->csname && (cs->state & cs_flags) && - !strcmp(cs->csname, charset_name)) + if (cs->cs_name.str && (cs->state & cs_flags) && + !strcmp(cs->cs_name.str, charset_name)) return cs->number; } return 0; @@ -114,17 +114,23 @@ static void simple_cs_copy_data(struct charset_info_st *to, CHARSET_INFO *from) to->number= from->number ? from->number : to->number; to->state|= from->state; - if (from->csname) - to->csname= strdup(from->csname); + if (from->cs_name.str) + { + to->cs_name.str= strndup(from->cs_name.str, from->cs_name.length); + to->cs_name.length= from->cs_name.length; + } - if (from->name) - to->name= strdup(from->name); + if (from->coll_name.str) + { + to->coll_name.str= strndup(from->coll_name.str, from->coll_name.length); + to->coll_name.length= from->coll_name.length; + } if (from->tailoring) to->tailoring= strdup(from->tailoring); - if (from->ctype) - to->ctype= (uchar*) mdup((char*) from->ctype, MY_CS_CTYPE_TABLE_SIZE); + if (from->m_ctype) + to->m_ctype= (uchar*) mdup((char*) from->m_ctype, MY_CS_CTYPE_TABLE_SIZE); if (from->to_lower) to->to_lower= (uchar*) mdup((char*) from->to_lower, MY_CS_TO_LOWER_TABLE_SIZE); if (from->to_upper) @@ -160,9 +166,9 @@ static void inherit_charset_data(struct charset_info_st *cs, CHARSET_INFO *refcs) { cs->state|= (refcs->state & (MY_CS_PUREASCII|MY_CS_NONASCII)); - if (refcs->ctype && cs->ctype && - !memcmp(cs->ctype, refcs->ctype, MY_CS_CTYPE_TABLE_SIZE)) - cs->ctype= NULL; + if (refcs->m_ctype && cs->m_ctype && + !memcmp(cs->m_ctype, refcs->m_ctype, MY_CS_CTYPE_TABLE_SIZE)) + cs->m_ctype= NULL; if (refcs->to_lower && cs->to_lower && !memcmp(cs->to_lower, refcs->to_lower, MY_CS_TO_LOWER_TABLE_SIZE)) cs->to_lower= NULL; @@ -179,7 +185,7 @@ static void inherit_charset_data(struct charset_info_st *cs, static CHARSET_INFO *find_charset_data_inheritance_source(CHARSET_INFO *cs) { CHARSET_INFO *refcs; - uint refid= get_charset_number_internal(cs->csname, MY_CS_PRIMARY); + uint refid= get_charset_number_internal(cs->cs_name.str, MY_CS_PRIMARY); return refid && refid != cs->number && (refcs= &all_charsets[refid]) && (refcs->state & MY_CS_LOADED) ? refcs : NULL; @@ -197,16 +203,16 @@ static CHARSET_INFO *find_charset_data_inheritance_source(CHARSET_INFO *cs) */ static my_bool simple_cs_is_full(CHARSET_INFO *cs) { - return ((cs->csname && cs->tab_to_uni && cs->ctype && cs->to_upper && + return ((cs->cs_name.str && cs->tab_to_uni && cs->m_ctype && cs->to_upper && cs->to_lower) && - (cs->number && cs->name && + (cs->number && cs->coll_name.str && (cs->sort_order || cs->tailoring || (cs->state & MY_CS_BINSORT)))); } static int add_collation(struct charset_info_st *cs) { - if (cs->name && - (cs->number || (cs->number= get_collation_number(cs->name)))) + if (cs->coll_name.str && + (cs->number || (cs->number= get_collation_number(cs->coll_name.str)))) { if (!(all_charsets[cs->number].state & MY_CS_COMPILED)) { @@ -215,7 +221,8 @@ static int add_collation(struct charset_info_st *cs) } cs->number= 0; - cs->name= NULL; + cs->coll_name.str= 0; + cs->coll_name.length= 0; cs->tailoring= NULL; cs->state= 0; cs->sort_order= NULL; @@ -276,16 +283,16 @@ static int my_read_charset_file(const char *filename) void print_arrays(FILE *f, CHARSET_INFO *cs) { - if (cs->ctype) - print_array(f, cs->name, "ctype", cs->ctype, MY_CS_CTYPE_TABLE_SIZE); + if (cs->m_ctype) + print_array(f, cs->coll_name.str, "ctype", cs->m_ctype, MY_CS_CTYPE_TABLE_SIZE); if (cs->to_lower) - print_array(f, cs->name, "to_lower", cs->to_lower, MY_CS_TO_LOWER_TABLE_SIZE); + print_array(f, cs->coll_name.str, "to_lower", cs->to_lower, MY_CS_TO_LOWER_TABLE_SIZE); if (cs->to_upper) - print_array(f, cs->name, "to_upper", cs->to_upper, MY_CS_TO_UPPER_TABLE_SIZE); + print_array(f, cs->coll_name.str, "to_upper", cs->to_upper, MY_CS_TO_UPPER_TABLE_SIZE); if (cs->sort_order) - print_array(f, cs->name, "sort_order", cs->sort_order, MY_CS_SORT_ORDER_TABLE_SIZE); + print_array(f, cs->coll_name.str, "sort_order", cs->sort_order, MY_CS_SORT_ORDER_TABLE_SIZE); if (cs->tab_to_uni) - print_array16(f, cs->name, "to_uni", cs->tab_to_uni, MY_CS_TO_UNI_TABLE_SIZE); + print_array16(f, cs->coll_name.str, "to_uni", cs->tab_to_uni, MY_CS_TO_UNI_TABLE_SIZE); } @@ -332,7 +339,7 @@ print_array_ref(FILE *f, CHARSET_INFO *cs= array0 ? cs0 : array1 ? cs1 : NULL; if (cs) fprintf(f," %s_%s, /* %s */\n", - name, cs->name, name); + name, cs->coll_name.str, name); else fprintf(f," NULL, /* %s */\n", name); } @@ -344,6 +351,12 @@ static const char *nopad_infix(CHARSET_INFO *cs) } +void fprintf_lex_str_member(FILE *f, const LEX_CSTRING str, const char *comment) +{ + fprintf(f," { STRING_WITH_LEN(\"%s\") }, %s\n", str.str, comment); +} + + void dispcset(FILE *f,CHARSET_INFO *cs) { fprintf(f,"{\n"); @@ -356,23 +369,23 @@ void dispcset(FILE *f,CHARSET_INFO *cs) cs->state & MY_CS_NONASCII ? "|MY_CS_NONASCII" : "", cs->state & MY_CS_NOPAD ? "|MY_CS_NOPAD" : ""); - if (cs->name) + if (cs->coll_name.str) { CHARSET_INFO *srccs= inheritance_source(cs->number); - fprintf(f," \"%s\", /* cset name */\n",cs->csname); - fprintf(f," \"%s\", /* coll name */\n",cs->name); + fprintf_lex_str_member(f, cs->cs_name, "/* cset name */"); + fprintf_lex_str_member(f, cs->coll_name, "/* coll name */"); fprintf(f," \"\", /* comment */\n"); if (cs->tailoring) fprintf(f, " \"%s\", /* tailoring */\n", cs->tailoring); else fprintf(f," NULL, /* tailoring */\n"); - print_array_ref(f, cs, cs->ctype, srccs, srccs->ctype, "ctype"); + print_array_ref(f, cs, cs->m_ctype, srccs, srccs->m_ctype, "ctype"); print_array_ref(f, cs, cs->to_lower, srccs, srccs->to_lower, "to_lower"); print_array_ref(f, cs, cs->to_upper, srccs, srccs->to_upper, "to_upper"); if (cs->sort_order) - fprintf(f," sort_order_%s, /* sort_order */\n",cs->name); + fprintf(f," sort_order_%s, /* sort_order */\n", cs->coll_name.str); else fprintf(f," NULL, /* sort_order */\n"); @@ -382,8 +395,8 @@ void dispcset(FILE *f,CHARSET_INFO *cs) } else { - fprintf(f," NULL, /* cset name */\n"); - fprintf(f," NULL, /* coll name */\n"); + fprintf(f," {NULL,0}, /* cset name */\n"); + fprintf(f," {NULL,0}, /* coll name */\n"); fprintf(f," NULL, /* comment */\n"); fprintf(f," NULL, /* tailoging */\n"); fprintf(f," NULL, /* ctype */\n"); @@ -422,7 +435,7 @@ fprint_copyright(FILE *file) fprintf(file, "/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.\n" " Copyright (c) 2000, 2011, Oracle and/or its affiliates.\n" -" Copyright 2008-2016 MariaDB Corporation\n" +" Copyright 2008-2023 MariaDB Corporation\n" "\n" " This program is free software; you can redistribute it and/or modify\n" " it under the terms of the GNU General Public License as published by\n" @@ -466,9 +479,9 @@ main(int argc, char **argv __attribute__((unused))) { if (cs->number && !(cs->state & MY_CS_COMPILED)) { - if ( (!simple_cs_is_full(cs)) && (cs->csname)) + if ( (!simple_cs_is_full(cs)) && (cs->cs_name.str)) { - sprintf(filename,"%s/%s.xml",argv[1],cs->csname); + sprintf(filename,"%s/%s.xml",argv[1], cs->cs_name.str); my_read_charset_file(filename); } cs->state|= MY_CS_LOADED; @@ -502,7 +515,7 @@ main(int argc, char **argv __attribute__((unused))) refids[cs->number]= refcs->number; inherit_charset_data(cs, refcs); } - fprintf(f,"#ifdef HAVE_CHARSET_%s\n",cs->csname); + fprintf(f,"#ifdef HAVE_CHARSET_%s\n", cs->cs_name.str); print_arrays(f, cs); fprintf(f,"#endif\n"); fprintf(f,"\n"); @@ -516,7 +529,7 @@ main(int argc, char **argv __attribute__((unused))) { if (cs->state & MY_CS_LOADED) { - fprintf(f,"#ifdef HAVE_CHARSET_%s\n",cs->csname); + fprintf(f,"#ifdef HAVE_CHARSET_%s\n", cs->cs_name.str); dispcset(f,cs); fprintf(f,",\n"); fprintf(f,"#endif\n"); |