diff options
author | Michael Widenius <monty@askmonty.org> | 2010-01-06 21:20:16 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2010-01-06 21:20:16 +0200 |
commit | f83113df07d6ef8e8a6d1db8f6dc3bb90fb0652a (patch) | |
tree | dd61d137ac567ebd15d245f0d24a12e763f78545 /mysys/charset.c | |
parent | 43ddd3b89ffea24147332f95fb7c8929d2873e63 (diff) | |
download | mariadb-git-f83113df07d6ef8e8a6d1db8f6dc3bb90fb0652a.tar.gz |
Applied Antony T Curtis patch for declaring many CHARSET objects as const
Removed compiler warnings
extra/libevent/epoll.c:
Removed compiler warnings
extra/libevent/evbuffer.c:
Removed compiler warnings
extra/libevent/event.c:
Removed compiler warnings
extra/libevent/select.c:
Removed compiler warnings
extra/libevent/signal.c:
Removed compiler warnings
include/m_ctype.h:
Define CHARSET_INFO, MY_CHARSET_HANDLER, MY_COLLATION_HANDLER, MY_UNICASE_INFO, MY_UNI_CTYPE and MY_UNI_IDX as const structures.
Declare that pointers point to const data
include/m_string.h:
Declare that pointers point to const data
include/my_sys.h:
Redefine variables and function prototypes
include/mysql.h:
Declare charset as const
include/mysql.h.pp:
Declare charset as const
include/mysql/plugin.h:
Declare charset as const
include/mysql/plugin.h.pp:
Declare charset as const
mysys/charset-def.c:
Charset can't be of type CHARSET_INFO as they are changed when they are initialized.
mysys/charset.c:
Functions that change CHARSET_INFO must use 'struct charset_info_st'
Add temporary variables to not have to change all_charsets[] (Which now is const)
sql-common/client.c:
Added cast to const
sql/item_cmpfunc.h:
Added cast to avoid compiler error.
sql/sql_class.cc:
Added cast to const
sql/sql_lex.cc:
Added cast to const
storage/maria/ma_ft_boolean_search.c:
Added cast to avoid compiler error.
storage/maria/ma_ft_parser.c:
Added cast to avoid compiler error.
storage/maria/ma_search.c:
Added cast to const
storage/myisam/ft_boolean_search.c:
Added cast to avoid compiler error
storage/myisam/ft_parser.c:
Added cast to avoid compiler error
storage/myisam/mi_search.c:
Added cast to const
storage/pbxt/src/datadic_xt.cc:
Added cast to const
storage/pbxt/src/ha_pbxt.cc:
Added cast to const
Removed compiler warning by changing prototype of XTThreadPtr()
storage/pbxt/src/myxt_xt.h:
Character sets should be const
storage/pbxt/src/xt_defs.h:
Character sets should be const
storage/xtradb/btr/btr0cur.c:
Removed compiler warning
strings/conf_to_src.c:
Added const
Functions that change CHARSET_INFO must use 'struct charset_info_st'
strings/ctype-big5.c:
Made arrays const
strings/ctype-bin.c:
Made arrays const
strings/ctype-cp932.c:
Made arrays const
strings/ctype-czech.c:
Made arrays const
strings/ctype-euc_kr.c:
Made arrays const
strings/ctype-eucjpms.c:
Made arrays const
strings/ctype-extra.c:
Made arrays const
strings/ctype-gb2312.c:
Made arrays const
strings/ctype-gbk.c:
Made arrays const
strings/ctype-latin1.c:
Made arrays const
strings/ctype-mb.c:
Made arrays const
strings/ctype-simple.c:
Made arrays const
strings/ctype-sjis.c:
Made arrays const
strings/ctype-tis620.c:
Made arrays const
strings/ctype-uca.c:
Made arrays const
strings/ctype-ucs2.c:
Made arrays const
strings/ctype-ujis.c:
Made arrays const
strings/ctype-utf8.c:
Made arrays const
strings/ctype-win1250ch.c:
Made arrays const
strings/ctype.c:
Made arrays const
Added cast to const
Functions that change CHARSET_INFO must use 'struct charset_info_st'
strings/int2str.c:
Added cast to const
Diffstat (limited to 'mysys/charset.c')
-rw-r--r-- | mysys/charset.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index 84723a88a96..aaf071fe0d2 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -53,21 +53,18 @@ get_collation_number_internal(const char *name) } -static my_bool init_state_maps(CHARSET_INFO *cs) +static my_bool init_state_maps(struct charset_info_st *cs) { uint i; uchar *state_map; uchar *ident_map; - if (!(cs->state_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) + if (!(cs->state_map= state_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) return 1; - if (!(cs->ident_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) + if (!(cs->ident_map= ident_map= (uchar*) my_once_alloc(256, MYF(MY_WME)))) return 1; - state_map= cs->state_map; - ident_map= cs->ident_map; - /* Fill state_map with states to get a faster parser */ for (i=0; i < 256 ; i++) { @@ -118,7 +115,7 @@ static my_bool init_state_maps(CHARSET_INFO *cs) } -static void simple_cs_init_functions(CHARSET_INFO *cs) +static void simple_cs_init_functions(struct charset_info_st *cs) { if (cs->state & MY_CS_BINSORT) cs->coll= &my_collation_8bit_bin_handler; @@ -130,7 +127,7 @@ static void simple_cs_init_functions(CHARSET_INFO *cs) -static int cs_copy_data(CHARSET_INFO *to, CHARSET_INFO *from) +static int cs_copy_data(struct charset_info_st *to, CHARSET_INFO *from) { to->number= from->number ? from->number : to->number; @@ -203,7 +200,7 @@ static my_bool simple_cs_is_full(CHARSET_INFO *cs) static void -copy_uca_collation(CHARSET_INFO *to, CHARSET_INFO *from) +copy_uca_collation(struct charset_info_st *to, CHARSET_INFO *from) { to->cset= from->cset; to->coll= from->coll; @@ -217,17 +214,18 @@ copy_uca_collation(CHARSET_INFO *to, CHARSET_INFO *from) } -static int add_collation(CHARSET_INFO *cs) +static int add_collation(struct charset_info_st *cs) { if (cs->name && (cs->number || (cs->number=get_collation_number_internal(cs->name)))) { - if (!all_charsets[cs->number]) + struct charset_info_st *newcs; + if (!(newcs= (struct charset_info_st*) all_charsets[cs->number])) { - if (!(all_charsets[cs->number]= - (CHARSET_INFO*) my_once_alloc(sizeof(CHARSET_INFO),MYF(0)))) + if (!(all_charsets[cs->number]= newcs= + (struct charset_info_st*) my_once_alloc(sizeof(CHARSET_INFO),MYF(0)))) return MY_XML_ERROR; - bzero((void*)all_charsets[cs->number],sizeof(CHARSET_INFO)); + bzero(newcs,sizeof(CHARSET_INFO)); } if (cs->primary_number == cs->number) @@ -236,12 +234,11 @@ static int add_collation(CHARSET_INFO *cs) if (cs->binary_number == cs->number) cs->state |= MY_CS_BINSORT; - all_charsets[cs->number]->state|= cs->state; + newcs->state|= cs->state; - if (!(all_charsets[cs->number]->state & MY_CS_COMPILED)) + if (!(newcs->state & MY_CS_COMPILED)) { - CHARSET_INFO *newcs= all_charsets[cs->number]; - if (cs_copy_data(all_charsets[cs->number],cs)) + if (cs_copy_data(newcs,cs)) return MY_XML_ERROR; if (!strcmp(cs->csname,"ucs2") ) @@ -259,15 +256,15 @@ static int add_collation(CHARSET_INFO *cs) } else { - uchar *sort_order= all_charsets[cs->number]->sort_order; - simple_cs_init_functions(all_charsets[cs->number]); + const uchar *sort_order= newcs->sort_order; + simple_cs_init_functions(newcs); newcs->mbminlen= 1; newcs->mbmaxlen= 1; - if (simple_cs_is_full(all_charsets[cs->number])) + if (simple_cs_is_full(newcs)) { - all_charsets[cs->number]->state |= MY_CS_LOADED; + newcs->state |= MY_CS_LOADED; } - all_charsets[cs->number]->state|= MY_CS_AVAILABLE; + newcs->state|= MY_CS_AVAILABLE; /* Check if case sensitive sort order: A < a < B. @@ -277,12 +274,12 @@ static int add_collation(CHARSET_INFO *cs) */ if (sort_order && sort_order['A'] < sort_order['a'] && sort_order['a'] < sort_order['B']) - all_charsets[cs->number]->state|= MY_CS_CSSORT; + newcs->state|= MY_CS_CSSORT; - if (my_charset_is_8bit_pure_ascii(all_charsets[cs->number])) - all_charsets[cs->number]->state|= MY_CS_PUREASCII; + if (my_charset_is_8bit_pure_ascii(newcs)) + newcs->state|= MY_CS_PUREASCII; if (!my_charset_is_ascii_compatible(cs)) - all_charsets[cs->number]->state|= MY_CS_NONASCII; + newcs->state|= MY_CS_NONASCII; } } else @@ -296,16 +293,15 @@ static int add_collation(CHARSET_INFO *cs) If a character set was compiled, this information will get lost and overwritten in add_compiled_collation(). */ - CHARSET_INFO *dst= all_charsets[cs->number]; - dst->number= cs->number; + newcs->number= cs->number; if (cs->comment) - if (!(dst->comment= my_once_strdup(cs->comment,MYF(MY_WME)))) + if (!(newcs->comment= my_once_strdup(cs->comment,MYF(MY_WME)))) return MY_XML_ERROR; if (cs->csname) - if (!(dst->csname= my_once_strdup(cs->csname,MYF(MY_WME)))) + if (!(newcs->csname= my_once_strdup(cs->csname,MYF(MY_WME)))) return MY_XML_ERROR; if (cs->name) - if (!(dst->name= my_once_strdup(cs->name,MYF(MY_WME)))) + if (!(newcs->name= my_once_strdup(cs->name,MYF(MY_WME)))) return MY_XML_ERROR; } cs->number= 0; @@ -390,7 +386,7 @@ char *get_charsets_dir(char *buf) CHARSET_INFO *all_charsets[256]={NULL}; CHARSET_INFO *default_charset_info = &my_charset_latin1; -void add_compiled_collation(CHARSET_INFO *cs) +void add_compiled_collation(struct charset_info_st *cs) { all_charsets[cs->number]= cs; cs->state|= MY_CS_AVAILABLE; @@ -416,7 +412,7 @@ static my_bool init_available_charsets(myf myflags) */ if (!charset_initialized) { - CHARSET_INFO **cs; + struct charset_info_st **cs; /* To make things thread safe we are not allowing other threads to interfere while we may changing the cs_info_table @@ -428,8 +424,9 @@ static my_bool init_available_charsets(myf myflags) init_compiled_charsets(myflags); /* Copy compiled charsets */ - for (cs=all_charsets; - cs < all_charsets+array_elements(all_charsets)-1 ; + for (cs= (struct charset_info_st**) all_charsets; + cs < (struct charset_info_st**) all_charsets + + array_elements(all_charsets)-1 ; cs++) { if (*cs) @@ -496,9 +493,9 @@ const char *get_charset_name(uint charset_number) static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags) { char buf[FN_REFLEN]; - CHARSET_INFO *cs; + struct charset_info_st *cs; - if ((cs= all_charsets[cs_number])) + if ((cs= (struct charset_info_st*) all_charsets[cs_number])) { if (cs->state & MY_CS_READY) /* if CS is already initialized */ return cs; |