@@ -78,7 +78,7 @@ static uint get_collation_number(const char *name)
7878 cs < all_charsets + array_elements (all_charsets );
7979 cs ++ )
8080 {
81- if (cs -> name && !strcmp (cs -> name , name ))
81+ if (cs -> coll_name . str && !strcmp (cs -> coll_name . str , name ))
8282 return cs -> number ;
8383 }
8484 return 0 ;
@@ -93,8 +93,8 @@ get_charset_number_internal(const char *charset_name, uint cs_flags)
9393 cs < all_charsets + array_elements (all_charsets );
9494 cs ++ )
9595 {
96- if (cs -> csname && (cs -> state & cs_flags ) &&
97- !strcmp (cs -> csname , charset_name ))
96+ if (cs -> cs_name . str && (cs -> state & cs_flags ) &&
97+ !strcmp (cs -> cs_name . str , charset_name ))
9898 return cs -> number ;
9999 }
100100 return 0 ;
@@ -114,17 +114,23 @@ static void simple_cs_copy_data(struct charset_info_st *to, CHARSET_INFO *from)
114114 to -> number = from -> number ? from -> number : to -> number ;
115115 to -> state |= from -> state ;
116116
117- if (from -> csname )
118- to -> csname = strdup (from -> csname );
117+ if (from -> cs_name .str )
118+ {
119+ to -> cs_name .str = strndup (from -> cs_name .str , from -> cs_name .length );
120+ to -> cs_name .length = from -> cs_name .length ;
121+ }
119122
120- if (from -> name )
121- to -> name = strdup (from -> name );
123+ if (from -> coll_name .str )
124+ {
125+ to -> coll_name .str = strndup (from -> coll_name .str , from -> coll_name .length );
126+ to -> coll_name .length = from -> coll_name .length ;
127+ }
122128
123129 if (from -> tailoring )
124130 to -> tailoring = strdup (from -> tailoring );
125131
126- if (from -> ctype )
127- to -> ctype = (uchar * ) mdup ((char * ) from -> ctype , MY_CS_CTYPE_TABLE_SIZE );
132+ if (from -> m_ctype )
133+ to -> m_ctype = (uchar * ) mdup ((char * ) from -> m_ctype , MY_CS_CTYPE_TABLE_SIZE );
128134 if (from -> to_lower )
129135 to -> to_lower = (uchar * ) mdup ((char * ) from -> to_lower , MY_CS_TO_LOWER_TABLE_SIZE );
130136 if (from -> to_upper )
@@ -160,9 +166,9 @@ static void inherit_charset_data(struct charset_info_st *cs,
160166 CHARSET_INFO * refcs )
161167{
162168 cs -> state |= (refcs -> state & (MY_CS_PUREASCII |MY_CS_NONASCII ));
163- if (refcs -> ctype && cs -> ctype &&
164- !memcmp (cs -> ctype , refcs -> ctype , MY_CS_CTYPE_TABLE_SIZE ))
165- cs -> ctype = NULL ;
169+ if (refcs -> m_ctype && cs -> m_ctype &&
170+ !memcmp (cs -> m_ctype , refcs -> m_ctype , MY_CS_CTYPE_TABLE_SIZE ))
171+ cs -> m_ctype = NULL ;
166172 if (refcs -> to_lower && cs -> to_lower &&
167173 !memcmp (cs -> to_lower , refcs -> to_lower , MY_CS_TO_LOWER_TABLE_SIZE ))
168174 cs -> to_lower = NULL ;
@@ -179,7 +185,7 @@ static void inherit_charset_data(struct charset_info_st *cs,
179185static CHARSET_INFO * find_charset_data_inheritance_source (CHARSET_INFO * cs )
180186{
181187 CHARSET_INFO * refcs ;
182- uint refid = get_charset_number_internal (cs -> csname , MY_CS_PRIMARY );
188+ uint refid = get_charset_number_internal (cs -> cs_name . str , MY_CS_PRIMARY );
183189 return refid && refid != cs -> number &&
184190 (refcs = & all_charsets [refid ]) &&
185191 (refcs -> state & MY_CS_LOADED ) ? refcs : NULL ;
@@ -197,16 +203,16 @@ static CHARSET_INFO *find_charset_data_inheritance_source(CHARSET_INFO *cs)
197203*/
198204static my_bool simple_cs_is_full (CHARSET_INFO * cs )
199205{
200- return ((cs -> csname && cs -> tab_to_uni && cs -> ctype && cs -> to_upper &&
206+ return ((cs -> cs_name . str && cs -> tab_to_uni && cs -> m_ctype && cs -> to_upper &&
201207 cs -> to_lower ) &&
202- (cs -> number && cs -> name &&
208+ (cs -> number && cs -> coll_name . str &&
203209 (cs -> sort_order || cs -> tailoring || (cs -> state & MY_CS_BINSORT ))));
204210}
205211
206212static int add_collation (struct charset_info_st * cs )
207213{
208- if (cs -> name &&
209- (cs -> number || (cs -> number = get_collation_number (cs -> name ))))
214+ if (cs -> coll_name . str &&
215+ (cs -> number || (cs -> number = get_collation_number (cs -> coll_name . str ))))
210216 {
211217 if (!(all_charsets [cs -> number ].state & MY_CS_COMPILED ))
212218 {
@@ -215,7 +221,8 @@ static int add_collation(struct charset_info_st *cs)
215221 }
216222
217223 cs -> number = 0 ;
218- cs -> name = NULL ;
224+ cs -> coll_name .str = 0 ;
225+ cs -> coll_name .length = 0 ;
219226 cs -> tailoring = NULL ;
220227 cs -> state = 0 ;
221228 cs -> sort_order = NULL ;
@@ -276,16 +283,16 @@ static int my_read_charset_file(const char *filename)
276283
277284void print_arrays (FILE * f , CHARSET_INFO * cs )
278285{
279- if (cs -> ctype )
280- print_array (f , cs -> name , "ctype" , cs -> ctype , MY_CS_CTYPE_TABLE_SIZE );
286+ if (cs -> m_ctype )
287+ print_array (f , cs -> coll_name . str , "ctype" , cs -> m_ctype , MY_CS_CTYPE_TABLE_SIZE );
281288 if (cs -> to_lower )
282- print_array (f , cs -> name , "to_lower" , cs -> to_lower , MY_CS_TO_LOWER_TABLE_SIZE );
289+ print_array (f , cs -> coll_name . str , "to_lower" , cs -> to_lower , MY_CS_TO_LOWER_TABLE_SIZE );
283290 if (cs -> to_upper )
284- print_array (f , cs -> name , "to_upper" , cs -> to_upper , MY_CS_TO_UPPER_TABLE_SIZE );
291+ print_array (f , cs -> coll_name . str , "to_upper" , cs -> to_upper , MY_CS_TO_UPPER_TABLE_SIZE );
285292 if (cs -> sort_order )
286- print_array (f , cs -> name , "sort_order" , cs -> sort_order , MY_CS_SORT_ORDER_TABLE_SIZE );
293+ print_array (f , cs -> coll_name . str , "sort_order" , cs -> sort_order , MY_CS_SORT_ORDER_TABLE_SIZE );
287294 if (cs -> tab_to_uni )
288- print_array16 (f , cs -> name , "to_uni" , cs -> tab_to_uni , MY_CS_TO_UNI_TABLE_SIZE );
295+ print_array16 (f , cs -> coll_name . str , "to_uni" , cs -> tab_to_uni , MY_CS_TO_UNI_TABLE_SIZE );
289296}
290297
291298
@@ -332,7 +339,7 @@ print_array_ref(FILE *f,
332339 CHARSET_INFO * cs = array0 ? cs0 : array1 ? cs1 : NULL ;
333340 if (cs )
334341 fprintf (f ," %s_%s, /* %s */\n" ,
335- name , cs -> name , name );
342+ name , cs -> coll_name . str , name );
336343 else
337344 fprintf (f ," NULL, /* %s */\n" , name );
338345}
@@ -344,6 +351,12 @@ static const char *nopad_infix(CHARSET_INFO *cs)
344351}
345352
346353
354+ void fprintf_lex_str_member (FILE * f , const LEX_CSTRING str , const char * comment )
355+ {
356+ fprintf (f ," { STRING_WITH_LEN(\"%s\") }, %s\n" , str .str , comment );
357+ }
358+
359+
347360void dispcset (FILE * f ,CHARSET_INFO * cs )
348361{
349362 fprintf (f ,"{\n" );
@@ -356,23 +369,23 @@ void dispcset(FILE *f,CHARSET_INFO *cs)
356369 cs -> state & MY_CS_NONASCII ? "|MY_CS_NONASCII" : "" ,
357370 cs -> state & MY_CS_NOPAD ? "|MY_CS_NOPAD" : "" );
358371
359- if (cs -> name )
372+ if (cs -> coll_name . str )
360373 {
361374 CHARSET_INFO * srccs = inheritance_source (cs -> number );
362- fprintf (f ," \"%s\" , /* cset name */\n" , cs -> csname );
363- fprintf (f ," \"%s\", /* coll name */\n" , cs -> name );
375+ fprintf_lex_str_member (f , cs -> cs_name , " /* cset name */" );
376+ fprintf_lex_str_member (f , cs -> coll_name , " /* coll name */" );
364377 fprintf (f ," \"\", /* comment */\n" );
365378 if (cs -> tailoring )
366379 fprintf (f , " \"%s\", /* tailoring */\n" , cs -> tailoring );
367380 else
368381 fprintf (f ," NULL, /* tailoring */\n" );
369382
370- print_array_ref (f , cs , cs -> ctype , srccs , srccs -> ctype , "ctype" );
383+ print_array_ref (f , cs , cs -> m_ctype , srccs , srccs -> m_ctype , "ctype" );
371384 print_array_ref (f , cs , cs -> to_lower , srccs , srccs -> to_lower , "to_lower" );
372385 print_array_ref (f , cs , cs -> to_upper , srccs , srccs -> to_upper , "to_upper" );
373386
374387 if (cs -> sort_order )
375- fprintf (f ," sort_order_%s, /* sort_order */\n" ,cs -> name );
388+ fprintf (f ," sort_order_%s, /* sort_order */\n" , cs -> coll_name . str );
376389 else
377390 fprintf (f ," NULL, /* sort_order */\n" );
378391
@@ -382,8 +395,8 @@ void dispcset(FILE *f,CHARSET_INFO *cs)
382395 }
383396 else
384397 {
385- fprintf (f ," NULL, /* cset name */\n" );
386- fprintf (f ," NULL, /* coll name */\n" );
398+ fprintf (f ," { NULL,0}, /* cset name */\n" );
399+ fprintf (f ," { NULL,0}, /* coll name */\n" );
387400 fprintf (f ," NULL, /* comment */\n" );
388401 fprintf (f ," NULL, /* tailoging */\n" );
389402 fprintf (f ," NULL, /* ctype */\n" );
@@ -422,7 +435,7 @@ fprint_copyright(FILE *file)
422435 fprintf (file ,
423436"/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.\n"
424437" Copyright (c) 2000, 2011, Oracle and/or its affiliates.\n"
425- " Copyright 2008-2016 MariaDB Corporation\n"
438+ " Copyright 2008-2023 MariaDB Corporation\n"
426439"\n"
427440" This program is free software; you can redistribute it and/or modify\n"
428441" 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)))
466479 {
467480 if (cs -> number && !(cs -> state & MY_CS_COMPILED ))
468481 {
469- if ( (!simple_cs_is_full (cs )) && (cs -> csname ))
482+ if ( (!simple_cs_is_full (cs )) && (cs -> cs_name . str ))
470483 {
471- sprintf (filename ,"%s/%s.xml" ,argv [1 ],cs -> csname );
484+ sprintf (filename ,"%s/%s.xml" ,argv [1 ], cs -> cs_name . str );
472485 my_read_charset_file (filename );
473486 }
474487 cs -> state |= MY_CS_LOADED ;
@@ -502,7 +515,7 @@ main(int argc, char **argv __attribute__((unused)))
502515 refids [cs -> number ]= refcs -> number ;
503516 inherit_charset_data (cs , refcs );
504517 }
505- fprintf (f ,"#ifdef HAVE_CHARSET_%s\n" ,cs -> csname );
518+ fprintf (f ,"#ifdef HAVE_CHARSET_%s\n" , cs -> cs_name . str );
506519 print_arrays (f , cs );
507520 fprintf (f ,"#endif\n" );
508521 fprintf (f ,"\n" );
@@ -516,7 +529,7 @@ main(int argc, char **argv __attribute__((unused)))
516529 {
517530 if (cs -> state & MY_CS_LOADED )
518531 {
519- fprintf (f ,"#ifdef HAVE_CHARSET_%s\n" ,cs -> csname );
532+ fprintf (f ,"#ifdef HAVE_CHARSET_%s\n" , cs -> cs_name . str );
520533 dispcset (f ,cs );
521534 fprintf (f ,",\n" );
522535 fprintf (f ,"#endif\n" );
0 commit comments