diff options
author | unknown <monty@mysql.com> | 2004-02-16 10:03:25 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-02-16 10:03:25 +0200 |
commit | a07e48eca04b1564da9868f229ba5d958994db69 (patch) | |
tree | 44dc172194086edaeef7da9c9ed059171579a886 /strings | |
parent | 5b2c3126277a8eedab5bcc8a9b0ce7386ccc3dbe (diff) | |
download | mariadb-git-a07e48eca04b1564da9868f229ba5d958994db69.tar.gz |
After merge fixes
Added more DBUG statements
Ensure that we are comparing end space with BINARY strings
Use 'any_db' instead of '' to mean any database. (For HANDLER command)
Only strip ' ' when comparing CHAR, not other space-like characters (like \t)
BitKeeper/deleted/.del-ctype_tis620.result-old~3578ceb0b8284685:
Delete: mysql-test/r/ctype_tis620.result-old
BitKeeper/deleted/.del-ctype_tis620.test-old~ffb1bbd2935d1aba:
Delete: mysql-test/t/ctype_tis620.test-old
client/mysqlbinlog.cc:
Added DBUG statements
Added call of my_end() to free all used memory on exit
heap/hp_info.c:
After merge fixes
heap/hp_open.c:
After merge fixes
include/heap.h:
After merge fixes
include/m_ctype.h:
Use pchar instead of 'int' for character parameters.
Added 'my_binary_compare()'
include/m_string.h:
Fixed wrong define
innobase/ibuf/ibuf0ibuf.c:
After merge fixes
innobase/srv/srv0start.c:
After merge fixes
mysql-test/r/alter_table.result:
Fixed results after merge
mysql-test/r/auto_increment.result:
Fixed results after merge
mysql-test/r/bdb.result:
Fixed results after merge
mysql-test/r/binary.result:
Fixed results after merge
mysql-test/r/create.result:
Fixed results after merge
mysql-test/r/ctype_mb.result:
Fixed results after merge
mysql-test/r/ctype_tis620.result:
Fixed results after merge
mysql-test/r/ctype_utf8.result:
Fixed results after merge
mysql-test/r/delete.result:
Fixed results after merge
mysql-test/r/func_compress.result:
Fixed results after merge
mysql-test/r/func_gconcat.result:
Fixed results after merge
mysql-test/r/func_group.result:
Fixed results after merge
mysql-test/r/func_str.result:
Fixed results after merge
mysql-test/r/innodb.result:
Fixed results after merge
mysql-test/r/insert.result:
Fixed results after merge
mysql-test/r/insert_select.result:
Fixed results after merge
mysql-test/r/key.result:
Fixed results after merge
mysql-test/r/loaddata.result:
Fixed results after merge
mysql-test/r/lock.result:
Fixed results after merge
mysql-test/r/myisam.result:
Fixed results after merge
mysql-test/r/null.result:
Fixed results after merge
mysql-test/r/null_key.result:
Fixed results after merge
mysql-test/r/order_by.result:
Fixed results after merge
mysql-test/r/query_cache.result:
Fixed results after merge
mysql-test/r/range.result:
Fixed results after merge
mysql-test/r/rpl_multi_delete.result:
Fixed results after merge
mysql-test/r/rpl_until.result:
Fixed results after merge
mysql-test/r/subselect.result:
Fixed results after merge
mysql-test/r/subselect_innodb.result:
Fixed results after merge
mysql-test/r/type_blob.result:
Fixed results after merge
mysql-test/r/type_datetime.result:
Fixed results after merge
mysql-test/r/type_decimal.result:
Fixed results after merge
mysql-test/r/type_enum.result:
Fixed results after merge
mysql-test/r/type_float.result:
Fixed results after merge
mysql-test/r/type_ranges.result:
Fixed results after merge
mysql-test/r/type_time.result:
Fixed results after merge
mysql-test/r/type_timestamp.result:
Fixed results after merge
mysql-test/r/type_uint.result:
Fixed results after merge
mysql-test/r/type_year.result:
Fixed results after merge
mysql-test/r/variables.result:
Fixed results after merge
mysql-test/r/warnings.result:
Fixed results after merge
mysql-test/t/case.test:
Fixed shifted error messages
mysql-test/t/create.test:
Fixed shifted error messages
mysql-test/t/ctype_collate.test:
Fixed shifted error messages
mysql-test/t/ctype_tis620.test:
Merge with 4.0 ctype_tis620 test
mysql-test/t/delete.test:
Fixed shifted error messages
mysql-test/t/derived.test:
Fixed shifted error messages
mysql-test/t/fulltext.test:
Fixed shifted error messages
mysql-test/t/func_in.test:
Fixed shifted error messages
mysql-test/t/func_str.test:
Fixed shifted error messages
mysql-test/t/func_test.test:
Fixed shifted error messages
mysql-test/t/grant.test:
Fixed shifted error messages
mysql-test/t/innodb.test:
Change to 4.1 syntax
mysql-test/t/key_cache.test:
Fixed shifted error messages
mysql-test/t/myisam.test:
New test of blob and end space
mysql-test/t/row.test:
Fixed shifted error messages
mysql-test/t/rpl_until.test:
Fixed shifted error messages
mysql-test/t/subselect.test:
Fixed shifted error messages
mysql-test/t/subselect_innodb.test:
Fix test to take into account foreign key constraints
mysql-test/t/union.test:
Fixed shifted error messages
mysql-test/t/user_var.test:
Fixed shifted error messages
mysql-test/t/variables.test:
Fixed shifted error messages
mysys/my_handler.c:
Merge with 4.0 code
sql/ha_heap.cc:
After merge fixes
sql/handler.cc:
After merge fixes
sql/item.cc:
After merge fixes
sql/item_cmpfunc.cc:
Ensure that we are comparing end space with BINARY strings
sql/item_cmpfunc.h:
Ensure that we are comparing end space with BINARY strings
sql/log_event.cc:
More DBUG statements
Ensure that we use all options to LOAD DATA in replication
sql/opt_range.cc:
After merge fixes
sql/sql_db.cc:
After merge fixes
sql/sql_handler.cc:
After merge fixes
Use 'any_db' instead of '' to mean 'no database comparison'
sql/sql_parse.cc:
After merge fixes
sql/sql_select.cc:
After merge fixes
Added function comment for setup_group()
sql/sql_string.cc:
Added stringcmp() for binary comparison.
Added function comments for sortcmp() and stringcmp()
sql/sql_string.h:
Added stringcmp()
sql/sql_table.cc:
After merge fixes
sql/sql_update.cc:
After merge fixes
sql/sql_yacc.yy:
Use 'any_db' instead of '' to mean any database. Using "" causes a 'wrong db name' error.
strings/ctype-big5.c:
Strip only end space, not other space characters.
strings/ctype-bin.c:
Removed some not needed functions.
Added function comments
Don't remove end space in comparisons
Change my_wildcmp_bin() to be 'identical' with other similar code
strings/ctype-czech.c:
Strip only end space, not other space characters.
strings/ctype-gbk.c:
Strip only end space, not other space characters.
strings/ctype-latin1.c:
Strip only end space, not other space characters.
strings/ctype-mb.c:
Strip only end space, not other space characters.
strings/ctype-simple.c:
Strip only end space, not other space characters.
strings/ctype-sjis.c:
Strip only end space, not other space characters.
strings/ctype-tis620.c:
Added usage of my_instr_simple. This needs to be cleaned up!
strings/ctype-utf8.c:
Strip only end space, not other space characters.
strings/ctype-win1250ch.c:
Strip only end space, not other space characters.
Fixed indentation
strings/strto.c:
Code cleanup
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-big5.c | 12 | ||||
-rw-r--r-- | strings/ctype-bin.c | 154 | ||||
-rw-r--r-- | strings/ctype-czech.c | 13 | ||||
-rw-r--r-- | strings/ctype-gbk.c | 6 | ||||
-rw-r--r-- | strings/ctype-latin1.c | 4 | ||||
-rw-r--r-- | strings/ctype-mb.c | 10 | ||||
-rw-r--r-- | strings/ctype-simple.c | 65 | ||||
-rw-r--r-- | strings/ctype-sjis.c | 12 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 9 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 4 | ||||
-rw-r--r-- | strings/ctype-win1250ch.c | 254 | ||||
-rw-r--r-- | strings/strto.c | 2 |
12 files changed, 254 insertions, 291 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 574156a99ed..1b0a235ed57 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -247,8 +247,8 @@ int my_strnncollsp_big5(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_big5(cs,s,slen,t,tlen); } @@ -343,10 +343,10 @@ 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, - int escape, int w_one, int w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + 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 *end=ptr+ptr_length; char *min_org=min_str; diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index fc22938d46e..35382b05c88 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -67,6 +67,28 @@ static uchar bin_char_array[] = }; + +/* + Compare two strings. Result is sign(first_argument - second_argument) + + SYNOPSIS + my_strnncoll_binary() + cs Chararacter set + s String to compare + slen Length of 's' + t String to compare + tlen Length of 't' + + NOTE + This is used also when comparing with end space removal, as end space + is significant for binary strings + + RETURN + < 0 s < t + 0 s == t + > 0 s > t +*/ + static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), const uchar *s, uint slen, const uchar *t, uint tlen) @@ -75,59 +97,39 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), return cmp ? cmp : (int) (slen - tlen); } -static int my_strnncollsp_binary(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) -{ - int len, cmp; - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); +/* This function is used for all conversion functions */ - len = ( slen > tlen ) ? tlen : slen; - - cmp= memcmp(s,t,len); - return cmp ? cmp : (int) (slen - tlen); -} - -static void my_caseup_str_bin(CHARSET_INFO *cs __attribute__((unused)), - char *str __attribute__((unused))) +static void my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), + char *str __attribute__((unused))) { } -static void my_casedn_str_bin(CHARSET_INFO * cs __attribute__((unused)), - char *str __attribute__((unused))) +static void my_case_bin(CHARSET_INFO *cs __attribute__((unused)), + char *str __attribute__((unused)), + uint length __attribute__((unused))) { } -static void my_caseup_bin(CHARSET_INFO * cs __attribute__((unused)), - char *str __attribute__((unused)), - uint length __attribute__((unused))) -{ -} - -static void my_casedn_bin(CHARSET_INFO * cs __attribute__((unused)), - char *str __attribute__((unused)), - uint length __attribute__((unused))) -{ -} static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)), - const char *s, const char *t) + const char *s, const char *t) { return strcmp(s,t); } + int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), - uint c __attribute__((unused))) + uint c __attribute__((unused))) { return 1; } + 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))) + my_wc_t *wc, + const unsigned char *str, + const unsigned char *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOFEW(0); @@ -136,10 +138,11 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), return 1; } + static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t wc, - unsigned char *s, - unsigned char *e __attribute__((unused))) + my_wc_t wc, + unsigned char *s, + unsigned char *e __attribute__((unused))) { if (s >= e) return MY_CS_TOOSMALL; @@ -169,12 +172,21 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), } +/* + The following defines is here to keep the following code identical to + the one in ctype-simple.c +*/ + +#define likeconv(s,A) (A) +#define INC_PTR(cs,A,B) (A)++ + + static int my_wildcmp_bin(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend, int escape, int w_one, int w_many) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ while (wildstr != wildend) { @@ -182,31 +194,26 @@ static int my_wildcmp_bin(CHARSET_INFO *cs, { if (*wildstr == escape && wildstr+1 != wildend) wildstr++; - if (str == str_end || *wildstr++ != *str++) - { - return(1); - } + if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++)) + return(1); /* No match */ if (wildstr == wildend) - { - return(str != str_end); /* Match if both are at end */ - } - result=1; /* Found an anchor char */ + return(str != str_end); /* Match if both are at end */ + result=1; /* Found an anchor char */ } if (*wildstr == w_one) { do { - if (str == str_end) /* Skip one char if possible */ + if (str == str_end) /* Skip one char if possible */ return(result); - str++; - } while (*++wildstr == w_one && wildstr != wildend); + INC_PTR(cs,str,str_end); + } while (++wildstr < wildend && *wildstr == w_one); if (wildstr == wildend) break; } if (*wildstr == w_many) - { /* Found w_many */ - char cmp; - + { /* Found w_many */ + uchar cmp; wildstr++; /* Remove any '%' and '_' from the wild search string */ for (; wildstr != wildend ; wildstr++) @@ -216,40 +223,33 @@ static int my_wildcmp_bin(CHARSET_INFO *cs, if (*wildstr == w_one) { if (str == str_end) - { return(-1); - } - str++; + INC_PTR(cs,str,str_end); continue; } - break; /* Not a wild character */ + break; /* Not a wild character */ } if (wildstr == wildend) - { - return(0); /* Ok if w_many is last */ - } + return(0); /* match if w_many is last */ if (str == str_end) - { return(-1); - } if ((cmp= *wildstr) == escape && wildstr+1 != wildend) cmp= *++wildstr; - wildstr++; /* This is compared trough cmp */ + + INC_PTR(cs,wildstr,wildend); /* This is compared through cmp */ + cmp=likeconv(cs,cmp); do { - while (str != str_end && *str != cmp) + while (str != str_end && (uchar) likeconv(cs,*str) != cmp) str++; if (str++ == str_end) - { return(-1); - } { - int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many); if (tmp <= 0) - { return(tmp); - } } } while (str != str_end && wildstr[0] != w_many); return(-1); @@ -258,6 +258,7 @@ static int my_wildcmp_bin(CHARSET_INFO *cs, return(str != str_end ? 1 : 0); } + static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), uchar * dest, uint len, const uchar *src, @@ -268,11 +269,12 @@ static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), return len; } + static uint my_instr_bin(CHARSET_INFO *cs __attribute__((unused)), - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch) + const char *b, uint b_length, + const char *s, uint s_length, + my_match_t *match, uint nmatch) { register const uchar *str, *search, *end, *search_end; @@ -332,7 +334,7 @@ skip: MY_COLLATION_HANDLER my_collation_8bit_bin_handler = { my_strnncoll_binary, - my_strnncollsp_binary, + my_strnncoll_binary, my_strnxfrm_bin, my_like_range_simple, my_wildcmp_bin, @@ -341,6 +343,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler = my_hash_sort_bin }; + static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* ismbchar */ @@ -351,10 +354,10 @@ static MY_CHARSET_HANDLER my_charset_handler= my_lengthsp_8bit, my_mb_wc_bin, my_wc_mb_bin, - my_caseup_str_bin, - my_casedn_str_bin, - my_caseup_bin, - my_casedn_bin, + 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, @@ -367,6 +370,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_scan_8bit }; + CHARSET_INFO my_charset_bin = { 63,0,0, /* number */ diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 1a07a5eba7e..8aea7358a9c 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -379,10 +379,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, - int escape, int w_one, int w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + 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) { #ifdef EXAMPLE uchar value; @@ -599,8 +600,8 @@ int my_strnncollsp_czech(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_czech(cs,s,slen,t,tlen); } diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 9e71a18e531..2ebf145f840 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2613,8 +2613,8 @@ int my_strnncollsp_gbk(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_gbk(cs,s,slen,t,tlen); } @@ -2663,7 +2663,7 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, + pbool escape, pbool w_one, pbool w_many, uint res_length, char *min_str,char *max_str, uint *min_length,uint *max_length) { diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 933737b5f61..00d49f40ee4 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -360,8 +360,8 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_latin1_de(cs,s,slen,t,tlen); } diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 377bf311d38..323662f023c 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -354,14 +354,14 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), return cmp ? cmp : (int) (slen - tlen); } -static int my_strnncollsp_mb_bin(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) +static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const uchar *s, uint slen, + const uchar *t, uint tlen) { int len, cmp; - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); len = ( slen > tlen ) ? tlen : slen; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 233251e16a8..ed042c7de1a 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -66,8 +66,8 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *s, uint slen, uchar *map= cs->sort_order; int len; - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); len = ( slen > tlen ) ? tlen : slen; @@ -186,9 +186,9 @@ void my_hash_sort_simple(CHARSET_INFO *cs, } -long my_strntol_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, - char **endptr, int *err) +long my_strntol_8bit(CHARSET_INFO *cs, + const char *nptr, uint l, int base, + char **endptr, int *err) { int negative; register ulong cutoff; @@ -309,9 +309,9 @@ noconv: } -ulong my_strntoul_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, - char **endptr, int *err) +ulong my_strntoul_8bit(CHARSET_INFO *cs, + const char *nptr, uint l, int base, + char **endptr, int *err) { int negative; register ulong cutoff; @@ -423,9 +423,9 @@ noconv: } -longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, uint l, int base, - char **endptr,int *err) +longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *nptr, uint l, int base, + char **endptr,int *err) { int negative; register ulonglong cutoff; @@ -825,7 +825,7 @@ cnv: #define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)] #endif -#define INC_PTR(cs,A,B) A++ +#define INC_PTR(cs,A,B) (A)++ int my_wildcmp_8bit(CHARSET_INFO *cs, @@ -833,7 +833,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, const char *wildstr,const char *wildend, int escape, int w_one, int w_many) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ while (wildstr != wildend) { @@ -845,7 +845,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++)) return(1); /* No match */ if (wildstr == wildend) - return (str != str_end); /* Match if both are at end */ + return(str != str_end); /* Match if both are at end */ result=1; /* Found an anchor char */ } if (*wildstr == w_one) @@ -853,7 +853,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, do { if (str == str_end) /* Skip one char if possible */ - return (result); + return(result); INC_PTR(cs,str,str_end); } while (++wildstr < wildend && *wildstr == w_one); if (wildstr == wildend) @@ -872,7 +872,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, if (*wildstr == w_one) { if (str == str_end) - return (-1); + return(-1); INC_PTR(cs,str,str_end); continue; } @@ -881,28 +881,29 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, if (wildstr == wildend) return(0); /* Ok if w_many is last */ if (str == str_end) - return -1; + return(-1); if ((cmp= *wildstr) == escape && wildstr+1 != wildend) cmp= *++wildstr; - INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */ - cmp=likeconv(cs,cmp); + INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */ + cmp=likeconv(cs,cmp); do { - while (str != str_end && likeconv(cs,*str) != cmp) - str++; - if (str++ == str_end) return (-1); + while (str != str_end && (uchar) likeconv(cs,*str) != cmp) + str++; + if (str++ == str_end) return(-1); { - int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many); if (tmp <= 0) - return (tmp); + return(tmp); } } while (str != str_end && wildstr[0] != w_many); return(-1); } } - return (str != str_end ? 1 : 0); + return(str != str_end ? 1 : 0); } @@ -924,11 +925,11 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, */ my_bool my_like_range_simple(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, - char *min_str,char *max_str, - uint *min_length,uint *max_length) + 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 *end=ptr+ptr_length; char *min_org=min_str; @@ -953,7 +954,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, *min_length= (uint) (min_str - min_org); *max_length=res_length; do { - *min_str++ = ' '; /* Because if key compression */ + *min_str++ = ' '; /* Because if key compression */ *max_str++ = cs->max_sort_char; } while (min_str != min_end); return 0; @@ -970,7 +971,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, } while (min_str != min_end) - *min_str++ = *max_str++ = ' '; /* Because if key compression */ + *min_str++ = *max_str++ = ' '; /* Because if key compression */ return 0; } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index feff0fff227..09bd12dcdeb 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -227,8 +227,8 @@ int my_strnncollsp_sjis(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_sjis(cs,s,slen,t,tlen); } @@ -270,10 +270,10 @@ 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, - int escape, int w_one, int w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + 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 *end=ptr+ptr_length; char *min_org=min_str; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 9f4c33f86c1..b9856799add 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -466,7 +466,7 @@ uchar NEAR sort_order_tis620[]= static uint thai2sortable(uchar *tstr, uint len) { uchar *p; - int len, tlen; + int tlen; uchar l2bias; tlen= len; @@ -572,7 +572,8 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), uchar * dest, uint len, const uchar * src, uint srclen) { - len= (uint) (strmake(dest, src, min(len,srclen))- dest); + len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) - + (char*) dest); return (int) thai2sortable(dest, len); } @@ -610,7 +611,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2) my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)), const char *ptr, uint ptr_length, - int escape, int w_one, int w_many, + pbool escape, pbool w_one, pbool w_many, uint res_length, char *min_str, char *max_str, uint *min_length, uint *max_length) { @@ -862,7 +863,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_like_range_tis620, my_wildcmp_8bit, /* wildcmp */ my_strcasecmp_8bit, - NULL, + my_instr_simple, /* QQ: To be fixed */ my_hash_sort_simple, }; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index ef9719bf040..64956c872aa 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1840,8 +1840,8 @@ int my_strnncollsp_utf8(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_utf8(cs,s,slen,t,tlen); } diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index d3b5c9d1796..889cf2d2dae 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -38,7 +38,6 @@ */ #define REAL_MYSQL - #ifdef REAL_MYSQL #include "my_global.h" @@ -445,103 +444,65 @@ static struct wordvalue doubles[] = { break; \ } -#define IS_END(p, src, len) (!(*p)) - -#if UNUSED -static int my_strcoll_win1250ch(const uchar * s1, const uchar * s2) { - int v1, v2; - const uchar * p1, * p2; - int pass1 = 0, pass2 = 0; - int diff; - - p1 = s1; p2 = s2; - - do { - NEXT_CMP_VALUE(s1, p1, pass1, v1, 0); - NEXT_CMP_VALUE(s2, p2, pass2, v2, 0); - diff = v1 - v2; - if (diff != 0) return diff; - } while (v1); - return 0; -} -#endif - -#ifdef UNUSED -static int my_strxfrm_win1250ch(uchar * dest, const uchar * src, int len) { - int value; - const uchar * p; - int pass = 0; - int totlen = 0; - p = src; - - do { - NEXT_CMP_VALUE(src, p, pass, value, 0); - if (totlen <= len) - dest[totlen] = value; - totlen++; - } while (value); - return totlen; -} -#endif - -#undef IS_END - #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) { - int v1, v2; - const uchar * p1, * p2; - int pass1 = 0, pass2 = 0; - int diff; - - p1 = s1; p2 = s2; - - do { - NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1); - NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2); - diff = v1 - v2; - if (diff != 0) return diff; - } while (v1); - return 0; + const uchar * s1, uint len1, + const uchar * s2, uint len2) +{ + int v1, v2; + const uchar * p1, * p2; + int pass1 = 0, pass2 = 0; + int diff; + + p1 = s1; p2 = s2; + + do { + NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1); + NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2); + diff = v1 - v2; + if (diff != 0) return diff; + } while (v1); + return 0; } + static int my_strnncollsp_win1250ch(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) + const uchar *s, uint slen, + const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_win1250ch(cs,s,slen,t,tlen); } static int my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) { - int value; - const uchar * p; - int pass = 0; - uint totlen = 0; - p = src; - - do { - NEXT_CMP_VALUE(src, p, pass, value, (int)srclen); - if (totlen <= len) - dest[totlen] = value; - totlen++; - } while (value) ; - return totlen; + uchar * dest, uint len, + const uchar * src, uint srclen) +{ + int value; + const uchar * p; + int pass = 0; + uint totlen = 0; + p = src; + + do { + NEXT_CMP_VALUE(src, p, pass, value, (int)srclen); + if (totlen <= len) + dest[totlen] = value; + totlen++; + } while (value) ; + return totlen; } #undef IS_END - #ifdef REAL_MYSQL -static uchar NEAR like_range_prefix_min_win1250ch[] = { +static uchar NEAR like_range_prefix_min_win1250ch[] = +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, @@ -598,87 +559,82 @@ static uchar NEAR like_range_prefix_max_win1250ch[] = { ** optimized ! */ -static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, - char *min_str, char *max_str, - uint *min_length, uint *max_length) { - - int was_other_than_min = 0; - const char *end = ptr + ptr_length; - char *min_org = min_str; - char *min_end = min_str + res_length; - - /* return 1; */ - - for (; ptr != end && min_str != min_end ; ptr++) { - if (*ptr == w_one) { /* '_' in SQL */ - break; - } - if (*ptr == w_many) { /* '%' in SQL */ - break; - } - if (*ptr == escape && ptr + 1 != end) { /* Skip escape */ - ptr++; - } - *min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)]; - if (*min_str != min_sort_char) { - was_other_than_min = 1; - } - min_str++; - *max_str++ = like_range_prefix_max_win1250ch[(uint)(*ptr)]; - } - - *min_length = (uint) (min_str - min_org); - *max_length = res_length; - while (min_str != min_end) { - *min_str++ = min_sort_char; - *max_str++ = max_sort_char; - } - if (! was_other_than_min) { - return 1; - } +static my_bool +my_like_range_win1250ch(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) +{ - return 0; + int only_min_found= 1; + const char *end = ptr + ptr_length; + char *min_org = min_str; + char *min_end = min_str + res_length; + + /* return 1; */ + + for (; ptr != end && min_str != min_end ; ptr++) + { + if (*ptr == escape && ptr+1 != end) + ptr++; /* Skip escape */ + else if (*ptr == w_one || *ptr == w_many) /* '_' or '%' in SQL */ + break; + *min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)]; + if (*min_str != min_sort_char) + only_min_found= 0; + min_str++; + *max_str++ = like_range_prefix_max_win1250ch[(uint)(*ptr)]; + } + + *min_length = (uint) (min_str - min_org); + *max_length = res_length; + while (min_str != min_end) + { + *min_str++ = min_sort_char; + *max_str++ = max_sort_char; + } + return (only_min_found); } static MY_COLLATION_HANDLER my_collation_czech_ci_handler = { - my_strnncoll_win1250ch, - my_strnncollsp_win1250ch, - my_strnxfrm_win1250ch, - my_like_range_win1250ch, - my_wildcmp_8bit, - my_strcasecmp_8bit, - my_instr_simple, - my_hash_sort_simple + my_strnncoll_win1250ch, + my_strnncollsp_win1250ch, + my_strnxfrm_win1250ch, + my_like_range_win1250ch, + my_wildcmp_8bit, + my_strcasecmp_8bit, + my_instr_simple, + my_hash_sort_simple }; + CHARSET_INFO my_charset_cp1250_czech_ci = { - 34,0,0, /* number */ - MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ - "cp1250", /* cs name */ - "cp1250_czech_ci", /* name */ - "", /* comment */ - ctype_win1250ch, - to_lower_win1250ch, - to_upper_win1250ch, - sort_order_win1250ch, - tab_cp1250_uni, /* tab_to_uni */ - idx_uni_cp1250, /* tab_from_uni */ - "","", - 2, /* strxfrm_multiply */ - 1, /* mbminlen */ - 1, /* mbmaxlen */ - 0, - &my_charset_8bit_handler, - &my_collation_czech_ci_handler + 34,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ + "cp1250", /* cs name */ + "cp1250_czech_ci", /* name */ + "", /* comment */ + ctype_win1250ch, + to_lower_win1250ch, + to_upper_win1250ch, + sort_order_win1250ch, + tab_cp1250_uni, /* tab_to_uni */ + idx_uni_cp1250, /* tab_from_uni */ + "","", + 2, /* strxfrm_multiply */ + 1, /* mbminlen */ + 1, /* mbmaxlen */ + 0, + &my_charset_8bit_handler, + &my_collation_czech_ci_handler }; -#endif +#endif /* REAL_MYSQL */ -#endif +#endif /* HAVE_CHARSET_cp1250 */ diff --git a/strings/strto.c b/strings/strto.c index 6f12656cb20..52efec6e087 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -95,7 +95,7 @@ function (const char *nptr,char **endptr,int base) s = nptr; /* Skip white space. */ - while (my_isspace (&my_charset_latin1, *s)) + while (my_isspace(&my_charset_latin1, *s)) ++s; if (*s == '\0') { |