diff options
author | unknown <bar@gw.udmsearch.izhnet.ru> | 2002-03-12 21:37:58 +0400 |
---|---|---|
committer | unknown <bar@gw.udmsearch.izhnet.ru> | 2002-03-12 21:37:58 +0400 |
commit | 68375e0f008d109f574491bd3b0eb2184e6f3ad2 (patch) | |
tree | aa6dbf1781d8122e350474b0cac9e5ee443426bc /sql/sql_string.cc | |
parent | 003b294967317b4710714d8d2ab4880b8e5682e3 (diff) | |
download | mariadb-git-68375e0f008d109f574491bd3b0eb2184e6f3ad2.tar.gz |
New ctype functions/macros to support many charsets at a time
client/mysql.cc:
new ctypes
client/mysqldump.c:
new ctypes
client/mysqltest.c:
new ctypes
client/sql_string.cc:
new ctypes
client/sql_string.h:
new ctypes
extra/mysql_install.c:
new ctypes
extra/replace.c:
new ctypes
extra/resolve_stack_dump.c:
new ctypes
extra/resolveip.c:
new ctypes
heap/hp_hash.c:
new ctypes
include/m_ctype.h:
new ctypes
include/my_sys.h:
new ctypes
isam/_key.c:
new ctypes
isam/_search.c:
new ctypes
libmysql/Makefile.shared:
new ctypes
libmysql/libmysql.c:
new ctypes
myisam/ft_dump.c:
new ctypes
myisam/ft_parser.c:
new ctypes
myisam/mi_test1.c:
new ctypes
mysys/charset.c:
new ctypes
mysys/default.c:
new ctypes
mysys/getvar.c:
new ctypes
mysys/hash.c:
new ctypes
mysys/mf_casecnv.c:
new ctypes
mysys/mf_dirname.c:
new ctypes
mysys/mf_format.c:
new ctypes
mysys/mf_iocache2.c:
new ctypes
mysys/mf_soundex.c:
new ctypes
mysys/mf_wfile.c:
new ctypes
mysys/my_error.c:
new ctypes
mysys/my_getwd.c:
new ctypes
mysys/my_init.c:
new ctypes
mysys/my_vsnprintf.c:
new ctypes
mysys/typelib.c:
new ctypes
sql/convert.cc:
new ctypes
sql/des_key_file.cc:
new ctypes
sql/field.cc:
new ctypes
sql/field.h:
new ctypes
sql/field_conv.cc:
new ctypes
sql/filesort.cc:
new ctypes
sql/ha_innodb.cc:
new ctypes
sql/hostname.cc:
new ctypes
sql/init.cc:
new ctypes
sql/item.cc:
new ctypes
sql/item_func.cc:
new ctypes
sql/item_strfunc.cc:
new ctypes
sql/item_sum.cc:
new ctypes
sql/item_timefunc.cc:
new ctypes
sql/key.cc:
new ctypes
sql/log.cc:
new ctypes
sql/mysql_priv.h:
new ctypes
sql/mysqld.cc:
new ctypes
sql/opt_range.cc:
new ctypes
sql/procedure.cc:
new ctypes
sql/slave.cc:
new ctypes
sql/sql_acl.cc:
new ctypes
sql/sql_analyse.cc:
new ctypes
sql/sql_base.cc:
new ctypes
sql/sql_cache.cc:
new ctypes
sql/sql_db.cc:
new ctypes
sql/sql_handler.cc:
new ctypes
sql/sql_lex.cc:
new ctypes
sql/sql_parse.cc:
new ctypes
sql/sql_show.cc:
new ctypes
sql/sql_string.cc:
new ctypes
sql/sql_string.h:
new ctypes
sql/sql_table.cc:
new ctypes
sql/sql_yacc.yy:
new ctypes
sql/table.cc:
new ctypes
sql/time.cc:
new ctypes
strings/Makefile.am:
new ctypes
strings/ctype-big5.c:
new ctypes
strings/ctype-czech.c:
new ctypes
strings/ctype-gbk.c:
new ctypes
strings/ctype-latin1_de.c:
new ctypes
strings/ctype-sjis.c:
new ctypes
strings/ctype-tis620.c:
new ctypes
strings/ctype.c:
new ctypes
strings/str2int.c:
new ctypes
strings/strto.c:
new ctypes
tools/mysqlmanager.c:
new ctypes
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r-- | sql/sql_string.cc | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc index f0cfd590072..62b1812afb3 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -234,7 +234,7 @@ bool String::fill(uint32 max_length,char fill_char) void String::strip_sp() { - while (str_length && isspace(Ptr[str_length-1])) + while (str_length && my_isspace(str_charset,Ptr[str_length-1])) str_length--; } @@ -296,10 +296,10 @@ uint32 String::numchars() register uint32 n=0,mblen; register const char *mbstr=Ptr; register const char *end=mbstr+str_length; - if (use_mb(default_charset_info)) + if (use_mb(str_charset)) { while (mbstr < end) { - if ((mblen=my_ismbchar(default_charset_info, mbstr,end))) mbstr+=mblen; + if ((mblen=my_ismbchar(str_charset, mbstr,end))) mbstr+=mblen; else ++mbstr; ++n; } @@ -316,11 +316,11 @@ int String::charpos(int i,uint32 offset) register uint32 mblen; register const char *mbstr=Ptr+offset; register const char *end=Ptr+str_length; - if (use_mb(default_charset_info)) + if (use_mb(str_charset)) { if (i<=0) return i; while (i && mbstr < end) { - if ((mblen=my_ismbchar(default_charset_info, mbstr,end))) mbstr+=mblen; + if ((mblen=my_ismbchar(str_charset, mbstr,end))) mbstr+=mblen; else ++mbstr; --i; } @@ -380,12 +380,14 @@ int String::strstr_case(const String &s,uint32 offset) skipp: while (str != end) { - if (my_sort_order[*str++] == my_sort_order[*search]) + if (str_charset->sort_order[*str++] == str_charset->sort_order[*search]) { register char *i,*j; i=(char*) str; j=(char*) search+1; while (j != search_end) - if (my_sort_order[*i++] != my_sort_order[*j++]) goto skipp; + if (str_charset->sort_order[*i++] != + str_charset->sort_order[*j++]) + goto skipp; return (int) (str-Ptr) -1; } } @@ -505,15 +507,15 @@ int sortcmp(const String *x,const String *y) uint32 x_len=x->length(),y_len=y->length(),len=min(x_len,y_len); #ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) + if (use_strcoll(x->str_charset)) { #ifndef CMP_ENDSPACE - while (x_len && isspace(s[x_len-1])) + while (x_len && my_isspace(x->str_charset,s[x_len-1])) x_len--; - while (y_len && isspace(t[y_len-1])) + while (y_len && my_isspace(x->str_charset,t[y_len-1])) y_len--; #endif - return my_strnncoll(default_charset_info, + return my_strnncoll(x->str_charset, (unsigned char *)s,x_len,(unsigned char *)t,y_len); } else @@ -523,9 +525,10 @@ int sortcmp(const String *x,const String *y) y_len-=len; while (len--) { - if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++]) - return ((int) my_sort_order[(uchar) s[-1]] - - (int) my_sort_order[(uchar) t[-1]]); + if (x->str_charset->sort_order[(uchar) *s++] != + x->str_charset->sort_order[(uchar) *t++]) + return ((int) x->str_charset->sort_order[(uchar) s[-1]] - + (int) x->str_charset->sort_order[(uchar) t[-1]]); } #ifndef CMP_ENDSPACE /* Don't compare end space in strings */ @@ -534,14 +537,14 @@ int sortcmp(const String *x,const String *y) { const char *end=t+y_len; for (; t != end ; t++) - if (!isspace(*t)) + if (!my_isspace(x->str_charset,*t)) return -1; } else { const char *end=s+x_len; for (; s != end ; s++) - if (!isspace(*s)) + if (!my_isspace(x->str_charset,*s)) return 1; } return 0; @@ -589,11 +592,10 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) /* Make it easier to handle different charactersets */ #ifdef USE_MB -#define INC_PTR(A,B) A+=((use_mb_flag && \ - my_ismbchar(default_charset_info,A,B)) ? \ - my_ismbchar(default_charset_info,A,B) : 1) +#define INC_PTR(cs,A,B) A+=((use_mb_flag && \ + my_ismbchar(cs,A,B)) ? my_ismbchar(cs,A,B) : 1) #else -#define INC_PTR(A,B) A++ +#define INC_PTR(cs,A,B) A++ #endif /* @@ -604,12 +606,12 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) */ #ifdef LIKE_CMP_TOUPPER -#define likeconv(A) (uchar) toupper(A) +#define likeconv(s,A) (uchar) my_toupper(s,A) #else -#define likeconv(A) (uchar) my_sort_order[(uchar) (A)] +#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)] #endif -int wild_case_compare(const char *str,const char *str_end, +int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend, char escape) { @@ -626,7 +628,7 @@ int wild_case_compare(const char *str,const char *str_end, #ifdef USE_MB int l; if (use_mb_flag && - (l = my_ismbchar(default_charset_info, wildstr, wildend))) + (l = my_ismbchar(cs, wildstr, wildend))) { if (str+l > str_end || memcmp(str, wildstr, l) != 0) return 1; @@ -635,7 +637,7 @@ int wild_case_compare(const char *str,const char *str_end, } else #endif - if (str == str_end || likeconv(*wildstr++) != likeconv(*str++)) + 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 @@ -647,7 +649,7 @@ int wild_case_compare(const char *str,const char *str_end, { if (str == str_end) // Skip one char if possible return (result); - INC_PTR(str,str_end); + INC_PTR(cs,str,str_end); } while (++wildstr < wildend && *wildstr == wild_one); if (wildstr == wildend) break; @@ -664,7 +666,7 @@ int wild_case_compare(const char *str,const char *str_end, { if (str == str_end) return (-1); - INC_PTR(str,str_end); + INC_PTR(cs,str,str_end); continue; } break; // Not a wild character @@ -682,10 +684,10 @@ int wild_case_compare(const char *str,const char *str_end, int mblen; LINT_INIT(mblen); if (use_mb_flag) - mblen = my_ismbchar(default_charset_info, wildstr, wildend); + mblen = my_ismbchar(cs, wildstr, wildend); #endif - INC_PTR(wildstr,wildend); // This is compared trough cmp - cmp=likeconv(cmp); + INC_PTR(cs,wildstr,wildend); // This is compared trough cmp + cmp=likeconv(cs,cmp); do { #ifdef USE_MB @@ -703,26 +705,26 @@ int wild_case_compare(const char *str,const char *str_end, break; } } - else if (!my_ismbchar(default_charset_info, str, str_end) && - likeconv(*str) == cmp) + else if (!my_ismbchar(cs, str, str_end) && + likeconv(cs,*str) == cmp) { str++; break; } - INC_PTR(str, str_end); + INC_PTR(cs,str, str_end); } } else { #endif /* USE_MB */ - while (str != str_end && likeconv(*str) != cmp) + while (str != str_end && likeconv(cs,*str) != cmp) str++; if (str++ == str_end) return (-1); #ifdef USE_MB } #endif { - int tmp=wild_case_compare(str,str_end,wildstr,wildend,escape); + int tmp=wild_case_compare(cs,str,str_end,wildstr,wildend,escape); if (tmp <= 0) return (tmp); } @@ -739,7 +741,7 @@ int wild_case_compare(String &match,String &wild, char escape) DBUG_ENTER("wild_case_compare"); DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'" ,match.ptr(),wild.ptr(),escape)); - DBUG_RETURN(wild_case_compare(match.ptr(),match.ptr()+match.length(), + DBUG_RETURN(wild_case_compare(match.str_charset,match.ptr(),match.ptr()+match.length(), wild.ptr(), wild.ptr()+wild.length(),escape)); } |