diff options
author | unknown <tsmith@quadxeon.mysql.com> | 2007-06-05 17:51:30 +0200 |
---|---|---|
committer | unknown <tsmith@quadxeon.mysql.com> | 2007-06-05 17:51:30 +0200 |
commit | 38ed1be3ec579e55bfb12c16c9a5d2434dcd5d3d (patch) | |
tree | 50b7ef6b918f2c9add6a6f5f3237ef8e777f57e8 /strings | |
parent | c59c004c9a298c944c67672e301da8ec435461d6 (diff) | |
parent | 0484d44eebff70ef5a2c328c7a9d50ac07a89409 (diff) | |
download | mariadb-git-38ed1be3ec579e55bfb12c16c9a5d2434dcd5d3d.tar.gz |
Merge quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/51
into quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/jun05/51
client/mysqldump.c:
Auto merged
include/m_string.h:
Auto merged
include/mysql_com.h:
Auto merged
include/violite.h:
Auto merged
libmysql/libmysql.c:
Auto merged
mysql-test/include/mix1.inc:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/innodb_mysql.result:
Auto merged
mysql-test/r/ps.result:
Auto merged
mysql-test/t/mysqltest.test:
Auto merged
mysql-test/t/ps.test:
Auto merged
mysys/my_init.c:
Auto merged
server-tools/instance-manager/mysql_connection.cc:
Auto merged
sql/field.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/net_serv.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_connect.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql-common/client.c:
Auto merged
sql/sql_yacc.yy:
Auto merged
strings/ctype-mb.c:
Auto merged
strings/ctype-ucs2.c:
Auto merged
strings/strtod.c:
Auto merged
vio/vio_priv.h:
Auto merged
vio/viosocket.c:
Auto merged
client/mysqltest.c:
SCCS merged
include/my_global.h:
SCCS merged
sql/field.h:
SCCS merged
sql/sql_table.cc:
Manual merge
strings/ctype-bin.c:
Manual merge
Diffstat (limited to 'strings')
42 files changed, 759 insertions, 719 deletions
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index dd9b500841f..ac7c75ec56c 100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -24,4 +24,4 @@ ADD_LIBRARY(strings bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c strtod.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c - my_strchr.c strcont.c strinstr.c) + my_strchr.c strcont.c strinstr.c strnlen.c) diff --git a/strings/bchange.c b/strings/bchange.c index f17fb9bea27..0b2c62019b5 100644 --- a/strings/bchange.c +++ b/strings/bchange.c @@ -26,10 +26,10 @@ #include <my_global.h> #include "m_string.h" -void bchange(register char *dst, uint old_length, register const char *src, - uint new_length, uint tot_length) +void bchange(register uchar *dst, size_t old_length, register const uchar *src, + size_t new_length, size_t tot_length) { - uint rest=tot_length-old_length; + size_t rest=tot_length-old_length; if (old_length < new_length) bmove_upp(dst+rest+new_length,dst+tot_length,rest); else diff --git a/strings/bcmp.c b/strings/bcmp.c index fd9ee5c1b96..1b6ed22fc22 100644 --- a/strings/bcmp.c +++ b/strings/bcmp.c @@ -51,9 +51,11 @@ uint len; /* 0 <= len <= 65535 */ #else #ifndef HAVE_purify -int bcmp(register const char *s1,register const char *s2, register uint len) +size_t bcmp(register const uchar *s1,register const uchar *s2, + register size_t len) #else -int my_bcmp(register const char *s1,register const char *s2, register uint len) +size_t my_bcmp(register const uchar *s1,register const uchar *s2, + register size_t len) #endif { while (len-- != 0 && *s1++ == *s2++) ; diff --git a/strings/bmove512.c b/strings/bmove512.c index c3a4b7dfe4e..c3f0446ead6 100644 --- a/strings/bmove512.c +++ b/strings/bmove512.c @@ -36,7 +36,7 @@ #define LONG ulonglong #endif -void bmove512(gptr to, const gptr from, register uint length) +void bmove512(uchar *to, const uchar *from, register size_t length) { reg1 LONG *f,*t,*end= (LONG*) ((char*) from+length); diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c index 02b59bdb703..fb47bda2d1d 100644 --- a/strings/bmove_upp.c +++ b/strings/bmove_upp.c @@ -41,7 +41,8 @@ asm(".L5: "); } #else -void bmove_upp(register char *dst, register const char *src, register uint len) +void bmove_upp(register uchar *dst, register const uchar *src, + register size_t len) { while (len-- != 0) *--dst = *--src; } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index dba5064ba0c..a0571ff0b22 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -220,7 +220,7 @@ static uint16 big5strokexfrm(uint16 i) static int my_strnncoll_big5_internal(const uchar **a_res, - const uchar **b_res, uint length) + const uchar **b_res, size_t length) { const uchar *a= *a_res, *b= *b_res; @@ -249,11 +249,11 @@ static int my_strnncoll_big5_internal(const uchar **a_res, /* Compare strings */ static int my_strnncoll_big5(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_big5_internal(&a, &b, length); return res ? res : (int)((b_is_prefix ? length : a_length) - b_length); } @@ -262,11 +262,11 @@ static int my_strnncoll_big5(CHARSET_INFO *cs __attribute__((unused)), /* compare strings, ignore end space */ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_big5_internal(&a, &b, length); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -301,12 +301,12 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), } -static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uint16 e; - uint dstlen= len; + size_t dstlen= len; len = srclen; while (len--) @@ -327,7 +327,7 @@ static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), } #if 0 -static int my_strcoll_big5(const uchar * s1, const uchar * s2) +static int my_strcoll_big5(const uchar *s1, const uchar *s2) { while (*s1 && *s2) @@ -346,7 +346,7 @@ static int my_strcoll_big5(const uchar * s1, const uchar * s2) return 0; } -static int my_strxfrm_big5(uchar * dest, const uchar * src, int len) +static int my_strxfrm_big5(uchar *dest, const uchar *src, int len) { uint16 e; uchar *d = dest; @@ -395,15 +395,16 @@ static int my_strxfrm_big5(uchar * dest, const uchar * src, int len) #define max_sort_char ((char) 255) static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t res_length, + char *min_str, char *max_str, + size_t *min_length, size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) { @@ -435,7 +436,7 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do { @@ -447,21 +448,21 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), *min_str++= *max_str++ = *ptr; } - *min_length= *max_length= (uint) (min_str-min_org); + *min_length= *max_length= (size_t) (min_str-min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; return 0; } -static int ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)), - const char* p, const char *e) +static uint ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)), + const char* p, const char *e) { return (isbig5head(*(p)) && (e)-(p)>1 && isbig5tail(*((p)+1))? 2: 0); } -static int mbcharlen_big5(CHARSET_INFO *cs __attribute__((unused)), uint c) +static uint mbcharlen_big5(CHARSET_INFO *cs __attribute__((unused)), uint c) { return (isbig5head(c)? 2 : 1); } @@ -6239,7 +6240,7 @@ static int func_uni_big5_onechar(int code){ static int my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t wc, unsigned char *s, unsigned char *e) + my_wc_t wc, uchar *s, uchar *e) { int code; @@ -6297,9 +6298,9 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), CP950 and HKSCS additional characters are also accepted. */ static -uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -6324,7 +6325,7 @@ uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 681f0352b8c..b24470747e6 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -69,26 +69,26 @@ static uchar bin_char_array[] = static my_bool my_coll_init_8bit_bin(CHARSET_INFO *cs, - void *(*alloc)(uint) __attribute__((unused))) + void *(*alloc)(size_t) __attribute__((unused))) { cs->max_sort_char=255; return FALSE; } static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - uint len=min(slen,tlen); + size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen); } -uint my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr __attribute__((unused)), - uint length) +size_t my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr __attribute__((unused)), + size_t length) { return length; } @@ -117,8 +117,8 @@ uint my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)), */ static int my_strnncollsp_binary(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -127,11 +127,11 @@ static int my_strnncollsp_binary(CHARSET_INFO * cs __attribute__((unused)), static int my_strnncoll_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - uint len=min(slen,tlen); + size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen); } @@ -163,12 +163,12 @@ static int my_strnncoll_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), */ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *end; - uint length; + size_t length; int res; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -211,17 +211,18 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), /* This function is used for all conversion functions */ -static uint my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), - char *str __attribute__((unused))) +static size_t my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), + char *str __attribute__((unused))) { return 0; } -static uint my_case_bin(CHARSET_INFO *cs __attribute__((unused)), - char *src __attribute__((unused)), - uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +static size_t my_case_bin(CHARSET_INFO *cs __attribute__((unused)), + char *src __attribute__((unused)), + size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { return srclen; } @@ -234,8 +235,8 @@ static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)), } -int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), - uint c __attribute__((unused))) +uint my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), + uint c __attribute__((unused))) { return 1; } @@ -243,8 +244,8 @@ int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -256,8 +257,8 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, - unsigned char *s, - unsigned char *e __attribute__((unused))) + uchar *s, + uchar *e __attribute__((unused))) { if (s >= e) return MY_CS_TOOSMALL; @@ -295,7 +296,7 @@ void my_hash_sort_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len,ulong *nr1, ulong *nr2) + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -397,9 +398,9 @@ int my_wildcmp_bin(CHARSET_INFO *cs, } -static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t dstlen, + const uchar *src, size_t srclen) { if (dest != src) memcpy(dest, src, min(dstlen,srclen)); @@ -410,9 +411,9 @@ static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), static -int my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint dstlen, - const uchar *src, uint srclen) +size_t my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t dstlen, + const uchar *src, size_t srclen) { if (dest != src) memcpy(dest, src, min(dstlen,srclen)); @@ -424,8 +425,8 @@ int my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), static uint my_instr_bin(CHARSET_INFO *cs __attribute__((unused)), - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch) { register const uchar *str, *search, *end, *search_end; @@ -465,7 +466,7 @@ skip: if (nmatch > 0) { match[0].beg= 0; - match[0].end= (uint) (str- (const uchar*)b-1); + match[0].end= (size_t) (str- (const uchar*)b-1); match[0].mb_len= match[0].end; if (nmatch > 1) @@ -485,65 +486,65 @@ skip: MY_COLLATION_HANDLER my_collation_8bit_bin_handler = { - my_coll_init_8bit_bin, - my_strnncoll_8bit_bin, - my_strnncollsp_8bit_bin, - my_strnxfrm_8bit_bin, - my_strnxfrmlen_simple, - my_like_range_simple, - my_wildcmp_bin, - my_strcasecmp_bin, - my_instr_bin, - my_hash_sort_8bit_bin, - my_propagate_simple + my_coll_init_8bit_bin, + my_strnncoll_8bit_bin, + my_strnncollsp_8bit_bin, + my_strnxfrm_8bit_bin, + my_strnxfrmlen_simple, + my_like_range_simple, + my_wildcmp_bin, + my_strcasecmp_bin, + my_instr_bin, + my_hash_sort_8bit_bin, + my_propagate_simple }; static MY_COLLATION_HANDLER my_collation_binary_handler = { - NULL, /* init */ - my_strnncoll_binary, - my_strnncollsp_binary, - my_strnxfrm_bin, - my_strnxfrmlen_simple, - my_like_range_simple, - my_wildcmp_bin, - my_strcasecmp_bin, - my_instr_bin, - my_hash_sort_bin, - my_propagate_simple + NULL, /* init */ + my_strnncoll_binary, + my_strnncollsp_binary, + my_strnxfrm_bin, + my_strnxfrmlen_simple, + my_like_range_simple, + my_wildcmp_bin, + my_strcasecmp_bin, + my_instr_bin, + my_hash_sort_bin, + my_propagate_simple }; static MY_CHARSET_HANDLER my_charset_handler= { - NULL, /* init */ - NULL, /* ismbchar */ - my_mbcharlen_8bit, /* mbcharlen */ - my_numchars_8bit, - my_charpos_8bit, - my_well_formed_len_8bit, - my_lengthsp_binary, - my_numcells_8bit, - my_mb_wc_bin, - my_wc_mb_bin, - my_mb_ctype_8bit, - my_case_str_bin, - my_case_str_bin, - my_case_bin, - my_case_bin, - my_snprintf_8bit, - my_long10_to_str_8bit, - my_longlong10_to_str_8bit, - my_fill_8bit, - my_strntol_8bit, - my_strntoul_8bit, - my_strntoll_8bit, - my_strntoull_8bit, - my_strntod_8bit, - my_strtoll10_8bit, - my_strntoull10rnd_8bit, - my_scan_8bit + NULL, /* init */ + NULL, /* ismbchar */ + my_mbcharlen_8bit, /* mbcharlen */ + my_numchars_8bit, + my_charpos_8bit, + my_well_formed_len_8bit, + my_lengthsp_binary, + my_numcells_8bit, + my_mb_wc_bin, + my_wc_mb_bin, + my_mb_ctype_8bit, + my_case_str_bin, + my_case_str_bin, + my_case_bin, + my_case_bin, + my_snprintf_8bit, + my_long10_to_str_8bit, + my_longlong10_to_str_8bit, + my_fill_8bit, + my_strntol_8bit, + my_strntoul_8bit, + my_strntoll_8bit, + my_strntoull_8bit, + my_strntod_8bit, + my_strtoll10_8bit, + my_strntoull10rnd_8bit, + my_scan_8bit }; diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index dc8d1d7cb22..72b00679e1c 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -182,13 +182,13 @@ static uchar NEAR sort_order_cp932[]= (0x80<=(c) && (c)<=0xfc)) -static int ismbchar_cp932(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_cp932(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (iscp932head((uchar) *p) && (e-p)>1 && iscp932tail((uchar)p[1]) ? 2: 0); } -static int mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (iscp932head((uchar) c) ? 2 : 1); } @@ -198,8 +198,8 @@ static int mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) static int my_strnncoll_cp932_internal(CHARSET_INFO *cs, - const uchar **a_res, uint a_length, - const uchar **b_res, uint b_length) + const uchar **a_res, size_t a_length, + const uchar **b_res, size_t b_length) { const uchar *a= *a_res, *b= *b_res; const uchar *a_end= a + a_length; @@ -230,8 +230,8 @@ static int my_strnncoll_cp932_internal(CHARSET_INFO *cs, static int my_strnncoll_cp932(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { int res= my_strnncoll_cp932_internal(cs, &a, a_length, &b, b_length); @@ -242,8 +242,8 @@ static int my_strnncoll_cp932(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -275,9 +275,9 @@ static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)), -static int my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), - uchar *dest, uint len, - const uchar *src, uint srclen) +static size_t my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uchar *d_end = dest + len; uchar *s_end = (uchar*) src + srclen; @@ -318,10 +318,11 @@ static int my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((char) 255) static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, - pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + const char *ptr,size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str,char *max_str, + size_t *min_length, size_t *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; @@ -350,7 +351,7 @@ static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), } if (*ptr == w_many) { /* '%' in SQL */ - *min_length = (uint)(min_str - min_org); + *min_length = (size_t)(min_str - min_org); *max_length = res_length; do { @@ -361,7 +362,7 @@ static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), } *min_str++ = *max_str++ = *ptr++; } - *min_length = *max_length = (uint)(min_str - min_org); + *min_length = *max_length = (size_t) (min_str - min_org); while (min_str < min_end) *min_str++ = *max_str++ = ' '; /* Because if key compression */ return 0; @@ -5378,12 +5379,12 @@ my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)), } static -uint my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen= 0; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -5410,9 +5411,11 @@ uint my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), Returns a well formed length of a cp932 string. cp932 additional characters are also accepted. */ + static -uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, uint pos, int *error) +size_t my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; *error= 0; @@ -5445,7 +5448,7 @@ uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index d0104a50f4a..a5df86cc6b3 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -83,7 +83,7 @@ below for what are the "special values" */ -static uchar * CZ_SORT_TABLE[] = { +static uchar *CZ_SORT_TABLE[] = { (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\043\044\045\046\047\050\051\052\053\054\000\000\000\000\000\000\000\003\004\377\007\010\011\012\013\015\016\017\020\022\023\024\025\026\027\031\033\034\035\036\037\040\041\000\000\000\000\000\000\003\004\377\007\010\011\012\013\015\016\017\020\022\023\024\025\026\027\031\033\034\035\036\037\040\041\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000\021\000\020\032\000\000\032\032\033\042\000\042\042\000\003\000\021\000\020\032\000\000\032\032\033\042\000\042\042\027\003\003\003\003\020\006\006\006\010\010\010\010\015\015\007\007\023\023\024\024\024\024\000\030\034\034\034\034\040\033\000\027\003\003\003\003\020\006\006\006\010\010\010\010\015\015\007\007\023\023\024\024\024\024\000\030\034\034\034\034\040\033\000", (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\106\107\110\111\112\113\114\115\116\117\000\000\000\000\000\000\000\003\011\377\016\021\026\027\030\032\035\036\037\043\044\047\054\055\056\061\065\070\075\076\077\100\102\000\000\000\000\000\000\003\011\377\016\021\026\027\030\032\035\036\037\043\044\047\054\055\056\061\065\070\075\076\077\100\102\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\042\000\041\063\000\000\062\064\066\104\000\103\105\000\010\000\042\000\041\063\000\000\062\064\066\104\000\103\105\057\004\005\007\006\040\014\015\013\022\025\024\023\033\034\017\020\046\045\050\051\053\052\000\060\072\071\074\073\101\067\000\057\004\005\007\006\040\014\015\013\022\025\024\023\033\034\017\020\046\045\050\051\053\052\000\060\072\071\074\073\101\067\000", (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\212\213\214\215\216\217\220\221\222\223\000\000\000\000\000\000\000\004\020\377\032\040\052\054\056\063\071\073\075\105\107\115\127\131\133\141\151\157\171\173\175\177\203\000\000\000\000\000\000\003\017\377\031\037\051\053\055\062\070\072\074\104\106\114\126\130\132\140\150\156\170\172\174\176\202\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\103\000\101\145\000\000\143\147\153\207\000\205\211\000\015\000\102\000\100\144\000\000\142\146\152\206\000\204\210\135\006\010\014\012\077\026\030\024\042\050\046\044\065\067\034\036\113\111\117\121\125\123\000\137\163\161\167\165\201\155\000\134\005\007\013\011\076\025\027\023\041\047\045\043\064\066\033\035\112\110\116\120\124\122\000\136\162\160\166\164\200\154\000", @@ -99,7 +99,7 @@ static uchar * CZ_SORT_TABLE[] = { struct wordvalue { const char * word; - uchar * outvalue; + uchar *outvalue; }; static struct wordvalue doubles[] = { { "ch", (uchar*) "\014\031\057\057" }, @@ -190,8 +190,8 @@ while (1) \ { p++; continue; } /* ignore value */ \ if (value == 2) /* space */ \ { \ - const uchar * tmp; \ - const uchar * runner = ++p; \ + const uchar *tmp; \ + const uchar *runner = ++p; \ while (!(IS_END(runner, src, len)) && (CZ_SORT_TABLE[pass][*runner] == 2)) \ runner++; /* skip all spaces */ \ if (IS_END(runner, src, len) && SKIP_TRAILING_SPACES) \ @@ -240,12 +240,12 @@ while (1) \ */ static int my_strnncoll_czech(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2, + const uchar *s1, size_t len1, + const uchar *s2, size_t len2, my_bool s2_is_prefix) { int v1, v2; - const uchar * p1, * p2, * store1, * store2; + const uchar *p1, * p2, * store1, * store2; int pass1 = 0, pass2 = 0; if (s2_is_prefix && len1 > len2) @@ -274,8 +274,8 @@ static int my_strnncoll_czech(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_czech(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -290,14 +290,14 @@ int my_strnncollsp_czech(CHARSET_INFO * cs, the length of the strings being specified */ -static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { int value; - const uchar * p, * store; + const uchar *p, * store; int pass = 0; - uint totlen = 0; + size_t totlen = 0; p = src; store = src; do @@ -361,11 +361,11 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), #define EXAMPLE static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str, + size_t res_length, char *min_str, char *max_str, - uint *min_length,uint *max_length) + size_t *min_length,size_t *max_length) { #ifdef EXAMPLE uchar value; @@ -396,7 +396,7 @@ static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)), } if (cs->state & MY_CS_BINSORT) - *min_length= (uint) (min_str - min_org); + *min_length= (size_t) (min_str - min_org); else { /* 'a\0\0... is the smallest possible string */ diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index a90489cf7c6..844d8cc3ff5 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -182,15 +182,15 @@ static uchar NEAR sort_order_euc_kr[]= #define iseuc_kr(c) ((0xa1<=(uchar)(c) && (uchar)(c)<=0xfe)) -static int ismbchar_euc_kr(CHARSET_INFO *cs __attribute__((unused)), - const char* p, const char *e) +static uint ismbchar_euc_kr(CHARSET_INFO *cs __attribute__((unused)), + const char* p, const char *e) { return ((*(uchar*)(p)<0x80)? 0:\ iseuc_kr(*(p)) && (e)-(p)>1 && iseuc_kr(*((p)+1))? 2:\ 0); } -static int mbcharlen_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (iseuc_kr(c) ? 2 : 1); } @@ -8608,6 +8608,7 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)), return 2; } + static int my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e) @@ -8637,10 +8638,10 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)), /* Returns well formed length of a EUC-KR string. */ -static uint +static size_t my_well_formed_len_euckr(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e, - uint pos, int *error) + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -8665,7 +8666,7 @@ my_well_formed_len_euckr(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index eb1811b19bf..14be5e84d21 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -185,7 +185,7 @@ static uchar NEAR sort_order_eucjpms[]= #define iseucjpms_ss3(c) (((c)&0xff) == 0x8f) -static int ismbchar_eucjpms(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_eucjpms(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return ((*(uchar*)(p)<0x80)? 0:\ @@ -195,7 +195,7 @@ static int ismbchar_eucjpms(CHARSET_INFO *cs __attribute__((unused)), 0); } -static int mbcharlen_eucjpms(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_eucjpms(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (iseucjpms(c)? 2: iseucjpms_ss2(c)? 2: iseucjpms_ss3(c)? 3: 1); } @@ -8387,8 +8387,9 @@ my_jisx0212_uni_onechar(int code){ */ static -uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), - const char *beg, const char *end, uint pos, int *error) +size_t my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), + const char *beg, const char *end, size_t pos, + int *error) { const uchar *b= (uchar *) beg; *error=0; @@ -8427,19 +8428,19 @@ uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ continue; *error=1; - return (uint) (chbeg - beg); /* invalid sequence */ + return (size_t) (chbeg - beg); /* invalid sequence */ } - return (uint) (b - (uchar *) beg); + return (size_t) (b - (uchar *) beg); } static -uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *str_end) +size_t my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -8555,9 +8556,9 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e) } static int -my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e) +my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, uchar *s, uchar *e) { - unsigned char c1; + uchar c1; int jp; if (s >= e) diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 6b4238859d5..21aeb8b7990 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -165,13 +165,13 @@ static uchar NEAR sort_order_gb2312[]= #define isgb2312tail(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe) -static int ismbchar_gb2312(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_gb2312(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (isgb2312head(*(p)) && (e)-(p)>1 && isgb2312tail(*((p)+1))? 2: 0); } -static int mbcharlen_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (isgb2312head(c)? 2 : 1); } @@ -5688,10 +5688,10 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)), /* Returns well formed length of a EUC-KR string. */ -static uint +static size_t my_well_formed_len_gb2312(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e, - uint pos, int *error) + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -5716,7 +5716,7 @@ my_well_formed_len_gb2312(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index d88f4786017..e9a2b7cf832 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2582,7 +2582,7 @@ static uint16 gbksortorder(uint16 i) int my_strnncoll_gbk_internal(const uchar **a_res, const uchar **b_res, - uint length) + size_t length) { const uchar *a= *a_res, *b= *b_res; uint a_char,b_char; @@ -2612,22 +2612,22 @@ int my_strnncoll_gbk_internal(const uchar **a_res, const uchar **b_res, int my_strnncoll_gbk(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_gbk_internal(&a, &b, length); return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length); } static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_gbk_internal(&a, &b, length); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -2662,12 +2662,12 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), } -static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uint16 e; - uint dstlen= len; + size_t dstlen= len; len = srclen; while (len--) @@ -2708,15 +2708,16 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((uchar) 255) static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t res_length, + char *min_str,char *max_str, + size_t *min_length,size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) { @@ -2748,7 +2749,7 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do { @@ -2760,20 +2761,20 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), *min_str++= *max_str++ = *ptr; } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; /* Because if key compression */ return 0; } -static int ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (isgbkhead(*(p)) && (e)-(p)>1 && isgbktail(*((p)+1))? 2: 0); } -static int mbcharlen_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (isgbkhead(c)? 2 : 1); } @@ -9940,9 +9941,9 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)), Returns well formed length of a GBK string. */ static -uint my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -9967,7 +9968,7 @@ uint my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 30e0abb35d5..e5333c4101b 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -150,7 +150,7 @@ unsigned short cs_to_uni[256]={ 0x00F0,0x00F1,0x00F2,0x00F3,0x00F4,0x00F5,0x00F6,0x00F7, 0x00F8,0x00F9,0x00FA,0x00FB,0x00FC,0x00FD,0x00FE,0x00FF }; -unsigned char pl00[256]={ +uchar pl00[256]={ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, @@ -184,7 +184,7 @@ unsigned char pl00[256]={ 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7, 0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF }; -unsigned char pl01[256]={ +uchar pl01[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -218,7 +218,7 @@ unsigned char pl01[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char pl02[256]={ +uchar pl02[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -252,7 +252,7 @@ unsigned char pl02[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char pl20[256]={ +uchar pl20[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x96,0x97,0x00,0x00,0x00, @@ -286,7 +286,7 @@ unsigned char pl20[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char pl21[256]={ +uchar pl21[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -320,7 +320,7 @@ unsigned char pl21[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char *uni_to_cs[256]={ +uchar *uni_to_cs[256]={ pl00,pl01,pl02,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, @@ -358,8 +358,8 @@ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL static int my_mb_wc_latin1(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -371,10 +371,10 @@ int my_mb_wc_latin1(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_latin1(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, - unsigned char *str, - unsigned char *end __attribute__((unused))) + uchar *str, + uchar *end __attribute__((unused))) { - unsigned char *pl; + uchar *pl; if (str >= end) return MY_CS_TOOSMALL; @@ -543,8 +543,8 @@ uchar combo2map[]={ static int my_strnncoll_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { const uchar *a_end= a + a_length; @@ -584,8 +584,8 @@ static int my_strnncoll_latin1_de(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *a_end= a + a_length, *b_end= b + b_length; @@ -655,9 +655,9 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)), } -static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { const uchar *de = dest + len; const uchar *se = src + srclen; @@ -675,7 +675,7 @@ static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)), void my_hash_sort_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len, + const uchar *key, size_t len, ulong *nr1, ulong *nr2) { const uchar *end= key+len; diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index ce2bb4922ea..d1572834ad3 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -20,7 +20,7 @@ #ifdef USE_MB -uint my_caseup_str_mb(CHARSET_INFO * cs, char *str) +size_t my_caseup_str_mb(CHARSET_INFO * cs, char *str) { register uint32 l; register uchar *map= cs->to_upper; @@ -37,10 +37,11 @@ uint my_caseup_str_mb(CHARSET_INFO * cs, char *str) str++; } } - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_casedn_str_mb(CHARSET_INFO * cs, char *str) + +size_t my_casedn_str_mb(CHARSET_INFO * cs, char *str) { register uint32 l; register uchar *map= cs->to_lower; @@ -57,12 +58,13 @@ uint my_casedn_str_mb(CHARSET_INFO * cs, char *str) str++; } } - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_caseup_mb(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +size_t my_caseup_mb(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { register uint32 l; register char *srcend= src + srclen; @@ -82,9 +84,10 @@ uint my_caseup_mb(CHARSET_INFO * cs, char *src, uint srclen, return srclen; } -uint my_casedn_mb(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +size_t my_casedn_mb(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { register uint32 l; register char *srcend= src + srclen; @@ -104,9 +107,11 @@ uint my_casedn_mb(CHARSET_INFO * cs, char *src, uint srclen, return srclen; } + /* my_strcasecmp_mb() returns 0 if strings are equal, non-zero otherwise. */ + int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t) { register uint32 l; @@ -250,10 +255,10 @@ int my_wildcmp_mb(CHARSET_INFO *cs, } -uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), const char *pos, const char *end) { - register uint32 count=0; + register size_t count= 0; while (pos < end) { uint mb_len; @@ -264,8 +269,8 @@ uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), } -uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), - const char *pos, const char *end, uint length) +size_t my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), + const char *pos, const char *end, size_t length) { const char *start= pos; @@ -275,12 +280,12 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), pos+= (mb_len= my_ismbchar(cs, pos, end)) ? mb_len : 1; length--; } - return (uint) (length ? end+2-start : pos-start); + return (size_t) (length ? end+2-start : pos-start); } -uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, + size_t pos, int *error) { const char *b_start= b; *error= 0; @@ -297,14 +302,13 @@ uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, b+= mb_len; pos--; } - return (uint) (b - b_start); + return (size_t) (b - b_start); } - uint my_instr_mb(CHARSET_INFO *cs, - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch) { register const char *end, *b0; @@ -330,13 +334,13 @@ uint my_instr_mb(CHARSET_INFO *cs, { int mb_len; - if (!cs->coll->strnncoll(cs, (unsigned char*) b, s_length, - (unsigned char*) s, s_length, 0)) + if (!cs->coll->strnncoll(cs, (uchar*) b, s_length, + (uchar*) s, s_length, 0)) { if (nmatch) { match[0].beg= 0; - match[0].end= (uint) (b-b0); + match[0].end= (size_t) (b-b0); match[0].mb_len= res; if (nmatch > 1) { @@ -360,11 +364,11 @@ uint my_instr_mb(CHARSET_INFO *cs, /* BINARY collations handlers for MB charsets */ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - uint len=min(slen,tlen); + size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen); } @@ -396,12 +400,12 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), */ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *end; - uint length; + size_t length; int res; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -442,9 +446,9 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), } -static int my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t dstlen, + const uchar *src, size_t srclen) { if (dest != src) memcpy(dest, src, min(dstlen, srclen)); @@ -461,7 +465,7 @@ static int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), } static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len,ulong *nr1, ulong *nr2) + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -551,18 +555,18 @@ static void pad_max_char(CHARSET_INFO *cs, char *str, char *end) */ my_bool my_like_range_mb(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t *min_length,size_t *max_length) { uint mb_len; const char *end= ptr + ptr_length; char *min_org= min_str; char *min_end= min_str + res_length; char *max_end= max_str + res_length; - uint maxcharlen= res_length / cs->mbmaxlen; + size_t maxcharlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && maxcharlen ; maxcharlen--) { @@ -576,7 +580,7 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; /* Create min key */ @@ -606,7 +610,7 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; /* Because if key compression */ return 0; @@ -926,10 +930,11 @@ static struct {int page; char *p;} utr11_data[256]= {0,NULL},{1,NULL},{0,pgFA},{0,NULL},{0,NULL},{0,NULL},{0,pgFE},{0,pgFF} }; -uint my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) + +size_t my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) { my_wc_t wc; - int clen= 0; + size_t clen= 0; while (b < e) { @@ -951,7 +956,7 @@ uint my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, - const unsigned char *s, const unsigned char *e) + const uchar *s, const uchar *e) { my_wc_t wc; int res= cs->cset->mb_wc(cs, &wc, s, e); @@ -965,7 +970,6 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, } - MY_COLLATION_HANDLER my_collation_mb_bin_handler = { NULL, /* init */ diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index c129f117744..99e41611eaa 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -24,7 +24,8 @@ /* Returns the number of bytes required for strnxfrm(). */ -uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) + +size_t my_strnxfrmlen_simple(CHARSET_INFO *cs, size_t len) { return len * (cs->strxfrm_multiply ? cs->strxfrm_multiply : 1); } @@ -70,12 +71,12 @@ uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) */ -int my_strnxfrm_simple(CHARSET_INFO * cs, - uchar *dest, uint len, - const uchar *src, uint srclen) +size_t my_strnxfrm_simple(CHARSET_INFO * cs, + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uchar *map= cs->sort_order; - uint dstlen= len; + size_t dstlen= len; set_if_smaller(len, srclen); if (dest != src) { @@ -94,11 +95,12 @@ int my_strnxfrm_simple(CHARSET_INFO * cs, return dstlen; } -int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, - const uchar *t, uint tlen, + +int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - int len = ( slen > tlen ) ? tlen : slen; + size_t len = ( slen > tlen ) ? tlen : slen; uchar *map= cs->sort_order; if (t_is_prefix && slen > tlen) slen=tlen; @@ -107,7 +109,11 @@ int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, if (map[*s++] != map[*t++]) return ((int) map[s[-1]] - (int) map[t[-1]]); } - return (int) (slen - tlen); + /* + We can't use (slen - tlen) here as the result may be outside of the + precision of a signed int + */ + return slen > tlen ? 1 : slen < tlen ? -1 : 0 ; } @@ -141,12 +147,12 @@ int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, > 0 a > b */ -int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, - const uchar *b, uint b_length, +int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *map= cs->sort_order, *end; - uint length; + size_t length; int res; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -187,48 +193,49 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, } -uint my_caseup_str_8bit(CHARSET_INFO * cs,char *str) +size_t my_caseup_str_8bit(CHARSET_INFO * cs,char *str) { register uchar *map= cs->to_upper; char *str_orig= str; while ((*str= (char) map[(uchar) *str]) != 0) str++; - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_casedn_str_8bit(CHARSET_INFO * cs,char *str) +size_t my_casedn_str_8bit(CHARSET_INFO * cs,char *str) { register uchar *map= cs->to_lower; char *str_orig= str; while ((*str= (char) map[(uchar) *str]) != 0) str++; - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_caseup_8bit(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) +size_t my_caseup_8bit(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { - uint srclen0= srclen; + char *end= src + srclen; register uchar *map= cs->to_upper; DBUG_ASSERT(src == dst && srclen == dstlen); - for ( ; srclen > 0 ; srclen--, src++) + for ( ; src != end ; src++) *src= (char) map[(uchar) *src]; - return srclen0; + return srclen; } -uint my_casedn_8bit(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +size_t my_casedn_8bit(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { - uint srclen0= srclen; + char *end= src + srclen; register uchar *map=cs->to_lower; DBUG_ASSERT(src == dst && srclen == dstlen); - for ( ; srclen > 0 ; srclen--, src++) + for ( ; src != end ; src++) *src= (char) map[(uchar) *src]; - return srclen0; + return srclen; } int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t) @@ -241,8 +248,8 @@ int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t) int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -252,8 +259,8 @@ int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, } int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, - unsigned char *str, - unsigned char *end __attribute__((unused))) + uchar *str, + uchar *end) { MY_UNI_IDX *idx; @@ -279,8 +286,8 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, end buffer must be checked. */ -int my_snprintf_8bit(CHARSET_INFO *cs __attribute__((unused)), - char* to, uint n __attribute__((unused)), +size_t my_snprintf_8bit(CHARSET_INFO *cs __attribute__((unused)), + char* to, size_t n __attribute__((unused)), const char* fmt, ...) { va_list args; @@ -293,7 +300,7 @@ int my_snprintf_8bit(CHARSET_INFO *cs __attribute__((unused)), void my_hash_sort_simple(CHARSET_INFO *cs, - const uchar *key, uint len, + const uchar *key, size_t len, ulong *nr1, ulong *nr2) { register uchar *sort_order=cs->sort_order; @@ -316,15 +323,15 @@ void my_hash_sort_simple(CHARSET_INFO *cs, long my_strntol_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative; register uint32 cutoff; - register unsigned int cutlim; + register uint cutlim; register uint32 i; register const char *s; - register unsigned char c; + register uchar c; const char *save, *e; int overflow; @@ -439,15 +446,15 @@ noconv: ulong my_strntoul_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative; register uint32 cutoff; - register unsigned int cutlim; + register uint cutlim; register uint32 i; register const char *s; - register unsigned char c; + register uchar c; const char *save, *e; int overflow; @@ -553,12 +560,12 @@ noconv: longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr,int *err) { int negative; register ulonglong cutoff; - register unsigned int cutlim; + register uint cutlim; register ulonglong i; register const char *s, *e; const char *save; @@ -625,7 +632,7 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), i = 0; for ( ; s != e; s++) { - register unsigned char c= *s; + register uchar c= *s; if (c>='0' && c<='9') c -= '0'; else if (c>='A' && c<='Z') @@ -676,12 +683,12 @@ noconv: ulonglong my_strntoull_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative; register ulonglong cutoff; - register unsigned int cutlim; + register uint cutlim; register ulonglong i; register const char *s, *e; const char *save; @@ -748,7 +755,7 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs, i = 0; for ( ; s != e; s++) { - register unsigned char c= *s; + register uchar c= *s; if (c>='0' && c<='9') c -= '0'; @@ -790,6 +797,7 @@ noconv: return 0L; } + /* Read double from string @@ -814,7 +822,7 @@ noconv: double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *str, uint length, + char *str, size_t length, char **end, int *err) { if (length == INT_MAX32) @@ -830,8 +838,8 @@ double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)), Assume len >= 1 */ -int my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *dst, uint len, int radix, long int val) +size_t my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), + char *dst, size_t len, int radix, long int val) { char buffer[66]; register char *p, *e; @@ -863,14 +871,15 @@ int my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), val= new_val; } - len= min(len, (uint) (e-p)); + len= min(len, (size_t) (e-p)); memcpy(dst, p, len); - return (int) len+sign; + return len+sign; } -int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *dst, uint len, int radix, longlong val) +size_t my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), + char *dst, size_t len, int radix, + longlong val) { char buffer[65]; register char *p, *e; @@ -914,7 +923,7 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), long_val= quo; } - len= min(len, (uint) (e-p)); + len= min(len, (size_t) (e-p)); cnv: memcpy(dst, p, len); return len+sign; @@ -1034,16 +1043,16 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, */ my_bool my_like_range_simple(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t *min_length, size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && charlen > 0 ; ptr++, charlen--) { @@ -1062,7 +1071,8 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, if (*ptr == w_many) /* '%' in SQL */ { /* Calculate length of keys */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? + (size_t) (min_str - min_org) : res_length); *max_length= res_length; do @@ -1075,14 +1085,14 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, *min_str++= *max_str++ = *ptr; } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++ = ' '; /* Because if key compression */ return 0; } -ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) +size_t my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) { const char *str0= str; switch (sq) @@ -1091,7 +1101,7 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) if (*str == '.') { for(str++ ; str != end && *str == '0' ; str++); - return (ulong) (str - str0); + return (size_t) (str - str0); } return 0; @@ -1101,7 +1111,7 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) if (!my_isspace(cs,*str)) break; } - return (ulong) (str - str0); + return (size_t) (str - str0); default: return 0; } @@ -1109,59 +1119,59 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) void my_fill_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *s, uint l, int fill) + char *s, size_t l, int fill) { - bfill(s,l,fill); + bfill((uchar*) s,l,fill); } -uint my_numchars_8bit(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numchars_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) { - return (uint) (e - b); + return (size_t) (e - b); } -uint my_numcells_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e) +size_t my_numcells_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e) { - return (uint) (e - b); + return (size_t) (e - b); } -uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *b __attribute__((unused)), - const char *e __attribute__((unused)), - uint pos) +size_t my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused)), + size_t pos) { return pos; } -uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *start, const char *end, - uint nchars, int *error) +size_t my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *start, const char *end, + size_t nchars, int *error) { - uint nbytes= (uint) (end-start); + size_t nbytes= (size_t) (end-start); *error= 0; return min(nbytes, nchars); } -uint my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint length) +size_t my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, size_t length) { const char *end= ptr+length; while (end > ptr && end[-1] == ' ') end--; - return (uint) (end-ptr); + return (size_t) (end-ptr); } uint my_instr_simple(CHARSET_INFO *cs, - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch) + const char *b, size_t b_length, + const char *s, size_t s_length, + my_match_t *match, uint nmatch) { register const uchar *str, *search, *end, *search_end; @@ -1200,7 +1210,7 @@ skip: if (nmatch > 0) { match[0].beg= 0; - match[0].end= (uint) (str- (const uchar*)b-1); + match[0].end= (size_t) (str- (const uchar*)b-1); match[0].mb_len= match[0].end; if (nmatch > 1) @@ -1239,7 +1249,7 @@ static int pcmp(const void * f, const void * s) return res; } -static my_bool create_fromuni(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool create_fromuni(CHARSET_INFO *cs, void *(*alloc)(size_t)) { uni_idx idx[PLANE_NUM]; int i,n; @@ -1318,7 +1328,7 @@ static my_bool create_fromuni(CHARSET_INFO *cs, void *(*alloc)(uint)) return FALSE; } -static my_bool my_cset_init_8bit(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool my_cset_init_8bit(CHARSET_INFO *cs, void *(*alloc)(size_t)) { cs->caseup_multiply= 1; cs->casedn_multiply= 1; @@ -1346,7 +1356,7 @@ static void set_max_sort_char(CHARSET_INFO *cs) } static my_bool my_coll_init_simple(CHARSET_INFO *cs, - void *(*alloc)(uint) __attribute__((unused))) + void *(*alloc)(size_t) __attribute__((unused))) { set_max_sort_char(cs); return FALSE; @@ -1361,7 +1371,7 @@ longlong my_strtoll10_8bit(CHARSET_INFO *cs __attribute__((unused)), int my_mb_ctype_8bit(CHARSET_INFO *cs, int *ctype, - const unsigned char *s, const unsigned char *e) + const uchar *s, const uchar *e) { if (s >= e) { @@ -1473,13 +1483,13 @@ static ulonglong d10[DIGITS_IN_ULONGLONG]= ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *str, uint length, int unsigned_flag, + const char *str, size_t length, int unsigned_flag, char **endptr, int *error) { const char *dot, *end9, *beg, *end= str + length; ulonglong ull; ulong ul; - unsigned char ch; + uchar ch; int shift= 0, digits= 0, negative, addon; /* Skip leading spaces and tabs */ @@ -1497,7 +1507,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), beg= str; end9= (str + 9) > end ? end : (str + 9); /* Accumulate small number into ulong, for performance purposes */ - for (ul= 0 ; str < end9 && (ch= (unsigned char) (*str - '0')) < 10; str++) + for (ul= 0 ; str < end9 && (ch= (uchar) (*str - '0')) < 10; str++) { ul= ul * 10 + ch; } @@ -1530,7 +1540,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), /* Continue to accumulate into ulonglong */ for (dot= NULL, ull= ul; str < end; str++) { - if ((ch= (unsigned char) (*str - '0')) < 10) + if ((ch= (uchar) (*str - '0')) < 10) { if (ull < CUTOFF || (ull == CUTOFF && ch <= CUTLIM)) { @@ -1551,7 +1561,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), } else addon= (*str >= '5'); - for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++) + for ( ; str < end && (ch= (uchar) (*str - '0')) < 10; str++) { if (!dot) shift++; @@ -1559,7 +1569,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), if (str < end && *str == '.' && !dot) { str++; - for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++); + for ( ; str < end && (ch= (uchar) (*str - '0')) < 10; str++); } goto exp; } @@ -1605,7 +1615,7 @@ exp: /* [ E [ <sign> ] <unsigned integer> ] */ goto ret_sign; } for (exponent= 0 ; - str < end && (ch= (unsigned char) (*str - '0')) < 10; + str < end && (ch= (uchar) (*str - '0')) < 10; str++) { exponent= exponent * 10 + ch; @@ -1748,7 +1758,7 @@ ret_too_big: my_bool my_propagate_simple(CHARSET_INFO *cs __attribute__((unused)), const uchar *str __attribute__((unused)), - uint length __attribute__((unused))) + size_t length __attribute__((unused))) { return 1; } @@ -1756,7 +1766,7 @@ my_bool my_propagate_simple(CHARSET_INFO *cs __attribute__((unused)), my_bool my_propagate_complex(CHARSET_INFO *cs __attribute__((unused)), const uchar *str __attribute__((unused)), - uint length __attribute__((unused))) + size_t length __attribute__((unused))) { return 0; } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 8f7158cc9c9..dfa8819a4db 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -182,13 +182,13 @@ static uchar NEAR sort_order_sjis[]= (0x80<=(c) && (c)<=0xfc)) -static int ismbchar_sjis(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_sjis(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (issjishead((uchar) *p) && (e-p)>1 && issjistail((uchar)p[1]) ? 2: 0); } -static int mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (issjishead((uchar) c) ? 2 : 1); } @@ -198,8 +198,8 @@ static int mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) static int my_strnncoll_sjis_internal(CHARSET_INFO *cs, - const uchar **a_res, uint a_length, - const uchar **b_res, uint b_length) + const uchar **a_res, size_t a_length, + const uchar **b_res, size_t b_length) { const uchar *a= *a_res, *b= *b_res; const uchar *a_end= a + a_length; @@ -230,9 +230,9 @@ static int my_strnncoll_sjis_internal(CHARSET_INFO *cs, static int my_strnncoll_sjis(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, - my_bool b_is_prefix) + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + my_bool b_is_prefix) { int res= my_strnncoll_sjis_internal(cs, &a, a_length, &b, b_length); if (b_is_prefix && a_length > b_length) @@ -242,8 +242,8 @@ static int my_strnncoll_sjis(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *a_end= a + a_length, *b_end= b + b_length; @@ -281,9 +281,9 @@ static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)), -static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), - uchar *dest, uint len, - const uchar *src, uint srclen) +static size_t my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uchar *d_end = dest + len; uchar *s_end = (uchar*) src + srclen; @@ -324,15 +324,16 @@ static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((char) 255) static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t res_length, + char *min_str,char *max_str, + size_t *min_length,size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for ( ; ptr < end && min_str < min_end && charlen > 0 ; charlen--) { @@ -363,7 +364,7 @@ static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do @@ -376,7 +377,7 @@ static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), *min_str++ = *max_str++ = *ptr++; } - *min_length= *max_length= (uint) (min_str - min_org); + *min_length= *max_length= (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; /* Because if key compression */ return 0; @@ -4553,12 +4554,12 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)), } static -uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -4586,9 +4587,9 @@ uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), CP932 additional characters are also accepted. */ static -uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; *error= 0; @@ -4616,7 +4617,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 4babe9917dc..a8c05dc4fd0 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -462,7 +462,7 @@ static uchar NEAR sort_order_tis620[]= len Length of tstr */ -static uint thai2sortable(uchar *tstr, uint len) +static size_t thai2sortable(uchar *tstr, size_t len) { uchar *p; int tlen; @@ -527,8 +527,8 @@ static uint thai2sortable(uchar *tstr, uint len) static int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2, + const uchar *s1, size_t len1, + const uchar *s2, size_t len2, my_bool s2_is_prefix) { uchar buf[80] ; @@ -557,12 +557,12 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a0, uint a_length, - const uchar *b0, uint b_length, + const uchar *a0, size_t a_length, + const uchar *b0, size_t b_length, my_bool diff_if_only_endspace_difference) { uchar buf[80], *end, *a, *b, *alloced= NULL; - uint length; + size_t length; int res= 0; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -633,13 +633,13 @@ ret: */ static -int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +size_t my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { - uint dstlen= len; - len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) - - (char*) dest); + size_t dstlen= len; + len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) - + (char*) dest); len= thai2sortable(dest, len); if (dstlen > len) bfill(dest + len, dstlen - len, ' '); @@ -681,7 +681,7 @@ static unsigned short cs_to_uni[256]={ 0x0E50,0x0E51,0x0E52,0x0E53,0x0E54,0x0E55,0x0E56,0x0E57, 0x0E58,0x0E59,0x0E5A,0x0E5B,0xFFFD,0xFFFD,0xFFFD,0xFFFD }; -static unsigned char pl00[256]={ +static uchar pl00[256]={ 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F, 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, @@ -715,7 +715,7 @@ static unsigned char pl00[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 }; -static unsigned char pl0E[256]={ +static uchar pl0E[256]={ 0x0000,0x00A1,0x00A2,0x00A3,0x00A4,0x00A5,0x00A6,0x00A7, 0x00A8,0x00A9,0x00AA,0x00AB,0x00AC,0x00AD,0x00AE,0x00AF, 0x00B0,0x00B1,0x00B2,0x00B3,0x00B4,0x00B5,0x00B6,0x00B7, @@ -749,7 +749,7 @@ static unsigned char pl0E[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 }; -static unsigned char plFF[256]={ +static uchar plFF[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, @@ -783,7 +783,7 @@ static unsigned char plFF[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x00FF,0x0000,0x0000 }; -static unsigned char *uni_to_cs[256]={ +static uchar *uni_to_cs[256]={ pl00,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,pl0E,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, @@ -822,8 +822,8 @@ NULL,NULL,NULL,NULL,NULL,NULL,NULL,plFF static int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -835,10 +835,10 @@ int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_tis620(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, - unsigned char *str, - unsigned char *end __attribute__((unused))) + uchar *str, + uchar *end __attribute__((unused))) { - unsigned char *pl; + uchar *pl; if (str >= end) return MY_CS_TOOSMALL; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 1263882846d..ea0d5a1436a 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6740,7 +6740,7 @@ typedef struct my_uca_scanner_st typedef struct my_uca_scanner_handler_st { void (*init)(my_uca_scanner *scanner, CHARSET_INFO *cs, - const uchar *str, uint length); + const uchar *str, size_t length); int (*next)(my_uca_scanner *scanner); } my_uca_scanner_handler; @@ -6767,7 +6767,7 @@ static uint16 nochar[]= {0,0}; static void my_uca_scanner_init_ucs2(my_uca_scanner *scanner, CHARSET_INFO *cs __attribute__((unused)), - const uchar *str, uint length) + const uchar *str, size_t length) { scanner->wbeg= nochar; if (length) @@ -6859,8 +6859,8 @@ static int my_uca_scanner_next_ucs2(my_uca_scanner *scanner) if (scanner->sbeg > scanner->send) return -1; - scanner->page= (unsigned char)scanner->sbeg[0]; - scanner->code= (unsigned char)scanner->sbeg[1]; + scanner->page= (uchar)scanner->sbeg[0]; + scanner->code= (uchar)scanner->sbeg[1]; scanner->sbeg+= 2; if (scanner->contractions && (scanner->sbeg <= scanner->send)) @@ -6919,7 +6919,7 @@ static my_uca_scanner_handler my_ucs2_uca_scanner_handler= */ static void my_uca_scanner_init_any(my_uca_scanner *scanner, CHARSET_INFO *cs __attribute__((unused)), - const uchar *str, uint length) + const uchar *str, size_t length) { /* Note, no needs to initialize scanner->wbeg */ scanner->sbeg= str; @@ -7055,8 +7055,8 @@ static my_uca_scanner_handler my_any_uca_scanner_handler= static int my_strnncoll_uca(CHARSET_INFO *cs, my_uca_scanner_handler *scanner_handler, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { my_uca_scanner sscanner; @@ -7126,8 +7126,8 @@ static int my_strnncoll_uca(CHARSET_INFO *cs, static int my_strnncollsp_uca(CHARSET_INFO *cs, my_uca_scanner_handler *scanner_handler, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { my_uca_scanner sscanner, tscanner; @@ -7204,7 +7204,7 @@ static int my_strnncollsp_uca(CHARSET_INFO *cs, static void my_hash_sort_uca(CHARSET_INFO *cs, my_uca_scanner_handler *scanner_handler, - const uchar *s, uint slen, + const uchar *s, size_t slen, ulong *n1, ulong *n2) { int s_res; @@ -7254,12 +7254,12 @@ static void my_hash_sort_uca(CHARSET_INFO *cs, Number of bytes that have been written into the binary image. */ -static int my_strnxfrm_uca(CHARSET_INFO *cs, - my_uca_scanner_handler *scanner_handler, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_uca(CHARSET_INFO *cs, + my_uca_scanner_handler *scanner_handler, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { - uchar *de = dst + (dstlen & (uint) ~1); /* add even length for easier code */ + uchar *de= dst + (dstlen & (size_t) ~1); /* add even length for easier code */ int s_res; my_uca_scanner scanner; scanner_handler->init(&scanner, cs, src, srclen); @@ -7292,6 +7292,7 @@ static int my_strnxfrm_uca(CHARSET_INFO *cs, This fact allows us to use memcmp() safely, on both little-endian and big-endian machines. */ + static int my_uca_charcmp(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2) { size_t page1= wc1 >> MY_UCA_PSHIFT; @@ -7334,7 +7335,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs, my_wc_t s_wc, w_wc; int scan; int (*mb_wc)(struct charset_info_st *, my_wc_t *, - const unsigned char *, const unsigned char *); + const uchar *, const uchar *); mb_wc= cs->cset->mb_wc; while (wildstr != wildend) @@ -7566,7 +7567,7 @@ static void my_coll_lexem_print_error(MY_COLL_LEXEM *lexem, { char tail[30]; size_t len= lexem->end - lexem->prev; - strmake (tail, lexem->prev, (uint) min(len, sizeof(tail)-1)); + strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1)); errstr[errsize-1]= '\0'; my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail); } @@ -7830,7 +7831,7 @@ static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems, default weights. */ -static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(size_t)) { MY_COLL_RULE rule[MY_MAX_COLL_RULE]; char errstr[128]; @@ -7979,15 +7980,15 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) Should work for any character set. */ -static my_bool my_coll_init_uca(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool my_coll_init_uca(CHARSET_INFO *cs, void *(*alloc)(size_t)) { cs->pad_char= ' '; return create_tailoring(cs, alloc); } static int my_strnncoll_any_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { return my_strnncoll_uca(cs, &my_any_uca_scanner_handler, @@ -7995,8 +7996,8 @@ static int my_strnncoll_any_uca(CHARSET_INFO *cs, } static int my_strnncollsp_any_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { return my_strnncollsp_uca(cs, &my_any_uca_scanner_handler, @@ -8005,15 +8006,15 @@ static int my_strnncollsp_any_uca(CHARSET_INFO *cs, } static void my_hash_sort_any_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, + const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_hash_sort_uca(cs, &my_any_uca_scanner_handler, s, slen, n1, n2); } -static int my_strnxfrm_any_uca(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_any_uca(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { return my_strnxfrm_uca(cs, &my_any_uca_scanner_handler, dst, dstlen, src, srclen); @@ -8025,8 +8026,8 @@ static int my_strnxfrm_any_uca(CHARSET_INFO *cs, UCS2 optimized CHARSET_INFO compatible wrappers. */ static int my_strnncoll_ucs2_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { return my_strnncoll_uca(cs, &my_ucs2_uca_scanner_handler, @@ -8034,8 +8035,8 @@ static int my_strnncoll_ucs2_uca(CHARSET_INFO *cs, } static int my_strnncollsp_ucs2_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { return my_strnncollsp_uca(cs, &my_ucs2_uca_scanner_handler, @@ -8044,15 +8045,15 @@ static int my_strnncollsp_ucs2_uca(CHARSET_INFO *cs, } static void my_hash_sort_ucs2_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, + const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_hash_sort_uca(cs, &my_ucs2_uca_scanner_handler, s, slen, n1, n2); } -static int my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { return my_strnxfrm_uca(cs, &my_ucs2_uca_scanner_handler, dst, dstlen, src, srclen); @@ -8060,17 +8061,17 @@ static int my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = { - my_coll_init_uca, /* init */ - my_strnncoll_ucs2_uca, - my_strnncollsp_ucs2_uca, - my_strnxfrm_ucs2_uca, - my_strnxfrmlen_simple, - my_like_range_ucs2, - my_wildcmp_uca, - NULL, - my_instr_mb, - my_hash_sort_ucs2_uca, - my_propagate_complex + my_coll_init_uca, /* init */ + my_strnncoll_ucs2_uca, + my_strnncollsp_ucs2_uca, + my_strnxfrm_ucs2_uca, + my_strnxfrmlen_simple, + my_like_range_ucs2, + my_wildcmp_uca, + NULL, + my_instr_mb, + my_hash_sort_ucs2_uca, + my_propagate_complex }; CHARSET_INFO my_charset_ucs2_general_uca= diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index d337c519f84..a8d0f051abf 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -22,6 +22,7 @@ #include "m_string.h" #include "m_ctype.h" #include <errno.h> +#include <stdarg.h> #ifdef HAVE_CHARSET_ucs2 @@ -96,7 +97,7 @@ static int my_ucs2_uni(CHARSET_INFO *cs __attribute__((unused)), if (s+2 > e) /* Need 2 characters */ return MY_CS_TOOSMALL2; - *pwc= ((unsigned char)s[0]) * 256 + ((unsigned char)s[1]); + *pwc= ((uchar)s[0]) * 256 + ((uchar)s[1]); return 2; } @@ -112,9 +113,9 @@ static int my_uni_ucs2(CHARSET_INFO *cs __attribute__((unused)) , } -static uint my_caseup_ucs2(CHARSET_INFO *cs, char *src, uint srclen, +static size_t my_caseup_ucs2(CHARSET_INFO *cs, char *src, size_t srclen, char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + size_t dstlen __attribute__((unused))) { my_wc_t wc; int res; @@ -135,7 +136,7 @@ static uint my_caseup_ucs2(CHARSET_INFO *cs, char *src, uint srclen, } -static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, uint slen, +static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_wc_t wc; @@ -159,16 +160,16 @@ static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, uint slen, } -static uint my_caseup_str_ucs2(CHARSET_INFO * cs __attribute__((unused)), +static size_t my_caseup_str_ucs2(CHARSET_INFO * cs __attribute__((unused)), char * s __attribute__((unused))) { return 0; } -static uint my_casedn_ucs2(CHARSET_INFO *cs, char *src, uint srclen, +static size_t my_casedn_ucs2(CHARSET_INFO *cs, char *src, size_t srclen, char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + size_t dstlen __attribute__((unused))) { my_wc_t wc; int res; @@ -189,7 +190,7 @@ static uint my_casedn_ucs2(CHARSET_INFO *cs, char *src, uint srclen, } -static uint my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), +static size_t my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), char * s __attribute__((unused))) { return 0; @@ -197,8 +198,8 @@ static uint my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncoll_ucs2(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -263,13 +264,13 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs, */ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { const uchar *se, *te; - uint minlen; + size_t minlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; /* extra safety to make sure the lengths are even numbers */ @@ -314,7 +315,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), static int my_strncasecmp_ucs2(CHARSET_INFO *cs, - const char *s, const char *t, uint len) + const char *s, const char *t, size_t len) { int s_res,t_res; my_wc_t s_wc,t_wc; @@ -355,15 +356,16 @@ static int my_strncasecmp_ucs2(CHARSET_INFO *cs, static int my_strcasecmp_ucs2(CHARSET_INFO *cs, const char *s, const char *t) { - uint s_len= (uint) strlen(s); - uint t_len= (uint) strlen(t); - uint len = (s_len > t_len) ? s_len : t_len; - return my_strncasecmp_ucs2(cs, s, t, len); + size_t s_len= strlen(s); + size_t t_len= strlen(t); + size_t len = (s_len > t_len) ? s_len : t_len; + return my_strncasecmp_ucs2(cs, s, t, len); } -static int my_strnxfrm_ucs2(CHARSET_INFO *cs, - uchar *dst, uint dstlen, const uchar *src, uint srclen) +static size_t my_strnxfrm_ucs2(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, const uchar *src, + size_t srclen) { my_wc_t wc; int res; @@ -391,30 +393,27 @@ static int my_strnxfrm_ucs2(CHARSET_INFO *cs, dst+=res; } if (dst < de) - cs->cset->fill(cs, (char*) dst, (uint) (de - dst), ' '); + cs->cset->fill(cs, (char*) dst, (size_t) (de - dst), ' '); return dstlen; } -static int my_ismbchar_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b __attribute__((unused)), - const char *e __attribute__((unused))) +static uint my_ismbchar_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused))) { return 2; } -static int my_mbcharlen_ucs2(CHARSET_INFO *cs __attribute__((unused)) , - uint c __attribute__((unused))) +static uint my_mbcharlen_ucs2(CHARSET_INFO *cs __attribute__((unused)) , + uint c __attribute__((unused))) { return 2; } -#include <m_string.h> -#include <stdarg.h> - -static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) +static int my_vsnprintf_ucs2(char *dst, size_t n, const char* fmt, va_list ap) { char *start=dst, *end=dst+n-1; for (; *fmt ; fmt++) @@ -440,10 +439,10 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(ap, char *); - uint plen; - uint left_len = (uint)(end-dst); + size_t plen; + size_t left_len = (size_t)(end-dst); if (!par) par = (char*)"(null)"; - plen = (uint) strlen(par); + plen= strlen(par); if (left_len <= plen*2) plen = left_len/2 - 1; @@ -460,7 +459,7 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) char nbuf[16]; char *pbuf=nbuf; - if ((uint) (end-dst) < 32) + if ((size_t) (end-dst) < 32) break; iarg = va_arg(ap, int); if (*fmt == 'd') @@ -485,11 +484,11 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) DBUG_ASSERT(dst <= end); *dst='\0'; /* End of errmessage */ - return (uint) (dst - start); + return (size_t) (dst - start); } -static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char* to, uint n, const char* fmt, ...) +static size_t my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), + char* to, size_t n, const char* fmt, ...) { va_list args; va_start(args,fmt); @@ -498,7 +497,7 @@ static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), long my_strntol_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -613,7 +612,7 @@ bs: ulong my_strntoul_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -722,7 +721,7 @@ bs: longlong my_strntoll_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -839,7 +838,7 @@ bs: ulonglong my_strntoull_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -947,7 +946,7 @@ bs: double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *nptr, uint length, + char *nptr, size_t length, char **endptr, int *err) { char buf[256]; @@ -974,13 +973,14 @@ double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), *endptr= b; res= my_strtod(buf, endptr, err); - *endptr= nptr + (uint) (*endptr- buf); + *endptr= nptr + (size_t) (*endptr- buf); return res; } ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, uint length, int unsign_fl, + const char *nptr, size_t length, + int unsign_fl, char **endptr, int *err) { char buf[256], *b= buf; @@ -1003,7 +1003,7 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), } res= my_strntoull10rnd_8bit(cs, buf, b - buf, unsign_fl, endptr, err); - *endptr= (char*) nptr + 2 * (uint) (*endptr- buf); + *endptr= (char*) nptr + 2 * (size_t) (*endptr- buf); return res; } @@ -1012,8 +1012,8 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), This is a fast version optimized for the case of radix 10 / -10 */ -int my_l10tostr_ucs2(CHARSET_INFO *cs, - char *dst, uint len, int radix, long int val) +size_t my_l10tostr_ucs2(CHARSET_INFO *cs, + char *dst, size_t len, int radix, long int val) { char buffer[66]; register char *p, *db, *de; @@ -1059,8 +1059,9 @@ int my_l10tostr_ucs2(CHARSET_INFO *cs, return (int) (dst-db); } -int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *dst, uint len, int radix, longlong val) + +size_t my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), + char *dst, size_t len, int radix, longlong val) { char buffer[65]; register char *p, *db, *de; @@ -1087,7 +1088,7 @@ int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), while ((ulonglong) val > (ulonglong) LONG_MAX) { - ulonglong quo=(ulonglong) val/(uint) 10; + ulonglong quo=(ulonglong) val/(size_t) 10; uint rem= (uint) (val- quo* (uint) 10); *--p = '0' + rem; val= quo; @@ -1137,7 +1138,7 @@ longlong my_strtoll10_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *nptr, char **endptr, int *error) { const char *s, *end, *start, *n_end, *true_end; - unsigned char c; + uchar c; unsigned long i, j, k; ulonglong li; int negative; @@ -1273,7 +1274,7 @@ end_i: return (negative ? ((longlong) -(long) i) : (longlong) i); end_i_and_j: - li= (ulonglong) i * lfactor[(uint) (s-start) / 2] + j; + li= (ulonglong) i * lfactor[(size_t) (s-start) / 2] + j; *endptr= (char*) s; return (negative ? -((longlong) li) : (longlong) li); @@ -1302,31 +1303,31 @@ no_conv: static -uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e) +size_t my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e) { - return (uint) (e-b)/2; + return (size_t) (e-b)/2; } static -uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b __attribute__((unused)), - const char *e __attribute__((unused)), - uint pos) +size_t my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused)), + size_t pos) { - uint string_length= (uint) (e - b); + size_t string_length= (size_t) (e - b); return pos > string_length ? string_length + 2 : pos * 2; } static -uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint nchars, int *error) +size_t my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t nchars, int *error) { /* Ensure string length is dividable with 2 */ - uint nbytes= ((uint) (e-b)) & ~(uint) 1; + size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1; *error= 0; nchars*= 2; return min(nbytes, nchars); @@ -1335,20 +1336,20 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), static void my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *s, uint l, int fill) + char *s, size_t l, int fill) { for ( ; l >= 2; s[0]= 0, s[1]= fill, s+=2, l-=2); } static -uint my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint length) +size_t my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, size_t length) { const char *end= ptr+length; while (end > ptr+1 && end[-1] == ' ' && end[-2] == '\0') end-=2; - return (uint) (end-ptr); + return (size_t) (end-ptr); } @@ -1377,8 +1378,8 @@ int my_wildcmp_ucs2_bin(CHARSET_INFO *cs, static int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -1410,13 +1411,13 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, } static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { const uchar *se, *te; - uint minlen; + size_t minlen; /* extra safety to make sure the lengths are even numbers */ slen= (slen >> 1) << 1; @@ -1459,17 +1460,17 @@ static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), static int my_strcasecmp_ucs2_bin(CHARSET_INFO *cs, const char *s, const char *t) { - uint s_len= (uint) strlen(s); - uint t_len= (uint) strlen(t); - uint len = (s_len > t_len) ? s_len : t_len; + size_t s_len= strlen(s); + size_t t_len= strlen(t); + size_t len = (s_len > t_len) ? s_len : t_len; return my_strncasecmp_ucs2(cs, s, t, len); } static -int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +size_t my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { if (dst != src) memcpy(dst,src,srclen= min(dstlen,srclen)); @@ -1481,7 +1482,7 @@ int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), static void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len,ulong *nr1, ulong *nr2) + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -1516,16 +1517,16 @@ void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), */ my_bool my_like_range_ucs2(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t *min_length,size_t *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for ( ; ptr + 1 < end && min_str + 1 < min_end && charlen > 0 ; ptr+=2, charlen--) @@ -1552,7 +1553,7 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do { @@ -1577,7 +1578,7 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, } } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str + 1 < min_end) { *min_str++ = *max_str++ = '\0'; @@ -1588,8 +1589,8 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, -ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *end, int sequence_type) +size_t my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) { const char *str0= str; end--; /* for easier loop condition, because of two bytes per character */ @@ -1602,7 +1603,7 @@ ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), if (str[0] != '\0' || str[1] != ' ') break; } - return (ulong) (str - str0); + return (size_t) (str - str0); default: return 0; } diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index d1e11071886..12d14667b28 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -184,7 +184,7 @@ static uchar NEAR sort_order_ujis[]= #define isujis_ss3(c) (((c)&0xff) == 0x8f) -static int ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return ((*(uchar*)(p)<0x80)? 0:\ @@ -194,7 +194,7 @@ static int ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)), 0); } -static int mbcharlen_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 1); } @@ -8252,9 +8252,9 @@ my_jisx0212_uni_onechar(int code){ */ static -uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), - const char *beg, const char *end, - uint pos, int *error) +size_t my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), + const char *beg, const char *end, + size_t pos, int *error) { const uchar *b= (uchar *) beg; @@ -8270,7 +8270,7 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), if (b >= (uchar *) end) /* need more bytes */ { *error= 1; - return (uint) (chbeg - beg); /* unexpected EOL */ + return (size_t) (chbeg - beg); /* unexpected EOL */ } if (ch == 0x8E) /* [x8E][xA0-xDF] */ @@ -8278,7 +8278,7 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), if (*b >= 0xA0 && *b <= 0xDF) continue; *error= 1; - return (uint) (chbeg - beg); /* invalid sequence */ + return (size_t) (chbeg - beg); /* invalid sequence */ } if (ch == 0x8F) /* [x8F][xA1-xFE][xA1-xFE] */ @@ -8287,7 +8287,7 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), if (b >= (uchar*) end) { *error= 1; - return (uint) (chbeg - beg); /* unexpected EOL */ + return (size_t) (chbeg - beg); /* unexpected EOL */ } } @@ -8295,19 +8295,19 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ continue; *error= 1; - return (uint) (chbeg - beg); /* invalid sequence */ + return (size_t) (chbeg - beg); /* invalid sequence */ } - return (uint) (b - (uchar *) beg); + return (size_t) (b - (uchar *) beg); } static -uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -8335,6 +8335,7 @@ uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), return clen; } + static int my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e) { @@ -8422,10 +8423,11 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e) return MY_CS_ILSEQ; } + static int -my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e) +my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, uchar *s, uchar *e) { - unsigned char c1; + uchar c1; int jp; if (s >= e) diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 16882e9b25d..851cef54b5b 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1722,7 +1722,7 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, my_wc_t s_wc, w_wc; int scan, plane; int (*mb_wc)(struct charset_info_st *, my_wc_t *, - const unsigned char *, const unsigned char *); + const uchar *, const uchar *); mb_wc= cs->cset->mb_wc; while (wildstr != wildend) @@ -1946,7 +1946,7 @@ static inline int bincmp(const uchar *s, const uchar *se, static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), my_wc_t * pwc, const uchar *s, const uchar *e) { - unsigned char c; + uchar c; if (s >= e) return MY_CS_TOOSMALL; @@ -1975,7 +1975,8 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), if (s+3 > e) /* We need 3 characters */ return MY_CS_TOOSMALL3; - if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0))) + if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && + (c >= 0xe1 || s[1] >= 0xa0))) return MY_CS_ILSEQ; *pwc = ((my_wc_t) (c & 0x0f) << 12) | @@ -2055,7 +2056,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), static int my_utf8_uni_no_range(CHARSET_INFO *cs __attribute__((unused)), my_wc_t * pwc, const uchar *s) { - unsigned char c; + uchar c; c= s[0]; if (c < 0x80) @@ -2093,8 +2094,8 @@ static int my_utf8_uni_no_range(CHARSET_INFO *cs __attribute__((unused)), } -static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) , - my_wc_t wc, uchar *r, uchar *e) +static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, uchar *r, uchar *e) { int count; @@ -2167,8 +2168,8 @@ static int my_uni_utf8_no_range(CHARSET_INFO *cs __attribute__((unused)), } -static uint my_caseup_utf8(CHARSET_INFO *cs, char *src, uint srclen, - char *dst, uint dstlen) +static size_t my_caseup_utf8(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst, size_t dstlen) { my_wc_t wc; int srcres, dstres; @@ -2186,10 +2187,11 @@ static uint my_caseup_utf8(CHARSET_INFO *cs, char *src, uint srclen, src+= srcres; dst+= dstres; } - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } -static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, uint slen, + +static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_wc_t wc; @@ -2217,7 +2219,7 @@ static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, uint slen, } -static uint my_caseup_str_utf8(CHARSET_INFO *cs, char *src) +static size_t my_caseup_str_utf8(CHARSET_INFO *cs, char *src) { my_wc_t wc; int srcres, dstres; @@ -2236,12 +2238,12 @@ static uint my_caseup_str_utf8(CHARSET_INFO *cs, char *src) dst+= dstres; } *dst= '\0'; - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } -static uint my_casedn_utf8(CHARSET_INFO *cs, char *src, uint srclen, - char *dst, uint dstlen) +static size_t my_casedn_utf8(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst, size_t dstlen) { my_wc_t wc; int srcres, dstres; @@ -2259,11 +2261,11 @@ static uint my_casedn_utf8(CHARSET_INFO *cs, char *src, uint srclen, src+= srcres; dst+= dstres; } - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } -static uint my_casedn_str_utf8(CHARSET_INFO *cs, char *src) +static size_t my_casedn_str_utf8(CHARSET_INFO *cs, char *src) { my_wc_t wc; int srcres, dstres; @@ -2298,13 +2300,13 @@ static uint my_casedn_str_utf8(CHARSET_INFO *cs, char *src) */ *dst= '\0'; - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } static int my_strnncoll_utf8(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -2375,8 +2377,8 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, */ static int my_strnncollsp_utf8(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { int s_res, t_res, res; @@ -2415,8 +2417,8 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, t+=t_res; } - slen= (uint) (se-s); - tlen= (uint) (te-t); + slen= (size_t) (se-s); + tlen= (size_t) (te-t); res= 0; if (slen != tlen) @@ -2564,14 +2566,16 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, static -uint my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), uint len) +size_t my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), + size_t len) { return (len * 2 + 2) / 3; } -static int my_strnxfrm_utf8(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) + +static size_t my_strnxfrm_utf8(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { my_wc_t wc; int res; @@ -2607,14 +2611,15 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, return dstlen; } -static int my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) +static uint my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) { my_wc_t wc; - int res=my_utf8_uni(cs,&wc, (const uchar*)b, (const uchar*)e); + int res= my_utf8_uni(cs,&wc, (const uchar*)b, (const uchar*)e); return (res>1) ? res : 0; } -static int my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)) , uint c) +static uint my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)), + uint c) { if (c < 0x80) return 1; @@ -2759,8 +2764,8 @@ CHARSET_INFO my_charset_utf8_bin= */ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -2805,8 +2810,8 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, } static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -4104,7 +4109,7 @@ my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_filename(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t wc, unsigned char *s, unsigned char *e) + my_wc_t wc, uchar *s, uchar *e) { int code; char hex[]= "0123456789abcdef"; @@ -4230,7 +4235,7 @@ static void test_mb(CHARSET_INFO *cs, uchar *s) { if (my_ismbhead_utf8(cs,*s)) { - int len=my_mbcharlen_utf8(cs,*s); + uint len=my_mbcharlen_utf8(cs,*s); while(len--) { printf("%c",*s); diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index d5be20f7b1b..b22b4364e8a 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -400,7 +400,7 @@ static uchar NEAR _sort_order_win1250ch2[] = { }; struct wordvalue { - const uchar * word; + const uchar *word; uchar pass1; uchar pass2; }; @@ -423,8 +423,8 @@ static struct wordvalue doubles[] = { if (value == 0xff) { \ int i; \ for (i = 0; i < (int) sizeof(doubles); i++) { \ - const uchar * patt = doubles[i].word; \ - const uchar * q = (const uchar *) p; \ + const uchar *patt = doubles[i].word; \ + const uchar *q = (const uchar *) p; \ while (*patt \ && !(IS_END(q, src, len)) \ && (*patt == *q)) { \ @@ -446,12 +446,12 @@ static struct wordvalue doubles[] = { #define IS_END(p, src, len) (((char *)p - (char *)src) >= (len)) static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2, + const uchar *s1, size_t len1, + const uchar *s2, size_t len2, my_bool s2_is_prefix) { int v1, v2; - const uchar * p1, * p2; + const uchar *p1, * p2; int pass1 = 0, pass2 = 0; int diff; @@ -477,8 +477,8 @@ static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_win1250ch(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -488,14 +488,14 @@ int my_strnncollsp_win1250ch(CHARSET_INFO * cs, } -static int my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { int value; - const uchar * p; + const uchar *p; int pass = 0; - uint totlen = 0; + size_t totlen = 0; p = src; do { @@ -615,11 +615,11 @@ static uchar NEAR like_range_prefix_max_win1250ch[]= static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length) + size_t *min_length, size_t *max_length) { int only_min_found= 1; @@ -643,7 +643,7 @@ my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), } if (cs->state & MY_CS_BINSORT) - *min_length= (uint) (min_str - min_org); + *min_length= (size_t) (min_str - min_org); else { /* 'a\0\0... is the smallest possible string */ diff --git a/strings/ctype.c b/strings/ctype.c index 8cb6b23c58e..de5625ef074 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -111,7 +111,7 @@ static struct my_cs_file_section_st sec[] = {0, NULL} }; -static struct my_cs_file_section_st * cs_file_sec(const char *attr, uint len) +static struct my_cs_file_section_st * cs_file_sec(const char *attr, size_t len) { struct my_cs_file_section_st *s; for (s=sec; s->str; s++) @@ -160,7 +160,7 @@ static int fill_uchar(uchar *a,uint size,const char *str, uint len) return 0; } -static int fill_uint16(uint16 *a,uint size,const char *str, uint len) +static int fill_uint16(uint16 *a,uint size,const char *str, size_t len) { uint i= 0; @@ -178,7 +178,7 @@ static int fill_uint16(uint16 *a,uint size,const char *str, uint len) } -static int cs_enter(MY_XML_PARSER *st,const char *attr, uint len) +static int cs_enter(MY_XML_PARSER *st,const char *attr, size_t len) { struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data; struct my_cs_file_section_st *s= cs_file_sec(attr,len); @@ -193,7 +193,7 @@ static int cs_enter(MY_XML_PARSER *st,const char *attr, uint len) } -static int cs_leave(MY_XML_PARSER *st,const char *attr, uint len) +static int cs_leave(MY_XML_PARSER *st,const char *attr, size_t len) { struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data; struct my_cs_file_section_st *s= cs_file_sec(attr,len); @@ -211,11 +211,12 @@ static int cs_leave(MY_XML_PARSER *st,const char *attr, uint len) } -static int cs_value(MY_XML_PARSER *st,const char *attr, uint len) +static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len) { struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data; struct my_cs_file_section_st *s; - int state= (int)((s=cs_file_sec(st->attr, (int) strlen(st->attr))) ? s->state : 0); + int state= (int)((s=cs_file_sec(st->attr, strlen(st->attr))) ? s->state : + 0); switch (state) { case _CS_ID: @@ -289,8 +290,8 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len) } -my_bool my_parse_charset_xml(const char *buf, uint len, - int (*add_collation)(CHARSET_INFO *cs)) +my_bool my_parse_charset_xml(const char *buf, size_t len, + int (*add_collation)(CHARSET_INFO *cs)) { MY_XML_PARSER p; struct my_cs_file_info i; diff --git a/strings/decimal.c b/strings/decimal.c index 0768c8cd4ca..ac82e7b16d6 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1190,7 +1190,7 @@ int decimal2longlong(decimal_t *from, longlong *to) 7E F2 04 37 2D FB 2D */ -int decimal2bin(decimal_t *from, char *to, int precision, int frac) +int decimal2bin(decimal_t *from, uchar *to, int precision, int frac) { dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1; int error=E_DEC_OK, intg=precision-frac, @@ -1206,7 +1206,7 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac) fsize1=frac1*sizeof(dec1)+dig2bytes[frac1x]; const int orig_isize0= isize0; const int orig_fsize0= fsize0; - char *orig_to= to; + uchar *orig_to= to; buf1= remove_leading_zeroes(from, &from_intg); @@ -1296,10 +1296,10 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac) } if (fsize0 > fsize1) { - char *to_end= orig_to + orig_fsize0 + orig_isize0; + uchar *to_end= orig_to + orig_fsize0 + orig_isize0; while (fsize0-- > fsize1 && to < to_end) - *to++=(uchar)mask; + *to++= (uchar)mask; } orig_to[0]^= 0x80; @@ -1325,19 +1325,19 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac) E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW */ -int bin2decimal(char *from, decimal_t *to, int precision, int scale) +int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale) { int error=E_DEC_OK, intg=precision-scale, intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1, intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1, intg1=intg0+(intg0x>0), frac1=frac0+(frac0x>0); dec1 *buf=to->buf, mask=(*from & 0x80) ? 0 : -1; - char *stop; - char *d_copy; + const uchar *stop; + uchar *d_copy; int bin_size= decimal_bin_size(precision, scale); sanity(to); - d_copy= (char *)my_alloca(bin_size); + d_copy= (uchar*) my_alloca(bin_size); memcpy(d_copy, from, bin_size); d_copy[0]^= 0x80; from= d_copy; diff --git a/strings/do_ctype.c b/strings/do_ctype.c index b8eca68debf..f33ddc5eb81 100644 --- a/strings/do_ctype.c +++ b/strings/do_ctype.c @@ -141,22 +141,22 @@ void init_case_convert() #endif #ifdef MSDOS - higher_pos= (uchar * ) "\217\216\231\232\220"; /* Extra chars to konv. */ - lower_pos= (uchar * ) "\206\204\224\201\202"; + higher_pos= (uchar *) "\217\216\231\232\220"; /* Extra chars to konv. */ + lower_pos= (uchar *) "\206\204\224\201\202"; #else #if defined(HPUX10) && ASCII_BITS_USED == 8 - higher_pos= (uchar * ) "\xd0\xd8\xda\xdb\xdc\xd3"; - lower_pos= (uchar * ) "\xd4\xcc\xce\xdf\xc9\xd7"; + higher_pos= (uchar *) "\xd0\xd8\xda\xdb\xdc\xd3"; + lower_pos= (uchar *) "\xd4\xcc\xce\xdf\xc9\xd7"; #else #ifdef USE_INTERNAL_CTYPE higher_pos=lower_pos= (uchar* ) ""; /* System converts chars */ #else #if defined(DEC_MULTINATIONAL_CHAR) || defined(HP_MULTINATIONAL_CHAR) - higher_pos= (uchar * ) "\305\304\326\311\334"; - lower_pos= (uchar * ) "\345\344\366\351\374"; + higher_pos= (uchar *) "\305\304\326\311\334"; + lower_pos= (uchar *) "\345\344\366\351\374"; #else - higher_pos= (uchar * ) "[]\\@^"; - lower_pos= (uchar * ) "{}|`~"; + higher_pos= (uchar *) "[]\\@^"; + lower_pos= (uchar *) "{}|`~"; #endif #endif /* USE_INTERNAL_CTYPE */ #endif /* HPUX10 */ diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 165d3e38095..4f73b1f8e71 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -86,7 +86,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error) { const char *s, *end, *start, *n_end, *true_end; char *dummy; - unsigned char c; + uchar c; unsigned long i, j, k; ulonglong li; int negative; diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 93d228a1954..a57cc5b5ebe 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -40,10 +40,11 @@ length of result string */ -int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) +size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) { char *start=to, *end=to+n-1; - uint length, width, pre_zero, have_long; + size_t length, width; + uint pre_zero, have_long; for (; *fmt ; fmt++) { @@ -58,7 +59,8 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) /* Read max fill size (only used with %d and %u) */ if (*fmt == '-') fmt++; - length= width= pre_zero= have_long= 0; + length= width= 0; + pre_zero= have_long= 0; if (*fmt == '*') { fmt++; @@ -93,10 +95,9 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(ap, char *); - uint plen,left_len = (uint)(end-to)+1; + size_t plen,left_len = (size_t) (end - to) + 1; if (!par) par = (char*)"(null)"; - plen = (uint) strlen(par); - set_if_smaller(plen,width); + plen= (uint) strnlen(par, width); if (left_len <= plen) plen = left_len - 1; to=strnmov(to,par,plen); @@ -115,11 +116,11 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x') /* Integer parameter */ { register long larg; - uint res_length, to_length; + size_t res_length, to_length; char *store_start= to, *store_end; char buff[32]; - if ((to_length= (uint) (end-to)) < 16 || length) + if ((to_length= (size_t) (end-to)) < 16 || length) store_start= buff; if (have_long) larg = va_arg(ap, long); @@ -135,7 +136,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) store_end= int10_to_str(larg, store_start, 10); else store_end= int2str(larg, store_start, 16, 0); - if ((res_length= (uint) (store_end - store_start)) > to_length) + if ((res_length= (size_t) (store_end - store_start)) > to_length) break; /* num doesn't fit in output */ /* If %#d syntax was used, we have to pre-zero/pre-space the string */ if (store_start == buff) @@ -143,7 +144,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) length= min(length, to_length); if (res_length < length) { - uint diff= (length- res_length); + size_t diff= (length- res_length); bfill(to, diff, pre_zero ? '0' : ' '); to+= diff; } @@ -169,10 +170,11 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) } DBUG_ASSERT(to <= end); *to='\0'; /* End of errmessage */ - return (uint) (to - start); + return (size_t) (to - start); } -int my_snprintf(char* to, size_t n, const char* fmt, ...) + +size_t my_snprintf(char* to, size_t n, const char* fmt, ...) { int result; va_list args; diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c index 98118015456..fb1e0c5a090 100644 --- a/strings/r_strinstr.c +++ b/strings/r_strinstr.c @@ -25,14 +25,14 @@ #include <my_global.h> #include "m_string.h" -uint r_strinstr(reg1 my_string str,int from, reg4 my_string search) +size_t r_strinstr(reg1 const char * str, size_t from, reg4 const char * search) { - reg2 my_string i, j; - uint len = (uint) strlen(search); + reg2 const char *i, *j; + size_t len = strlen(search); /* pointer to the last char of buff */ - my_string start = str + from - 1; + const char * start = str + from - 1; /* pointer to the last char of search */ - my_string search_end = search + len - 1; + const char * search_end = search + len - 1; skip: while (start >= str) /* Cant be != because the first char */ @@ -43,7 +43,7 @@ uint r_strinstr(reg1 my_string str,int from, reg4 my_string search) while (j >= search && start > str) if (*i-- != *j--) goto skip; - return (uint) ((start - len) - str + 3); + return (size_t) ((start - len) - str + 3); } } return (0); diff --git a/strings/str_test.c b/strings/str_test.c index 7863dce8688..3ddfca39419 100644 --- a/strings/str_test.c +++ b/strings/str_test.c @@ -29,12 +29,12 @@ #define T_PREFILL '1' static char from_buff[100],to_buff[100]; -static my_string from,to; +static char * from, *to; static int errors,tests; static int test_strarg(const char *name,...); static void init_strings (void); /* Init from and to */ void test_arg (const char *message,long func_value,long value); -int compare_buff(const char *message,my_string b1,my_string b2,int length, +int compare_buff(const char *message,char * b1,char * b2,int length, pchar fill, pchar prefill); static int my_test(int a) @@ -228,7 +228,7 @@ static int test_strarg(const char *message,...) /* test if function made right value */ -int compare_buff(const char *message, my_string b1, my_string b2, int length, +int compare_buff(const char *message, char * b1, char * b2, int length, pchar fill, pchar prefill) { int i,error=0; diff --git a/strings/strappend.c b/strings/strappend.c index 3a5da658709..bb926f74665 100644 --- a/strings/strappend.c +++ b/strings/strappend.c @@ -27,7 +27,7 @@ #include "m_string.h" -void strappend(register char *s, uint len, pchar fill) +void strappend(register char *s, size_t len, pchar fill) { register char *endpos; diff --git a/strings/strcont.c b/strings/strcont.c index d57af77804d..5a518a3550f 100644 --- a/strings/strcont.c +++ b/strings/strcont.c @@ -27,9 +27,9 @@ #include <my_global.h> #include "m_string.h" -my_string strcont(reg1 const char *str,reg2 const char *set) +char * strcont(reg1 const char *str,reg2 const char *set) { - reg3 my_string start = (my_string) set; + reg3 char * start = (char *) set; while (*str) { diff --git a/strings/strfill.c b/strings/strfill.c index 7d3f25e3ff4..4b1fe67b206 100644 --- a/strings/strfill.c +++ b/strings/strfill.c @@ -26,7 +26,7 @@ #include <my_global.h> #include "m_string.h" -my_string strfill(my_string s,uint len,pchar fill) +char * strfill(char *s, size_t len, pchar fill) { while (len--) *s++ = fill; *(s) = '\0'; diff --git a/strings/strinstr.c b/strings/strinstr.c index 10f83a54c29..dce498d61e8 100644 --- a/strings/strinstr.c +++ b/strings/strinstr.c @@ -28,20 +28,20 @@ #include <my_global.h> #include "m_string.h" -uint strinstr(reg1 const char *str,reg4 const char *search) +size_t strinstr(reg1 const char *str,reg4 const char *search) { - reg2 my_string i,j; - my_string start = (my_string) str; + reg2 const char *i, *j; + const char *start= str; skip: while (*str != '\0') { if (*str++ == *search) { - i=(my_string) str; j= (my_string) search+1; + i= str; j= search+1; while (*j) if (*i++ != *j++) goto skip; - return ((uint) (str - start)); + return ((size_t) (str - start)); } } return (0); diff --git a/strings/strlen.c b/strings/strlen.c index b3c901739b1..1469dd096ee 100644 --- a/strings/strlen.c +++ b/strings/strlen.c @@ -31,7 +31,7 @@ #if VaxAsm -size_s strlen(char *s) +size_t strlen(char *s) { asm("locc $0,$65535,*4(ap)"); asm("subl3 r0,$65535,r0"); @@ -40,7 +40,7 @@ size_s strlen(char *s) #else #if defined(MC68000) && defined(DS90) -size_s strlen(char *s) +size_t strlen(char *s) { asm(" movl 4(a7),a0 "); asm(" movl a0,a1 "); @@ -52,13 +52,13 @@ asm(" subql #1,d0 "); } #else -size_s strlen(register char *s) +size_t strlen(register char *s) { register char *startpos; startpos = s; while (*s++); - return ((size_s) (s-startpos-1)); + return ((size_t) (s-startpos-1)); } #endif diff --git a/strings/strmake.c b/strings/strmake.c index 5ca4688de46..0d26e1b61a9 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -42,7 +42,7 @@ char *strmake(char *dst,const char *src,uint length) #define strmake strmake_overlapp /* Use orginal for overlapping str */ #endif -char *strmake(register char *dst, register const char *src, uint length) +char *strmake(register char *dst, register const char *src, size_t length) { while (length--) if (! (*dst++ = *src++)) diff --git a/strings/strnlen.c b/strings/strnlen.c index 11ecf718746..826cd5ae5dd 100644 --- a/strings/strnlen.c +++ b/strings/strnlen.c @@ -25,10 +25,10 @@ #ifndef HAVE_STRNLEN -uint strnlen(register const char *s, register uint maxlen) +size_t strnlen(register const char *s, register size_t maxlen) { const char *end= (const char *)memchr(s, '\0', maxlen); - return end ? (uint) (end - s) : maxlen; + return end ? (size_t) (end - s) : maxlen; } #endif diff --git a/strings/strnmov.c b/strings/strnmov.c index b2099452d98..7e26877637b 100644 --- a/strings/strnmov.c +++ b/strings/strnmov.c @@ -23,7 +23,7 @@ #include <my_global.h> #include "m_string.h" -char *strnmov(register char *dst, register const char *src, uint n) +char *strnmov(register char *dst, register const char *src, size_t n) { while (n-- != 0) { if (!(*dst++ = *src++)) { diff --git a/strings/strto.c b/strings/strto.c index 934b5d88e90..fcb0d800b81 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -88,7 +88,7 @@ function (const char *nptr,char **endptr,int base) register unsigned int cutlim; register ulongtype i; register const char *s; - register unsigned char c; + register uchar c; const char *save; int overflow; diff --git a/strings/strtod.c b/strings/strtod.c index 5fe59d10bd2..0cec86f832d 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -83,7 +83,8 @@ const double log_10[] = { double my_strtod(const char *str, char **end_ptr, int *error) { double result= 0.0; - uint negative= 0, ndigits, dec_digits= 0, neg_exp= 0; + uint negative= 0, neg_exp= 0; + size_t ndigits, dec_digits= 0; int exponent= 0, digits_after_dec_point= 0, tmp_exp, step; const char *old_str, *end= *end_ptr, *start_of_number; char next_char; @@ -127,7 +128,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) } start_of_number= 0; /* Found digit */ } - ndigits= (uint) (str-old_str); + ndigits= (size_t) (str-old_str); if (next_char == '.' && str < end-1) { @@ -151,7 +152,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) } } /* If we found just '+.' or '.' then point at first character */ - if (!(dec_digits= (uint) (str-old_str)) && start_of_number) + if (!(dec_digits= (size_t) (str-old_str)) && start_of_number) str= start_of_number; /* Point at '+' or '.' */ } if ((next_char == 'e' || next_char == 'E') && diff --git a/strings/strxnmov.c b/strings/strxnmov.c index 377133de69e..16469be6e45 100644 --- a/strings/strxnmov.c +++ b/strings/strxnmov.c @@ -39,7 +39,7 @@ #include "m_string.h" #include <stdarg.h> -char *strxnmov(char *dst,uint len, const char *src, ...) +char *strxnmov(char *dst, size_t len, const char *src, ...) { va_list pvar; char *end_of_dst=dst+len; diff --git a/strings/xml.c b/strings/xml.c index fc6c61c8a3c..5c62a8e8603 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -110,7 +110,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) { int lex; - for( ; ( p->cur < p->end) && my_xml_is_space(p->cur[0]) ; p->cur++); + for (; ( p->cur < p->end) && my_xml_is_space(p->cur[0]) ; p->cur++); if (p->cur >= p->end) { @@ -125,7 +125,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) if ((p->end - p->cur > 3) && !bcmp(p->cur,"<!--",4)) { - for( ; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++) + for (; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++) {} if (!bcmp(p->cur, "-->", 3)) p->cur+=3; @@ -155,7 +155,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) else if ( (p->cur[0] == '"') || (p->cur[0] == '\'') ) { p->cur++; - for( ; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++) + for (; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++) {} a->end=p->cur; if (a->beg[0] == p->cur[0])p->cur++; @@ -185,15 +185,15 @@ ret: } -static int my_xml_value(MY_XML_PARSER *st, const char *str, uint len) +static int my_xml_value(MY_XML_PARSER *st, const char *str, size_t len) { return (st->value) ? (st->value)(st,str,len) : MY_XML_OK; } -static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len) +static int my_xml_enter(MY_XML_PARSER *st, const char *str, size_t len) { - if ((uint) (st->attrend-st->attr+len+1) > sizeof(st->attr)) + if ((size_t) (st->attrend-st->attr+len+1) > sizeof(st->attr)) { sprintf(st->errstr,"To deep XML"); return MY_XML_ERROR; @@ -213,7 +213,7 @@ static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len) } -static void mstr(char *s,const char *src,uint l1, uint l2) +static void mstr(char *s,const char *src,size_t l1, size_t l2) { l1 = l1<l2 ? l1 : l2; memcpy(s,src,l1); @@ -221,17 +221,17 @@ static void mstr(char *s,const char *src,uint l1, uint l2) } -static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) +static int my_xml_leave(MY_XML_PARSER *p, const char *str, size_t slen) { char *e; - uint glen; + size_t glen; char s[32]; char g[32]; int rc; /* Find previous '/' or beginning */ - for( e=p->attrend; (e>p->attr) && (e[0] != '/') ; e--); - glen = (uint) ((e[0] == '/') ? (p->attrend-e-1) : p->attrend-e); + for (e=p->attrend; (e>p->attr) && (e[0] != '/') ; e--); + glen = (size_t) ((e[0] == '/') ? (p->attrend-e-1) : p->attrend-e); if (str && (slen != glen)) { @@ -249,7 +249,8 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) if (p->flags & MY_XML_FLAG_RELATIVE_NAMES) rc= p->leave_xml ? p->leave_xml(p, str, slen) : MY_XML_OK; else - rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK; + rc= (p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : + MY_XML_OK); *e='\0'; p->attrend=e; @@ -258,7 +259,7 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) } -int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) +int my_xml_parse(MY_XML_PARSER *p,const char *str, size_t len) { p->attrend=p->attr; p->beg=str; @@ -283,7 +284,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) { a.beg+= 9; a.end-= 3; - my_xml_value(p, a.beg, (uint) (a.end-a.beg)); + my_xml_value(p, a.beg, (size_t) (a.end-a.beg)); continue; } @@ -296,7 +297,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) sprintf(p->errstr,"%s unexpected (ident wanted)",lex2str(lex)); return MY_XML_ERROR; } - if (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg))) + if (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg))) return MY_XML_ERROR; lex=my_xml_scan(p,&a); goto gt; @@ -316,7 +317,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) if (MY_XML_IDENT == lex) { p->current_node_type= MY_XML_NODE_TAG; - if (MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) + if (MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) return MY_XML_ERROR; } else @@ -336,9 +337,9 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) if ( (lex == MY_XML_IDENT) || (lex == MY_XML_STRING) ) { p->current_node_type= MY_XML_NODE_ATTR; - if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) || - (MY_XML_OK != my_xml_value(p,b.beg,(uint) (b.end-b.beg))) || - (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))) + if ((MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) || + (MY_XML_OK != my_xml_value(p,b.beg,(size_t) (b.end-b.beg))) || + (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg)))) return MY_XML_ERROR; } else @@ -351,8 +352,8 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) else if ((MY_XML_STRING == lex) || (MY_XML_IDENT == lex)) { p->current_node_type= MY_XML_NODE_ATTR; - if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) || - (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))) + if ((MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) || + (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg)))) return MY_XML_ERROR; } else @@ -401,7 +402,7 @@ gt: my_xml_norm_text(&a); if (a.beg != a.end) { - my_xml_value(p,a.beg,(uint) (a.end-a.beg)); + my_xml_value(p,a.beg,(size_t) (a.end-a.beg)); } } } @@ -428,14 +429,14 @@ void my_xml_parser_free(MY_XML_PARSER *p __attribute__((unused))) void my_xml_set_value_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, - uint l)) + size_t l)) { p->value=action; } void my_xml_set_enter_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, - uint l)) + size_t l)) { p->enter=action; } @@ -443,7 +444,7 @@ void my_xml_set_enter_handler(MY_XML_PARSER *p, void my_xml_set_leave_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, - uint l)) + size_t l)) { p->leave_xml=action; } @@ -461,7 +462,7 @@ const char *my_xml_error_string(MY_XML_PARSER *p) } -uint my_xml_error_pos(MY_XML_PARSER *p) +size_t my_xml_error_pos(MY_XML_PARSER *p) { const char *beg=p->beg; const char *s; @@ -470,7 +471,7 @@ uint my_xml_error_pos(MY_XML_PARSER *p) if (s[0] == '\n') beg=s; } - return (uint) (p->cur-beg); + return (size_t) (p->cur-beg); } uint my_xml_error_lineno(MY_XML_PARSER *p) |