summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@gw.udmsearch.izhnet.ru>2002-03-12 21:37:58 +0400
committerunknown <bar@gw.udmsearch.izhnet.ru>2002-03-12 21:37:58 +0400
commit68375e0f008d109f574491bd3b0eb2184e6f3ad2 (patch)
treeaa6dbf1781d8122e350474b0cac9e5ee443426bc
parent003b294967317b4710714d8d2ab4880b8e5682e3 (diff)
downloadmariadb-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
-rw-r--r--client/mysql.cc42
-rw-r--r--client/mysqldump.c11
-rw-r--r--client/mysqltest.c48
-rw-r--r--client/sql_string.cc204
-rw-r--r--client/sql_string.h94
-rw-r--r--extra/mysql_install.c2
-rw-r--r--extra/replace.c2
-rw-r--r--extra/resolve_stack_dump.c10
-rw-r--r--extra/resolveip.c2
-rw-r--r--heap/hp_hash.c13
-rw-r--r--include/m_ctype.h155
-rw-r--r--include/my_sys.h16
-rw-r--r--isam/_key.c6
-rw-r--r--isam/_search.c16
-rw-r--r--libmysql/Makefile.shared2
-rw-r--r--libmysql/libmysql.c10
-rw-r--r--myisam/ft_dump.c2
-rw-r--r--myisam/ft_parser.c16
-rw-r--r--myisam/mi_test1.c6
-rw-r--r--mysys/charset.c8
-rw-r--r--mysys/default.c10
-rw-r--r--mysys/getvar.c9
-rw-r--r--mysys/hash.c7
-rw-r--r--mysys/mf_casecnv.c216
-rw-r--r--mysys/mf_dirname.c6
-rw-r--r--mysys/mf_format.c6
-rw-r--r--mysys/mf_iocache2.c2
-rw-r--r--mysys/mf_soundex.c20
-rw-r--r--mysys/mf_wfile.c7
-rw-r--r--mysys/my_error.c2
-rw-r--r--mysys/my_getwd.c3
-rw-r--r--mysys/my_init.c3
-rw-r--r--mysys/my_vsnprintf.c2
-rw-r--r--mysys/typelib.c4
-rw-r--r--sql/convert.cc12
-rw-r--r--sql/des_key_file.cc5
-rw-r--r--sql/field.cc114
-rw-r--r--sql/field.h19
-rw-r--r--sql/field_conv.cc2
-rw-r--r--sql/filesort.cc11
-rw-r--r--sql/ha_innodb.cc5
-rw-r--r--sql/hostname.cc4
-rw-r--r--sql/init.cc14
-rw-r--r--sql/item.cc4
-rw-r--r--sql/item_func.cc3
-rw-r--r--sql/item_strfunc.cc16
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/item_timefunc.cc8
-rw-r--r--sql/key.cc5
-rw-r--r--sql/log.cc4
-rw-r--r--sql/mysql_priv.h6
-rw-r--r--sql/mysqld.cc11
-rw-r--r--sql/opt_range.cc3
-rw-r--r--sql/procedure.cc3
-rw-r--r--sql/slave.cc9
-rw-r--r--sql/sql_acl.cc46
-rw-r--r--sql/sql_analyse.cc10
-rw-r--r--sql/sql_base.cc21
-rw-r--r--sql/sql_cache.cc5
-rw-r--r--sql/sql_db.cc6
-rw-r--r--sql/sql_handler.cc2
-rw-r--r--sql/sql_lex.cc78
-rw-r--r--sql/sql_parse.cc15
-rw-r--r--sql/sql_show.cc10
-rw-r--r--sql/sql_string.cc74
-rw-r--r--sql/sql_string.h4
-rw-r--r--sql/sql_table.cc33
-rw-r--r--sql/sql_yacc.yy3
-rw-r--r--sql/table.cc14
-rw-r--r--sql/time.cc53
-rw-r--r--strings/Makefile.am6
-rw-r--r--strings/ctype-big5.c12
-rw-r--r--strings/ctype-czech.c19
-rw-r--r--strings/ctype-gbk.c20
-rw-r--r--strings/ctype-latin1_de.c25
-rw-r--r--strings/ctype-mb.c125
-rw-r--r--strings/ctype-simple.c87
-rw-r--r--strings/ctype-sjis.c27
-rw-r--r--strings/ctype-tis620.c11
-rw-r--r--strings/ctype.c329
-rw-r--r--strings/str2int.c2
-rw-r--r--strings/strto.c12
-rw-r--r--tools/mysqlmanager.c18
83 files changed, 1335 insertions, 955 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 769b4490096..5f79dd6b8d7 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -924,14 +924,14 @@ static COMMANDS *find_command (char *name,char cmd_char)
}
else
{
- while (isspace(*name))
+ while (my_isspace(system_charset_info,*name))
name++;
if (strchr(name,';') || strstr(name,"\\g"))
return ((COMMANDS *) 0);
if ((end=strcont(name," \t")))
{
len=(uint) (end - name);
- while (isspace(*end))
+ while (my_isspace(system_charset_info,*end))
end++;
if (!*end)
end=0; // no arguments to function
@@ -943,7 +943,8 @@ static COMMANDS *find_command (char *name,char cmd_char)
for (uint i= 0; commands[i].name; i++)
{
if (commands[i].func &&
- ((name && !my_casecmp(name,commands[i].name,len) &&
+ ((name &&
+ !my_strncasecmp(system_charset_info,name,commands[i].name,len) &&
!commands[i].name[len] &&
(!end || (end && commands[i].takes_params))) ||
!name && commands[i].cmd_char == cmd_char))
@@ -971,7 +972,8 @@ static bool add_line(String &buffer,char *line,char *in_string)
for (pos=out=line ; (inchar= (uchar) *pos) ; pos++)
{
- if (isspace(inchar) && out == line && buffer.is_empty())
+ if (my_isspace(default_charset_info,inchar) && out == line &&
+ buffer.is_empty())
continue;
#ifdef USE_MB
int l;
@@ -1039,7 +1041,7 @@ static bool add_line(String &buffer,char *line,char *in_string)
}
else if (!*in_string && (inchar == '#' ||
inchar == '-' && pos[1] == '-' &&
- isspace(pos[2])))
+ my_isspace(system_charset_info,pos[2])))
break; // comment to end of line
else
{ // Add found char to buffer
@@ -1439,7 +1441,8 @@ com_go(String *buffer,char *line __attribute__((unused)))
(void) com_print(buffer,0);
if (skip_updates &&
- (buffer->length() < 4 || my_sortcmp(buffer->ptr(),"SET ",4)))
+ (buffer->length() < 4 || my_sortcmp(system_charset_info,buffer->ptr(),
+ "SET ",4)))
{
(void) put_info("Ignoring query to other database",INFO_INFO);
return 0;
@@ -1871,7 +1874,7 @@ com_tee(String *buffer, char *line __attribute__((unused)))
if (status.batch)
return 0;
- while (isspace(*line))
+ while (my_isspace(system_charset_info,*line))
line++;
if (!(param = strchr(line, ' '))) // if outfile wasn't given, use the default
{
@@ -1884,10 +1887,11 @@ com_tee(String *buffer, char *line __attribute__((unused)))
}
else
{
- while (isspace(*param))
+ while (my_isspace(system_charset_info,*param))
param++;
end=strmake(file_name, param, sizeof(file_name)-1);
- while (end > file_name && (isspace(end[-1]) || iscntrl(end[-1])))
+ while (end > file_name && (my_isspace(system_charset_info,end[-1]) ||
+ my_iscntrl(system_charset_info,end[-1])))
end--;
end[0]=0;
strmov(outfile, file_name);
@@ -1930,7 +1934,7 @@ com_pager(String *buffer, char *line __attribute__((unused)))
if (status.batch)
return 0;
/* Skip space from file name */
- while (isspace(*line))
+ while (my_isspace(system_charset_info,*line))
line++;
if (!(param = strchr(line, ' '))) // if pager was not given, use the default
{
@@ -1946,10 +1950,11 @@ com_pager(String *buffer, char *line __attribute__((unused)))
}
else
{
- while (isspace(*param))
+ while (my_isspace(system_charset_info,*param))
param++;
end=strmake(pager_name, param, sizeof(pager_name)-1);
- while (end > pager_name && (isspace(end[-1]) || iscntrl(end[-1])))
+ while (end > pager_name && (my_isspace(system_charset_info,end[-1]) ||
+ my_iscntrl(system_charset_info,end[-1])))
end--;
end[0]=0;
strmov(pager, pager_name);
@@ -2083,7 +2088,7 @@ com_connect(String *buffer, char *line)
if (buffer)
{
- while (isspace(*line))
+ while (my_isspace(system_charset_info,*line))
line++;
strnmov(buff,line,sizeof(buff)-1); // Don't destroy history
if (buff[0] == '\\') // Short command
@@ -2129,15 +2134,16 @@ static int com_source(String *buffer, char *line)
FILE *sql_file;
/* Skip space from file name */
- while (isspace(*line))
+ while (my_isspace(system_charset_info,*line))
line++;
if (!(param = strchr(line, ' '))) // Skip command name
return put_info("Usage: \\. <filename> | source <filename>",
INFO_ERROR, 0);
- while (isspace(*param))
+ while (my_isspace(system_charset_info,*param))
param++;
end=strmake(source_name,param,sizeof(source_name)-1);
- while (end > source_name && (isspace(end[-1]) || iscntrl(end[-1])))
+ while (end > source_name && (my_isspace(system_charset_info,end[-1]) ||
+ my_iscntrl(system_charset_info,end[-1])))
end--;
end[0]=0;
unpack_filename(source_name,source_name);
@@ -2178,7 +2184,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
char *tmp;
char buff[256];
- while (isspace(*line))
+ while (my_isspace(system_charset_info,*line))
line++;
strnmov(buff,line,sizeof(buff)-1); // Don't destroy history
if (buff[0] == '\\') // Short command
@@ -2463,7 +2469,7 @@ static void remove_cntrl(String &buffer)
{
char *start,*end;
end=(start=(char*) buffer.ptr())+buffer.length();
- while (start < end && !isgraph(end[-1]))
+ while (start < end && !my_isgraph(system_charset_info,end[-1]))
end--;
buffer.length((uint) (end-start));
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index da708849992..bcb1195fb58 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -600,7 +600,7 @@ static my_bool test_if_special_chars(const char *str)
{
#if MYSQL_VERSION_ID >= 32300
for ( ; *str ; str++)
- if (!isvar(*str) && *str != '$')
+ if (!my_isvar(system_charset_info,*str) && *str != '$')
return 1;
#endif
return 0;
@@ -1112,7 +1112,8 @@ static void dumpTable(uint numFields, char *table)
/* change any strings ("inf","nan",..) into NULL */
char *ptr = row[i];
dynstr_append(&extended_row,
- (!isalpha(*ptr)) ? ptr : "NULL");
+ (!my_isalpha(system_charset_info,*ptr)) ?
+ ptr : "NULL");
}
}
else
@@ -1144,9 +1145,11 @@ static void dumpTable(uint numFields, char *table)
char *ptr = row[i];
if (opt_xml)
fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
- field->name,!isalpha(*ptr) ?ptr: "NULL",field->name);
+ field->name,
+ !my_isalpha(system_charset_info,*ptr) ?ptr: "NULL",field->name);
else
- fputs((!isalpha(*ptr)) ? ptr : "NULL", md_result_file);
+ fputs((!my_isalpha(system_charset_info,*ptr)) ?
+ ptr : "NULL", md_result_file);
}
}
else
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 4ae74d129b9..dd71c3255a0 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -456,9 +456,9 @@ void init_parser()
int hex_val(int c)
{
- if (isdigit(c))
+ if (my_isdigit(system_charset_info,c))
return c - '0';
- else if ((c = tolower(c)) >= 'a' && c <= 'f')
+ else if ((c = my_tolower(system_charset_info,c)) >= 'a' && c <= 'f')
return c - 'a' + 10;
else
return -1;
@@ -569,7 +569,7 @@ VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw,
{
const char* save_var_name = var_name, *end;
end = (var_name_end) ? *var_name_end : 0;
- while (isvar(*var_name) && var_name != end)
+ while (my_isvar(system_charset_info,*var_name) && var_name != end)
++var_name;
if (var_name == save_var_name)
{
@@ -729,7 +729,7 @@ int do_server_op(struct st_query* q,const char* op)
com_p=strmov(com_p,"_exec ");
if (!*p)
die("Missing server name in server_%s\n",op);
- while (*p && !isspace(*p))
+ while (*p && !my_isspace(system_charset_info,*p))
{
*com_p++=*p++;
}
@@ -762,7 +762,7 @@ int do_require_version(struct st_query* q)
if (!*p)
die("Missing version argument in require_version\n");
ver_arg = p;
- while (*p && !isspace(*p))
+ while (*p && !my_isspace(system_charset_info,*p))
p++;
*p = 0;
ver_arg_len = p - ver_arg;
@@ -792,7 +792,7 @@ int do_source(struct st_query* q)
if (!*p)
die("Missing file name in source\n");
name = p;
- while (*p && !isspace(*p))
+ while (*p && !my_isspace(system_charset_info,*p))
p++;
*p = 0;
@@ -1012,11 +1012,11 @@ int do_let(struct st_query* q)
if (!*p)
die("Missing variable name in let\n");
var_name = p;
- while(*p && (*p != '=' || isspace(*p)))
+ while(*p && (*p != '=' || my_isspace(system_charset_info,*p)))
p++;
var_name_end = p;
if (*p == '=') p++;
- while(*p && isspace(*p))
+ while(*p && my_isspace(system_charset_info,*p))
p++;
var_val_start = p;
return var_set(var_name, var_name_end, var_val_start, q->end);
@@ -1047,7 +1047,7 @@ int do_sleep(struct st_query* q)
char* p=q->first_argument;
struct timeval t;
int dec_mul = 1000000;
- while(*p && isspace(*p)) p++;
+ while(*p && my_isspace(system_charset_info,*p)) p++;
if (!*p)
die("Missing argument in sleep\n");
t.tv_usec = 0;
@@ -1067,7 +1067,7 @@ int do_sleep(struct st_query* q)
else
{
t.tv_sec = atoi(p);
- while(*p && *p != '.' && !isspace(*p))
+ while(*p && *p != '.' && !my_isspace(system_charset_info,*p))
p++;
if (*p == '.')
{
@@ -1099,7 +1099,7 @@ static void get_file_name(char *filename, struct st_query* q)
char* p=q->first_argument;
strnmov(filename, p, FN_REFLEN);
/* Remove end space */
- while (p > filename && isspace(p[-1]))
+ while (p > filename && my_isspace(system_charset_info,p[-1]))
p--;
p[0]=0;
}
@@ -1185,7 +1185,7 @@ static char *get_string(char **to_ptr, char **from_ptr,
if (*from != ' ' && *from)
die("Wrong string argument in %s\n", q->query);
- while (isspace(*from)) /* Point to next string */
+ while (my_isspace(system_charset_info,*from)) /* Point to next string */
from++;
*to =0; /* End of string marker */
@@ -1243,7 +1243,7 @@ static void get_replace(struct st_query *q)
insert_pointer_name(&to_array,to);
}
for (i=1,pos=word_end_chars ; i < 256 ; i++)
- if (isspace(i))
+ if (my_isspace(system_charset_info,i))
*pos++=i;
*pos=0; /* End pointer */
if (!(glob_replace=init_replace((char**) from_array.typelib.type_names,
@@ -1278,7 +1278,7 @@ int select_connection(struct st_query* q)
if (!*p)
die("Missing connection name in connect\n");
name = p;
- while(*p && !isspace(*p))
+ while(*p && !my_isspace(system_charset_info,*p))
p++;
*p = 0;
@@ -1304,7 +1304,7 @@ int close_connection(struct st_query* q)
if (!*p)
die("Missing connection name in connect\n");
name = p;
- while(*p && !isspace(*p))
+ while(*p && !my_isspace(system_charset_info,*p))
p++;
*p = 0;
@@ -1340,11 +1340,11 @@ int close_connection(struct st_query* q)
char* safe_get_param(char* str, char** arg, const char* msg)
{
DBUG_ENTER("safe_get_param");
- while (*str && isspace(*str)) str++;
+ while (*str && my_isspace(system_charset_info,*str)) str++;
*arg = str;
for (; *str && *str != ',' && *str != ')' ; str++)
{
- if (isspace(*str)) *str = 0;
+ if (my_isspace(system_charset_info,*str)) *str = 0;
}
if (!*str)
die(msg);
@@ -1626,7 +1626,7 @@ int read_line(char* buf, int size)
{
state = R_COMMENT;
}
- else if (isspace(c))
+ else if (my_isspace(system_charset_info,c))
{
if (c == '\n')
start_lineno= ++*lineno; /* Query hasn't started yet */
@@ -1752,7 +1752,7 @@ int read_query(struct st_query** q_ptr)
{
expected_errno = 0;
p++;
- for (;isdigit(*p);p++)
+ for (;my_isdigit(system_charset_info,*p);p++)
expected_errno = expected_errno * 10 + *p - '0';
q->expected_errno[0] = expected_errno;
q->expected_errno[1] = 0;
@@ -1760,25 +1760,25 @@ int read_query(struct st_query** q_ptr)
}
}
- while(*p && isspace(*p)) p++ ;
+ while(*p && my_isspace(system_charset_info,*p)) p++ ;
if (*p == '@')
{
p++;
p1 = q->record_file;
- while (!isspace(*p) &&
+ while (!my_isspace(system_charset_info,*p) &&
p1 < q->record_file + sizeof(q->record_file) - 1)
*p1++ = *p++;
*p1 = 0;
}
}
- while (*p && isspace(*p)) p++;
+ while (*p && my_isspace(system_charset_info,*p)) p++;
if (!(q->query_buf=q->query=my_strdup(p,MYF(MY_WME))))
die(NullS);
/* Calculate first word and first argument */
- for (p=q->query; *p && !isspace(*p) ; p++) ;
+ for (p=q->query; *p && !my_isspace(system_charset_info,*p) ; p++) ;
q->first_word_len = (uint) (p - q->query);
- while (*p && isspace(*p)) p++;
+ while (*p && my_isspace(system_charset_info,*p)) p++;
q->first_argument=p;
q->end = strend(q->query);
parser.read_lines++;
diff --git a/client/sql_string.cc b/client/sql_string.cc
index 3c5e481eaad..62b1812afb3 100644
--- a/client/sql_string.cc
+++ b/client/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;
}
@@ -361,6 +361,39 @@ skipp:
return -1;
}
+/*
+ Search after a string without regarding to case
+ This needs to be replaced when we have character sets per string
+*/
+
+int String::strstr_case(const String &s,uint32 offset)
+{
+ if (s.length()+offset <= str_length)
+ {
+ if (!s.length())
+ return ((int) offset); // Empty string is always found
+
+ register const char *str = Ptr+offset;
+ register const char *search=s.ptr();
+ const char *end=Ptr+str_length-s.length()+1;
+ const char *search_end=s.ptr()+s.length();
+skipp:
+ while (str != end)
+ {
+ 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 (str_charset->sort_order[*i++] !=
+ str_charset->sort_order[*j++])
+ goto skipp;
+ return (int) (str-Ptr) -1;
+ }
+ }
+ }
+ return -1;
+}
/*
** Search string from end. Offset is offset to the end of string
@@ -428,6 +461,44 @@ bool String::replace(uint32 offset,uint32 arg_length,const String &to)
return FALSE;
}
+// added by Holyfoot for "geometry" needs
+int String::reserve(uint32 space_needed, uint32 grow_by)
+{
+ if (Alloced_length < str_length + space_needed)
+ {
+ if (realloc(Alloced_length + max(space_needed, grow_by) - 1))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void String::qs_append(const char *str)
+{
+ int len = strlen(str);
+ memcpy(Ptr + str_length, str, len + 1);
+ str_length += len;
+}
+
+void String::qs_append(double d)
+{
+ char *buff = Ptr + str_length;
+ sprintf(buff,"%.14g", d);
+ str_length += strlen(buff);
+}
+
+void String::qs_append(double *d)
+{
+ double ld;
+ float8get(ld, d);
+ qs_append(ld);
+}
+
+void String::qs_append(const char &c)
+{
+ Ptr[str_length] = c;
+ str_length += sizeof(c);
+}
+
int sortcmp(const String *x,const String *y)
{
@@ -436,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
@@ -454,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 */
@@ -465,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;
@@ -520,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
/*
@@ -535,14 +606,14 @@ 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
-static int wild_case_compare(const char *str,const char *str_end,
- const char *wildstr,const char *wildend,
- char escape)
+int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,
+ char escape)
{
int result= -1; // Not found, using wildcards
#ifdef USE_MB
@@ -557,7 +628,7 @@ static 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;
@@ -566,7 +637,7 @@ static 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
@@ -576,9 +647,9 @@ static int wild_case_compare(const char *str,const char *str_end,
{
do
{
- if (str == str_end) // Skipp one char if possible
+ 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;
@@ -595,7 +666,7 @@ static 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
@@ -613,10 +684,10 @@ static 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
@@ -634,26 +705,26 @@ static 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);
}
@@ -667,17 +738,23 @@ static int wild_case_compare(const char *str,const char *str_end,
int wild_case_compare(String &match,String &wild, char escape)
{
- return wild_case_compare(match.ptr(),match.ptr()+match.length(),
- wild.ptr(), wild.ptr()+wild.length(),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.str_charset,match.ptr(),match.ptr()+match.length(),
+ wild.ptr(), wild.ptr()+wild.length(),escape));
}
/*
** The following is used when using LIKE on binary strings
*/
-static int wild_compare(const char *str,const char *str_end,
- const char *wildstr,const char *wildend,char escape)
+int wild_compare(const char *str,const char *str_end,
+ const char *wildstr,const char *wildend,char escape)
{
+ DBUG_ENTER("wild_compare");
+ DBUG_PRINT("enter",("str='%s', str_end='%s', wildstr='%s', wildend='%s', escape='%c'"
+ ,str,str_end,wildstr,wildend,escape));
int result= -1; // Not found, using wildcards
while (wildstr != wildend)
{
@@ -686,17 +763,21 @@ static int wild_compare(const char *str,const char *str_end,
if (*wildstr == escape && wildstr+1 != wildend)
wildstr++;
if (str == str_end || *wildstr++ != *str++)
- return(1);
+ {
+ DBUG_RETURN(1);
+ }
if (wildstr == wildend)
- return (str != str_end); // Match if both are at end
+ {
+ DBUG_RETURN(str != str_end); // Match if both are at end
+ }
result=1; // Found an anchor char
}
if (*wildstr == wild_one)
{
do
{
- if (str == str_end) // Skipp one char if possible
- return (result);
+ if (str == str_end) // Skip one char if possible
+ DBUG_RETURN(result);
str++;
} while (*++wildstr == wild_one && wildstr != wildend);
if (wildstr == wildend)
@@ -713,17 +794,22 @@ static int wild_compare(const char *str,const char *str_end,
if (*wildstr == wild_one)
{
if (str == str_end)
- return (-1);
+ {
+ DBUG_RETURN(-1);
+ }
str++;
continue;
}
break; // Not a wild character
}
if (wildstr == wildend)
- return(0); // Ok if wild_many is last
+ {
+ DBUG_RETURN(0); // Ok if wild_many is last
+ }
if (str == str_end)
- return -1;
-
+ {
+ DBUG_RETURN(-1);
+ }
char cmp;
if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
cmp= *++wildstr;
@@ -732,22 +818,32 @@ static int wild_compare(const char *str,const char *str_end,
{
while (str != str_end && *str != cmp)
str++;
- if (str++ == str_end) return (-1);
+ if (str++ == str_end)
+ {
+ DBUG_RETURN(-1);
+ }
{
int tmp=wild_compare(str,str_end,wildstr,wildend,escape);
if (tmp <= 0)
- return (tmp);
+ {
+ DBUG_RETURN(tmp);
+ }
}
} while (str != str_end && wildstr[0] != wild_many);
- return(-1);
+ DBUG_RETURN(-1);
}
}
- return (str != str_end ? 1 : 0);
+ DBUG_RETURN(str != str_end ? 1 : 0);
}
int wild_compare(String &match,String &wild, char escape)
{
- return wild_compare(match.ptr(),match.ptr()+match.length(),
- wild.ptr(), wild.ptr()+wild.length(),escape);
+ DBUG_ENTER("wild_compare");
+ DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'"
+ ,match.ptr(),wild.ptr(),escape));
+ DBUG_RETURN(wild_compare(match.ptr(),match.ptr()+match.length(),
+ wild.ptr(), wild.ptr()+wild.length(),escape));
}
+
+
diff --git a/client/sql_string.h b/client/sql_string.h
index cffe78936a0..811e49a0d02 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -24,31 +24,57 @@
#define NOT_FIXED_DEC 31
#endif
+class String;
+int sortcmp(const String *a,const String *b);
+int stringcmp(const String *a,const String *b);
+String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
+int wild_case_compare(String &match,String &wild,char escape);
+int wild_compare(String &match,String &wild,char escape);
+
class String
{
char *Ptr;
uint32 str_length,Alloced_length;
bool alloced;
+ CHARSET_INFO *str_charset;
public:
String()
- { Ptr=0; str_length=Alloced_length=0; alloced=0; }
+ {
+ Ptr=0; str_length=Alloced_length=0; alloced=0;
+ str_charset=default_charset_info;
+ }
String(uint32 length_arg)
- { alloced=0; Alloced_length=0; (void) real_alloc(length_arg); }
+ {
+ alloced=0; Alloced_length=0; (void) real_alloc(length_arg);
+ str_charset=default_charset_info;
+ }
String(const char *str)
- { Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;}
+ {
+ Ptr=(char*) str; str_length=(uint) strlen(str); Alloced_length=0; alloced=0;
+ str_charset=default_charset_info;
+ }
String(const char *str,uint32 len)
- { Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;}
+ {
+ Ptr=(char*) str; str_length=len; Alloced_length=0; alloced=0;
+ str_charset=default_charset_info;
+ }
String(char *str,uint32 len)
- { Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;}
+ {
+ Ptr=(char*) str; Alloced_length=str_length=len; alloced=0;
+ str_charset=default_charset_info;
+ }
String(const String &str)
- { Ptr=str.Ptr ; str_length=str.str_length ;
- Alloced_length=str.Alloced_length; alloced=0; }
-
+ {
+ Ptr=str.Ptr ; str_length=str.str_length ;
+ Alloced_length=str.Alloced_length; alloced=0;
+ str_charset=str.str_charset;
+ }
static void *operator new(size_t size) { return (void*) sql_alloc((uint) size); }
static void operator delete(void *ptr_arg,size_t size) /*lint -e715 */
{ sql_element_free(ptr_arg); }
~String() { free(); }
+ inline CHARSET_INFO *charset() const { return str_charset; }
inline uint32 length() const { return str_length;}
inline uint32 alloced_length() const { return Alloced_length;}
inline char& operator [] (uint32 i) const { return Ptr[i]; }
@@ -124,7 +150,7 @@ public:
char *new_ptr;
if (!(new_ptr=(char*) my_realloc(Ptr,arg_length,MYF(0))))
{
- (void) my_free(Ptr,MYF(0));
+ Alloced_length = 0;
real_alloc(arg_length);
}
else
@@ -153,6 +179,7 @@ public:
bool append(const char *s,uint32 arg_length=0);
bool append(IO_CACHE* file, uint32 arg_length);
int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
+ int strstr_case(const String &s,uint32 offset=0);
int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
bool replace(uint32 offset,uint32 arg_length,const String &to);
inline bool append(char chr)
@@ -171,8 +198,8 @@ public:
}
bool fill(uint32 max_length,char fill);
void strip_sp();
- inline void caseup() { ::caseup(Ptr,str_length); }
- inline void casedn() { ::casedn(Ptr,str_length); }
+ inline void caseup() { my_caseup(str_charset,Ptr,str_length); }
+ inline void casedn() { my_casedn(str_charset,Ptr,str_length); }
friend int sortcmp(const String *a,const String *b);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
@@ -180,4 +207,49 @@ public:
friend int wild_compare(String &match,String &wild,char escape);
uint32 numchars();
int charpos(int i,uint32 offset=0);
+
+// added by Holyfoot for "geometry" needs
+ int reserve(uint32 space_needed)
+ {
+ return realloc(str_length + space_needed);
+ }
+ int reserve(uint32 space_needed, uint32 grow_by);
+
+// these append operations do NOT check alloced memory
+// q_*** methods writes values of parameters itself
+// qs_*** methods writes string representation of value
+ void q_append(const char &c)
+ {
+ Ptr[str_length++] = c;
+ }
+ void q_append(const uint32 &n)
+ {
+ int4store(Ptr + str_length, n);
+ str_length += 4;
+ }
+ void q_append(double d)
+ {
+ float8store(Ptr + str_length, d);
+ str_length += 8;
+ }
+ void q_append(double *d)
+ {
+ float8store(Ptr + str_length, *d);
+ str_length += 8;
+ }
+ void q_append(const char *data, uint32 data_len)
+ {
+ memcpy(Ptr + str_length, data, data_len);
+ str_length += data_len;
+ }
+
+ void WriteAtPosition(int position, uint32 value)
+ {
+ int4store(Ptr + position,value);
+ }
+
+ void qs_append(const char *str);
+ void qs_append(double d);
+ void qs_append(double *d);
+ void qs_append(const char &c);
};
diff --git a/extra/mysql_install.c b/extra/mysql_install.c
index 1fa62f35b7e..3f716dccef5 100644
--- a/extra/mysql_install.c
+++ b/extra/mysql_install.c
@@ -155,7 +155,7 @@ static int get_answer(QUESTION_WIDGET* w)
char c;
if (!fgets(buf,sizeof(buf),w->in))
die("Failed fgets on input stream");
- switch ((c=tolower(*buf)))
+ switch ((c=my_tolower(system_charset_info,*buf)))
{
case '\n':
return w->default_ind;
diff --git a/extra/replace.c b/extra/replace.c
index 41312f5e3d4..5826586988a 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -113,7 +113,7 @@ char *argv[];
exit(1);
for (i=1,pos=word_end_chars ; i < 256 ; i++)
- if (isspace(i))
+ if (my_isspace(system_charset_info,i))
*pos++=i;
*pos=0;
if (!(replace=init_replace((char**) from.typelib.type_names,
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index 6c2ddf66027..7d1d125ec7e 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -178,9 +178,9 @@ trace dump and specify the path to it with -s or --symbols-file");
static uchar hex_val(char c)
{
uchar l;
- if(isdigit(c))
+ if(my_isdigit(system_charset_info,c))
return c - '0';
- l = tolower(c);
+ l = my_tolower(system_charset_info,c);
if(l < 'a' || l > 'f')
return HEX_INVALID;
return (uchar)10 + ((uchar)c - (uchar)'a');
@@ -206,10 +206,10 @@ static int init_sym_entry(SYM_ENTRY* se, char* buf)
if(!se->addr)
return -1;
- while(isspace(*buf++))
+ while ( my_isspace(system_charset_info,*buf++))
/* empty */;
- while(isspace(*buf++))
+ while (my_isspace(system_charset_info,*buf++))
/* empty - skip more space */;
--buf;
/* now we are on the symbol */
@@ -293,7 +293,7 @@ static void do_resolve()
while(fgets(buf, sizeof(buf), fp_dump))
{
p = buf;
- while(isspace(*p))
+ while(my_isspace(system_charset_info,*p))
++p;
/* skip space */;
diff --git a/extra/resolveip.c b/extra/resolveip.c
index 2d21d5c672c..20630d8414d 100644
--- a/extra/resolveip.c
+++ b/extra/resolveip.c
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
{
ip = *argv++;
- if (isdigit(ip[0]))
+ if (my_isdigit(system_charset_info,ip[0]))
{
taddr = inet_addr(ip);
if (taddr == htonl(INADDR_BROADCAST))
diff --git a/heap/hp_hash.c b/heap/hp_hash.c
index e29e51d2b75..519779d330d 100644
--- a/heap/hp_hash.c
+++ b/heap/hp_hash.c
@@ -173,7 +173,7 @@ ulong _hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
for (; pos < (uchar*) key ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2) *
- ((uint) my_sort_order[(uint) *pos])) + (nr << 8);
+ ((uint) default_charset_info->sort_order[(uint) *pos])) + (nr << 8);
nr2+=3;
}
}
@@ -212,7 +212,7 @@ ulong _hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec)
for (; pos < end ; pos++)
{
nr^=(ulong) ((((uint) nr & 63)+nr2)*
- ((uint) my_sort_order[(uint) *pos]))+ (nr << 8);
+ ((uint) default_charset_info->sort_order[(uint) *pos]))+ (nr << 8);
nr2+=3;
}
}
@@ -343,7 +343,7 @@ int _hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2)
}
if (seg->type == HA_KEYTYPE_TEXT)
{
- if (my_sortcmp(rec1+seg->start,rec2+seg->start,seg->length))
+ if (my_sortcmp(default_charset_info,rec1+seg->start,rec2+seg->start,seg->length))
return 1;
}
else
@@ -375,7 +375,12 @@ int _hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key)
}
if (seg->type == HA_KEYTYPE_TEXT)
{
- if (my_sortcmp(rec+seg->start,key,seg->length))
+ /*
+ BAR TODO: this will not use default_charset_info
+ I need Ram to apply his HEAP patches with
+ CHARSET_INFO field in HP segments
+ */
+ if (my_sortcmp(default_charset_info,rec+seg->start,key,seg->length))
return 1;
}
else
diff --git a/include/m_ctype.h b/include/m_ctype.h
index 9e29263ee54..43ae23e7ac3 100644
--- a/include/m_ctype.h
+++ b/include/m_ctype.h
@@ -39,11 +39,12 @@ typedef struct charset_info_st
uchar *sort_order;
uint strxfrm_multiply;
- int (*strcoll)(const uchar *, const uchar *);
- int (*strxfrm)(uchar *, const uchar *, int);
- int (*strnncoll)(const uchar *, int, const uchar *, int);
- int (*strnxfrm)(uchar *, const uchar *, int, int);
- my_bool (*like_range)(const char *, uint, pchar, uint,
+ int (*strnncoll)(struct charset_info_st *,
+ const uchar *, uint, const uchar *, uint);
+ int (*strnxfrm)(struct charset_info_st *,
+ uchar *, uint, const uchar *, uint);
+ my_bool (*like_range)(struct charset_info_st *,
+ const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
uint mbmaxlen;
@@ -52,19 +53,21 @@ typedef struct charset_info_st
int (*mbcharlen)(uint);
/* Functions for case convertion */
- void (*caseup_str)(struct charset_info_st *, uchar *);
- void (*casedn_str)(struct charset_info_st *, uchar *);
- void (*caseup)(struct charset_info_st *, uchar *, uint);
- void (*casedn)(struct charset_info_st *, uchar *, uint);
+ void (*caseup_str)(struct charset_info_st *, char *);
+ void (*casedn_str)(struct charset_info_st *, char *);
+ void (*caseup)(struct charset_info_st *, char *, uint);
+ void (*casedn)(struct charset_info_st *, char *, uint);
/* Functions for case comparison */
- int (*strcasecmp)(struct charset_info_st *, const uchar *, const uchar *);
- int (*strncasecmp)(struct charset_info_st *, const uchar *, const uchar *, uint);
+ int (*strcasecmp)(struct charset_info_st *, const char *, const char *);
+ int (*strncasecmp)(struct charset_info_st *, const char *, const char *, uint);
+ char max_sort_char; /* For LIKE otimization */
} CHARSET_INFO;
/* strings/ctype.c */
extern CHARSET_INFO *default_charset_info;
+extern CHARSET_INFO *system_charset_info;
extern CHARSET_INFO *find_compiled_charset(uint cs_number);
extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
extern CHARSET_INFO compiled_charsets[];
@@ -75,34 +78,32 @@ extern const char *compiled_charset_name(uint charset_number);
#define MY_CHARSET_CURRENT (default_charset_info->number)
/* declarations for simple charsets */
-extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, const uchar *, int, int);
-extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, int, const uchar *, int);
+extern int my_strnxfrm_simple(CHARSET_INFO *, char *, uint, const char *, uint);
+extern int my_strnncoll_simple(CHARSET_INFO *, const char *, uint, const char *, uint);
/* Functions for 8bit */
-extern void my_caseup_str_8bit(CHARSET_INFO *, uchar *);
-extern void my_casedn_str_8bit(CHARSET_INFO *, uchar *);
-extern void my_caseup_8bit(CHARSET_INFO *, uchar *, uint);
-extern void my_casedn_8bit(CHARSET_INFO *, uchar *, uint);
+extern void my_caseup_str_8bit(CHARSET_INFO *, char *);
+extern void my_casedn_str_8bit(CHARSET_INFO *, char *);
+extern void my_caseup_8bit(CHARSET_INFO *, char *, uint);
+extern void my_casedn_8bit(CHARSET_INFO *, char *, uint);
-extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const uchar *, const uchar *);
-extern int my_strncasecmp_8bit(CHARSET_INFO * cs, const uchar *, const uchar *, uint);
+extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
+extern int my_strncasecmp_8bit(CHARSET_INFO * cs, const char *, const char *, uint);
/* Functions for multibyte charsets */
-extern void my_caseup_str_mb(CHARSET_INFO *, uchar *);
-extern void my_casedn_str_mb(CHARSET_INFO *, uchar *);
-extern void my_caseup_mb(CHARSET_INFO *, uchar *, uint);
-extern void my_casedn_mb(CHARSET_INFO *, uchar *, uint);
+extern void my_caseup_str_mb(CHARSET_INFO *, char *);
+extern void my_casedn_str_mb(CHARSET_INFO *, char *);
+extern void my_caseup_mb(CHARSET_INFO *, char *, uint);
+extern void my_casedn_mb(CHARSET_INFO *, char *, uint);
-extern int my_strcasecmp_mb(CHARSET_INFO * cs,const uchar *, const uchar *);
-extern int my_strncasecmp_mb(CHARSET_INFO * cs,const uchar *, const uchar *t, uint);
+extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);
+extern int my_strncasecmp_mb(CHARSET_INFO * cs,const char *, const char *t, uint);
/* declarations for the big5 character set */
extern uchar ctype_big5[], to_lower_big5[], to_upper_big5[], sort_order_big5[];
-extern int my_strcoll_big5(const uchar *, const uchar *);
-extern int my_strxfrm_big5(uchar *, const uchar *, int);
-extern int my_strnncoll_big5(const uchar *, int, const uchar *, int);
-extern int my_strnxfrm_big5(uchar *, const uchar *, int, int);
-extern my_bool my_like_range_big5(const char *, uint, pchar, uint,
+extern int my_strnncoll_big5(CHARSET_INFO *,const uchar *, uint, const uchar *, uint);
+extern int my_strnxfrm_big5(CHARSET_INFO *,uchar *, uint, const uchar *, uint);
+extern my_bool my_like_range_big5(CHARSET_INFO *,const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
extern int ismbchar_big5(const char *, const char *);
extern my_bool ismbhead_big5(uint);
@@ -110,11 +111,10 @@ extern int mbcharlen_big5(uint);
/* declarations for the czech character set */
extern uchar ctype_czech[], to_lower_czech[], to_upper_czech[], sort_order_czech[];
-extern int my_strcoll_czech(const uchar *, const uchar *);
-extern int my_strxfrm_czech(uchar *, const uchar *, int);
-extern int my_strnncoll_czech(const uchar *, int, const uchar *, int);
-extern int my_strnxfrm_czech(uchar *, const uchar *, int, int);
-extern my_bool my_like_range_czech(const char *, uint, pchar, uint,
+extern int my_strnncoll_czech(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
+extern int my_strnxfrm_czech(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
+extern my_bool my_like_range_czech(CHARSET_INFO *,
+ const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
/* declarations for the euc_kr character set */
@@ -131,11 +131,9 @@ extern int mbcharlen_gb2312(uint);
/* declarations for the gbk character set */
extern uchar ctype_gbk[], to_lower_gbk[], to_upper_gbk[], sort_order_gbk[];
-extern int my_strcoll_gbk(const uchar *, const uchar *);
-extern int my_strxfrm_gbk(uchar *, const uchar *, int);
-extern int my_strnncoll_gbk(const uchar *, int, const uchar *, int);
-extern int my_strnxfrm_gbk(uchar *, const uchar *, int, int);
-extern my_bool my_like_range_gbk(const char *, uint, pchar, uint,
+extern int my_strnncoll_gbk(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
+extern int my_strnxfrm_gbk(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
+extern my_bool my_like_range_gbk(CHARSET_INFO *, const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
extern int ismbchar_gbk(const char *, const char *);
extern my_bool ismbhead_gbk(uint);
@@ -143,20 +141,16 @@ extern int mbcharlen_gbk(uint);
/* declarations for the latin1_de character set */
extern uchar ctype_latin1_de[], to_lower_latin1_de[], to_upper_latin1_de[], sort_order_latin1_de[];
-extern int my_strcoll_latin1_de(const uchar *, const uchar *);
-extern int my_strxfrm_latin1_de(uchar *, const uchar *, int);
-extern int my_strnncoll_latin1_de(const uchar *, int, const uchar *, int);
-extern int my_strnxfrm_latin1_de(uchar *, const uchar *, int, int);
-extern my_bool my_like_range_latin1_de(const char *, uint, pchar, uint,
+extern int my_strnncoll_latin1_de(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
+extern int my_strnxfrm_latin1_de(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
+extern my_bool my_like_range_latin1_de(CHARSET_INFO *, const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
/* declarations for the sjis character set */
extern uchar ctype_sjis[], to_lower_sjis[], to_upper_sjis[], sort_order_sjis[];
-extern int my_strcoll_sjis(const uchar *, const uchar *);
-extern int my_strxfrm_sjis(uchar *, const uchar *, int);
-extern int my_strnncoll_sjis(const uchar *, int, const uchar *, int);
-extern int my_strnxfrm_sjis(uchar *, const uchar *, int, int);
-extern my_bool my_like_range_sjis(const char *, uint, pchar, uint,
+extern int my_strnncoll_sjis(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
+extern int my_strnxfrm_sjis(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
+extern my_bool my_like_range_sjis(CHARSET_INFO *, const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
extern int ismbchar_sjis(const char *, const char *);
extern my_bool ismbhead_sjis(uint);
@@ -164,11 +158,9 @@ extern int mbcharlen_sjis(uint);
/* declarations for the tis620 character set */
extern uchar ctype_tis620[], to_lower_tis620[], to_upper_tis620[], sort_order_tis620[];
-extern int my_strcoll_tis620(const uchar *, const uchar *);
-extern int my_strxfrm_tis620(uchar *, const uchar *, int);
-extern int my_strnncoll_tis620(const uchar *, int, const uchar *, int);
-extern int my_strnxfrm_tis620(uchar *, const uchar *, int, int);
-extern my_bool my_like_range_tis620(const char *, uint, pchar, uint,
+extern int my_strnncoll_tis620(CHARSET_INFO *, const uchar *, uint, const uchar *, uint);
+extern int my_strnxfrm_tis620(CHARSET_INFO *, uchar *, uint, const uchar *, uint);
+extern my_bool my_like_range_tis620(CHARSET_INFO *, const char *, uint, pchar, uint,
char *, char *, uint *, uint *);
/* declarations for the ujis character set */
@@ -214,32 +206,11 @@ extern int mbcharlen_ujis(uint);
#define _B 0100 /* Blank */
#define _X 0200 /* heXadecimal digit */
-#ifndef HIDE_OLD_CTYPE
-#define my_ctype (default_charset_info->ctype)
-#define my_to_upper (default_charset_info->to_upper)
-#define my_to_lower (default_charset_info->to_lower)
-#define my_sort_order (default_charset_info->sort_order)
-
-#define _toupper(c) (char) my_to_upper[(uchar) (c)]
-#define _tolower(c) (char) my_to_lower[(uchar) (c)]
-#define toupper(c) (char) my_to_upper[(uchar) (c)]
-#define tolower(c) (char) my_to_lower[(uchar) (c)]
-
-#define isalpha(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L))
-#define isupper(c) ((my_ctype+1)[(uchar) (c)] & _U)
-#define islower(c) ((my_ctype+1)[(uchar) (c)] & _L)
-#define isdigit(c) ((my_ctype+1)[(uchar) (c)] & _N)
-#define isxdigit(c) ((my_ctype+1)[(uchar) (c)] & _X)
-#define isalnum(c) ((my_ctype+1)[(uchar) (c)] & (_U | _L | _N))
-#define isspace(c) ((my_ctype+1)[(uchar) (c)] & _S)
-#define ispunct(c) ((my_ctype+1)[(uchar) (c)] & _P)
-#define isprint(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N | _B))
-#define isgraph(c) ((my_ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
-#define iscntrl(c) ((my_ctype+1)[(uchar) (c)] & _C)
-#endif
#define isascii(c) (!((c) & ~0177))
#define toascii(c) ((c) & 0177)
+#define tocntrl(c) ((c) & 31)
+#define toprint(c) ((c) | 64)
#ifdef ctype
#undef ctype
@@ -259,26 +230,28 @@ extern int mbcharlen_ujis(uint);
#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_P | _U | _L | _N))
#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _C)
-#define use_strcoll(s) ((s)->strcoll != NULL)
-#define MY_STRXFRM_MULTIPLY (default_charset_info->strxfrm_multiply)
-#define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c), (d)))
-#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((a), (b), (c), (d)))
-#define my_strxfrm(s, a, b, c, d) ((s)->strnxfrm((a), (b), (c)))
-#define my_strcoll(s, a, b) ((s)->strcoll((a), (b)))
+/* Some macros that should be cleaned up a little */
+#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
+#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
+
+#define use_strcoll(s) ((s)->strnncoll != NULL)
+#define my_strnxfrm(s, a, b, c, d) ((s)->strnxfrm((s), (a), (b), (c), (d)))
+#define my_strnncoll(s, a, b, c, d) ((s)->strnncoll((s), (a), (b), (c), (d)))
#define my_like_range(s, a, b, c, d, e, f, g, h) \
- ((s)->like_range((a), (b), (c), (d), (e), (f), (g), (h)))
+ ((s)->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h)))
#define use_mb(s) ((s)->ismbchar != NULL)
-#define MBMAXLEN (default_charset_info->mbmaxlen)
#define my_ismbchar(s, a, b) ((s)->ismbchar((a), (b)))
#define my_ismbhead(s, a) ((s)->ismbhead((a)))
#define my_mbcharlen(s, a) ((s)->mbcharlen((a)))
-/* Some macros that should be cleaned up a little */
-#define isvar(c) (isalnum(c) || (c) == '_')
-#define isvar_start(c) (isalpha(c) || (c) == '_')
-#define tocntrl(c) ((c) & 31)
-#define toprint(c) ((c) | 64)
+#define my_caseup(s, a, l) ((s)->caseup((s), (a), (l)))
+#define my_casedn(s, a, l) ((s)->casedn((s), (a), (l)))
+#define my_caseup_str(s, a) ((s)->caseup_str((s), (a)))
+#define my_casedn_str(s, a) ((s)->casedn_str((s), (a)))
+#define my_strcasecmp(s, a, b) ((s)->strcasecmp((s), (a), (b)))
+#define my_strncasecmp(s, a, b, l) ((s)->strncasecmp((s), (a), (b), (l)))
+
/* XXX: still need to take care of this one */
#ifdef MY_CHARSET_TIS620
diff --git a/include/my_sys.h b/include/my_sys.h
index 61f93d665cd..ab6ae170651 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -563,11 +563,7 @@ extern void allow_break(void);
#endif
extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
-extern void caseup(my_string str,uint length);
-extern void casedn(my_string str,uint length);
-extern void caseup_str(my_string str);
-extern void casedn_str(my_string str);
-extern void case_sort(my_string str,uint length);
+extern void case_sort(CHARSET_INFO *cs, my_string str,uint length);
extern uint dirname_part(my_string to,const char *name);
extern uint dirname_length(const char *name);
#define base_name(A) (A+dirname_length(A))
@@ -592,18 +588,14 @@ extern my_string my_path(my_string to,const char *progname,
extern my_string my_load_path(my_string to, const char *path,
const char *own_path_prefix);
extern int wild_compare(const char *str,const char *wildstr);
-extern my_string my_strcasestr(const char *src,const char *suffix);
-extern int my_strcasecmp(const char *s,const char *t);
-extern int my_strsortcmp(const char *s,const char *t);
-extern int my_casecmp(const char *s,const char *t,uint length);
-extern int my_sortcmp(const char *s,const char *t,uint length);
-extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
+extern int my_sortcmp(CHARSET_INFO *cs, const char *s,const char *t,uint length);
+extern int my_sortncmp(CHARSET_INFO *cs, const char *s,uint s_len, const char *t,uint t_len);
extern WF_PACK *wf_comp(my_string str);
extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
extern void wf_end(struct wild_file_pack *buffer);
extern size_s stripp_sp(my_string str);
extern void get_date(my_string to,int timeflag,time_t use_time);
-extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage);
+extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr,pbool remove_garbage);
extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
uint reclength,enum cache_type type,
pbool use_async_io);
diff --git a/isam/_key.c b/isam/_key.c
index c0d667cb32d..0bedb428808 100644
--- a/isam/_key.c
+++ b/isam/_key.c
@@ -58,7 +58,7 @@ uint _nisam_make_key(register N_INFO *info, uint keynr, uchar *key, const char *
#endif
{
if (type == HA_KEYTYPE_TEXT)
- case_sort((byte*) key,length);
+ case_sort(default_charset_info,(byte*) key,length);
}
key+=length;
}
@@ -71,7 +71,7 @@ uint _nisam_make_key(register N_INFO *info, uint keynr, uchar *key, const char *
#endif
{
if (type == HA_KEYTYPE_TEXT)
- case_sort((byte*) key,(uint) keyseg->base.length);
+ case_sort(default_charset_info,(byte*) key,(uint) keyseg->base.length);
}
#ifdef NAN_TEST
else if (type == HA_KEYTYPE_FLOAT)
@@ -154,7 +154,7 @@ uint _nisam_pack_key(register N_INFO *info, uint keynr, uchar *key, uchar *old,
#endif
{
if (type == HA_KEYTYPE_TEXT)
- case_sort((byte*) key,length);
+ case_sort(default_charset_info,(byte*) key,length);
}
key+= length;
}
diff --git a/isam/_search.c b/isam/_search.c
index 57787d61818..d76a8ce3097 100644
--- a/isam/_search.c
+++ b/isam/_search.c
@@ -515,11 +515,13 @@ int _nisam_key_cmp(register N_KEYSEG *keyseg, register uchar *a, register uchar
if (*a++ != *b++)
{
a--; b--;
- if (isdigit((char) *a) && isdigit((char) *b))
+ if (my_isdigit(default_charset_info, (char) *a) &&
+ my_isdigit(default_charset_info, (char) *b))
return ((int) *a - (int) *b);
- if (*a == '-' || isdigit((char) *b))
+ if (*a == '-' || my_isdigit(default_charset_info,(char) *b))
return (-1);
- if (*b == '-' || *b++ == ' ' || isdigit((char) *a))
+ if (*b == '-' || *b++ == ' ' ||
+ my_isdigit(default_charset_info,(char) *a))
return (1);
if (*a++ == ' ')
return (-1);
@@ -539,11 +541,13 @@ int _nisam_key_cmp(register N_KEYSEG *keyseg, register uchar *a, register uchar
if (*a++ != *b++)
{
a--; b--;
- if (isdigit((char) *a) && isdigit((char) *b))
+ if (my_isdigit(default_charset_info,(char) *a) &&
+ my_isdigit(default_charset_info,(char) *b))
return ((int) *a - (int) *b);
- if (*a == '-' || isdigit((char) *b))
+ if (*a == '-' || my_isdigit(default_charset_info,(char) *b))
return (-1);
- if (*b == '-' || *b++ == ' ' || isdigit((char) *a))
+ if (*b == '-' || *b++ == ' ' ||
+ my_isdigit(default_charset_info,(char) *a))
return (1);
if (*a++ == ' ')
return -1;
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 93cbf130f18..f9b69124dbe 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -41,7 +41,7 @@ mystringsobjects = strmov.lo strxmov.lo strxnmov.lo strnmov.lo \
strcend.lo bcmp.lo \
bchange.lo bmove.lo bmove_upp.lo longlong2str.lo \
strtoull.lo strtoll.lo llstr.lo \
- ctype.lo $(LTCHARSET_OBJS)
+ ctype.lo ctype-simple.lo ctype-mb.lo $(LTCHARSET_OBJS)
mystringsextra= strto.c
dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo
mysysheaders = mysys_priv.h my_static.h
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 4e4518bbe10..c3ef33296b1 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1282,8 +1282,8 @@ STDCALL mysql_rpl_query_type(const char* q, int len)
for(; q < q_end; ++q)
{
char c;
- if (isalpha(c=*q))
- switch(tolower(c))
+ if (my_isalpha(system_charset_info,c=*q))
+ switch(my_tolower(system_charset_info,c))
{
case 'i': /* insert */
case 'u': /* update or unlock tables */
@@ -1292,9 +1292,11 @@ STDCALL mysql_rpl_query_type(const char* q, int len)
case 'a': /* alter */
return MYSQL_RPL_MASTER;
case 'c': /* create or check */
- return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_MASTER ;
+ return my_tolower(system_charset_info,q[1]) == 'h' ? MYSQL_RPL_ADMIN :
+ MYSQL_RPL_MASTER;
case 's': /* select or show */
- return tolower(q[1]) == 'h' ? MYSQL_RPL_ADMIN : MYSQL_RPL_SLAVE;
+ return my_tolower(system_charset_info,q[1]) == 'h' ? MYSQL_RPL_ADMIN :
+ MYSQL_RPL_SLAVE;
case 'f': /* flush */
case 'r': /* repair */
case 'g': /* grant */
diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c
index 6308694b58e..c40145b87ed 100644
--- a/myisam/ft_dump.c
+++ b/myisam/ft_dump.c
@@ -106,7 +106,7 @@ int main(int argc,char *argv[])
#endif
snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1);
- casedn_str(buf);
+ my_casedn_str(default_charset_info,buf);
total++;
lengths[keylen]++;
diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c
index c1b1190bcab..b241ae9be88 100644
--- a/myisam/ft_parser.c
+++ b/myisam/ft_parser.c
@@ -107,13 +107,13 @@ FT_WORD * ft_linearize(TREE *wtree)
DBUG_RETURN(wlist);
}
-#define true_word_char(X) (isalnum(X) || (X)=='_')
+#define true_word_char(s,X) (my_isalnum(s,X) || (X)=='_')
#ifdef HYPHEN_IS_DELIM
#define misc_word_char(X) ((X)=='\'')
#else
#define misc_word_char(X) ((X)=='\'' || (X)=='-')
#endif
-#define word_char(X) (true_word_char(X) || misc_word_char(X))
+#define word_char(s,X) (true_word_char(s,X) || misc_word_char(s,X))
/* returns:
@@ -134,7 +134,11 @@ byte ft_get_word(byte **start, byte *end, FT_WORD *word, FTB_PARAM *param)
{
for (;doc<end;doc++)
{
- if (true_word_char(*doc)) break;
+ /*
+ BAR TODO: discuss with Serge how to remove
+ default_charset_info correctly
+ */
+ if (true_word_char(default_charset_info,*doc)) break;
if (*doc == FTB_LBR || *doc == FTB_RBR)
{
/* param->prev=' '; */
@@ -156,7 +160,7 @@ byte ft_get_word(byte **start, byte *end, FT_WORD *word, FTB_PARAM *param)
mwc=0;
for (word->pos=doc; doc<end; doc++)
- if (true_word_char(*doc))
+ if (true_word_char(default_charset_info,*doc))
mwc=0;
else if (!misc_word_char(*doc) || mwc++)
break;
@@ -185,12 +189,12 @@ byte ft_simple_get_word(byte **start, byte *end, FT_WORD *word)
{
for (;doc<end;doc++)
{
- if (true_word_char(*doc)) break;
+ if (true_word_char(default_charset_info,*doc)) break;
}
mwc=0;
for(word->pos=doc; doc<end; doc++)
- if (true_word_char(*doc))
+ if (true_word_char(default_charset_info,*doc))
mwc=0;
else if (!misc_word_char(*doc) || mwc++)
break;
diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c
index 135589bb53c..412c493db9a 100644
--- a/myisam/mi_test1.c
+++ b/myisam/mi_test1.c
@@ -458,19 +458,19 @@ static void update_record(char *record)
ptr=blob_key;
memcpy_fixed(pos+4,&ptr,sizeof(char*)); /* Store pointer to new key */
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
- casedn(blob_key,length);
+ my_casedn(default_charset_info,blob_key,length);
pos+=recinfo[1].length;
}
else if (recinfo[1].type == FIELD_VARCHAR)
{
uint length=uint2korr(pos);
- casedn(pos+2,length);
+ my_casedn(default_charset_info,pos+2,length);
pos+=recinfo[1].length;
}
else
{
if (keyinfo[0].seg[0].type != HA_KEYTYPE_NUM)
- casedn(pos,keyinfo[0].seg[0].length);
+ my_casedn(default_charset_info,pos,keyinfo[0].seg[0].length);
pos+=recinfo[1].length;
}
diff --git a/mysys/charset.c b/mysys/charset.c
index 93e8b697904..1d84bb67d68 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -68,7 +68,7 @@ static my_bool get_word(struct simpleconfig_buf_st *fb, char *buf)
for (;;)
{
- while (isspace(*endptr))
+ while (my_isspace(system_charset_info, *endptr))
++endptr;
if (*endptr && *endptr != '#') /* Not comment */
break; /* Found something */
@@ -77,7 +77,7 @@ static my_bool get_word(struct simpleconfig_buf_st *fb, char *buf)
endptr = fb->buf;
}
- while (!isspace(*endptr))
+ while (!my_isspace(system_charset_info, *endptr))
*buf++= *endptr++;
*buf=0;
fb->p = endptr;
@@ -540,11 +540,9 @@ void _print_csinfo(CHARSET_INFO *cs)
printf("to_lower:\n"); _print_array(cs->to_lower, 256);
printf("to_upper:\n"); _print_array(cs->to_upper, 256);
printf("sort_order:\n"); _print_array(cs->sort_order, 256);
- printf("collate: %3s (%d, %p, %p, %p, %p, %p)\n",
+ printf("collate: %3s (%d, %p, %p, %p)\n",
cs->strxfrm_multiply ? "yes" : "no",
cs->strxfrm_multiply,
- cs->strcoll,
- cs->strxfrm,
cs->strnncoll,
cs->strnxfrm,
cs->like_range);
diff --git a/mysys/default.c b/mysys/default.c
index d3c1b3815eb..ad34d4b949d 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -247,7 +247,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
{
line++;
/* Ignore comment and empty lines */
- for (ptr=buff ; isspace(*ptr) ; ptr++ ) ;
+ for (ptr=buff ; my_isspace(system_charset_info,*ptr) ; ptr++ ) ;
if (*ptr == '#' || *ptr == ';' || !*ptr)
continue;
if (*ptr == '[') /* Group name */
@@ -260,7 +260,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
name,line);
goto err;
}
- for ( ; isspace(end[-1]) ; end--) ; /* Remove end space */
+ for ( ; my_isspace(system_charset_info,end[-1]) ; end--) ;/* Remove end space */
end[0]=0;
read_values=find_type(ptr,group,3) > 0;
continue;
@@ -276,7 +276,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
continue;
if (!(end=value=strchr(ptr,'=')))
end=strend(ptr); /* Option without argument */
- for ( ; isspace(end[-1]) ; end--) ;
+ for ( ; my_isspace(system_charset_info,end[-1]) ; end--) ;
if (!value)
{
if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3)))
@@ -289,9 +289,9 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
{
/* Remove pre- and end space */
char *value_end;
- for (value++ ; isspace(*value); value++) ;
+ for (value++ ; my_isspace(system_charset_info,*value); value++) ;
value_end=strend(value);
- for ( ; isspace(value_end[-1]) ; value_end--) ;
+ for ( ; my_isspace(system_charset_info,value_end[-1]) ; value_end--) ;
if (value_end < value) /* Empty string */
value_end=value;
if (!(tmp=alloc_root(alloc,(uint) (end-ptr)+3 +
diff --git a/mysys/getvar.c b/mysys/getvar.c
index bb470423c57..b5cc123f4b4 100644
--- a/mysys/getvar.c
+++ b/mysys/getvar.c
@@ -58,14 +58,15 @@ my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
longlong num;
/* Skip end space from variable */
- for (var_end=end ; end > str && isspace(var_end[-1]) ; var_end--) ;
+ for (var_end=end ; end > str && my_isspace(system_charset_info, var_end[-1]) ; var_end--) ;
length=(uint) (var_end-str);
/* Skip start space from argument */
- for (end++ ; isspace(*end) ; end++) ;
+ for (end++ ; my_isspace(system_charset_info, *end) ; end++) ;
for (var=vars,found=0 ; (name=var->name) ; var++)
{
- if (!my_casecmp(name,str,length))
+ /* BAR TODO: remove system_charset_info */
+ if (!my_strncasecmp(system_charset_info,name,str,length))
{
found=var; found_count++;
if (!name[length])
@@ -93,7 +94,7 @@ my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
num*=1024L*1024L;
else if (endchar == 'g' || endchar == 'G')
num*=1024L*1024L*1024L;
- else if (!isdigit(endchar))
+ else if (!my_isdigit(system_charset_info, endchar))
{
fprintf(stderr,"Unknown prefix used for variable value '%s'\n",str);
DBUG_RETURN(1);
diff --git a/mysys/hash.c b/mysys/hash.c
index 0b326ebc508..f1ce5052e4f 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -129,7 +129,9 @@ static uint calc_hashnr_caseup(const byte *key,uint length)
register uint nr=1, nr2=4;
while (length--)
{
- nr^= (((nr & 63)+nr2)*((uint) (uchar) toupper(*key++)))+ (nr << 8);
+ /* BAR TODO: remove default_charset_info */
+ nr^= (((nr & 63)+nr2)*
+ ((uint) (uchar) my_toupper(default_charset_info, *key++)))+ (nr << 8);
nr2+=3;
}
return((uint) nr);
@@ -271,9 +273,10 @@ static int hashcmp(HASH *hash,HASH_LINK *pos,const byte *key,uint length)
{
uint rec_keylength;
byte *rec_key=hash_key(hash,pos->data,&rec_keylength,1);
+ /* BAR TODO: remove default_charset_info */
return (length && length != rec_keylength) ||
(hash->flags & HASH_CASE_INSENSITIVE ?
- my_casecmp(rec_key,key,rec_keylength) :
+ my_strncasecmp(default_charset_info, rec_key,key,rec_keylength) :
memcmp(rec_key,key,rec_keylength));
}
diff --git a/mysys/mf_casecnv.c b/mysys/mf_casecnv.c
index 0302688ad1f..510a9b08f76 100644
--- a/mysys/mf_casecnv.c
+++ b/mysys/mf_casecnv.c
@@ -28,234 +28,50 @@
#include <m_string.h>
#endif
- /* string to uppercase */
-
-void caseup_str(my_string str)
-{
-#ifdef USE_MB
- if (use_mb(default_charset_info))
- {
- register uint32 l;
- register char *end=str+strlen(str);
- while (*str)
- {
- if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
- else *str=toupper(*str),++str;
- }
- }
- else
-#endif
- while ((*str = toupper(*str)) != 0)
- str++;
-} /* caseup_str */
-
- /* string to lowercase */
-
-void casedn_str(my_string str)
-{
-#ifdef USE_MB
- if (use_mb(default_charset_info))
- {
- register uint32 l;
- register char *end=str+strlen(str);
- while (*str)
- {
- if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
- else *str=tolower(*str),++str;
- }
- }
- else
-#endif
- while ((*str= tolower(*str)) != 0)
- str++;
-} /* casedn_str */
-
-
- /* to uppercase */
-
-void caseup(my_string str, uint length)
-{
-#ifdef USE_MB
- if (use_mb(default_charset_info))
- {
- register uint32 l;
- register char *end=str+length;
- while (str<end)
- {
- if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
- else *str=toupper(*str),++str;
- }
- }
- else
-#endif
- for ( ; length>0 ; length--, str++)
- *str= toupper(*str);
-} /* caseup */
-
- /* to lowercase */
-
-void casedn(my_string str, uint length)
-{
-#ifdef USE_MB
- if (use_mb(default_charset_info))
- {
- register uint32 l;
- register char *end=str+length;
- while (str<end)
- {
- if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
- else *str=tolower(*str),++str;
- }
- }
- else
-#endif
- for ( ; length>0 ; length--, str++)
- *str= tolower(*str);
-} /* casedn */
/* to sort-string that can be compared to get text in order */
-void case_sort(my_string str, uint length)
+void case_sort(CHARSET_INFO *cs, my_string str, uint length)
{
for ( ; length>0 ; length--, str++)
- *str= (char) my_sort_order[(uchar) *str];
+ *str= (char) cs->sort_order[(uchar) *str];
} /* case_sort */
- /* find string in another with no case_sensivity */
-
-/* ToDo: This function should be modified to support multibyte charset.
- However it is not used untill 3.23.5.
- Wei He (hewei@mail.ied.ac.cn)
-*/
-
-my_string my_strcasestr(const char *str, const char *search)
-{
- uchar *i,*j,*pos;
-
- pos=(uchar*) str;
-skipp:
- while (*pos != '\0')
- {
- if (toupper((uchar) *pos++) == toupper((uchar) *search))
- {
- i=(uchar*) pos; j=(uchar*) search+1;
- while (*j)
- if (toupper(*i++) != toupper(*j++)) goto skipp;
- return ((char*) pos-1);
- }
- }
- return ((my_string) 0);
-} /* strcstr */
-
-
- /* compare strings without regarding to case */
-
-int my_strcasecmp(const char *s, const char *t)
-{
-#ifdef USE_MB
- if (use_mb(default_charset_info))
- {
- register uint32 l;
- register const char *end=s+strlen(s);
- while (s<end)
- {
- if ((l=my_ismbchar(default_charset_info, s,end)))
- {
- while (l--)
- if (*s++ != *t++) return 1;
- }
- else if (my_ismbhead(default_charset_info, *t)) return 1;
- else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1;
- }
- return *t;
- }
- else
-#endif
- {
- while (toupper((uchar) *s) == toupper((uchar) *t++))
- if (!*s++) return 0;
- return ((int) toupper((uchar) s[0]) - (int) toupper((uchar) t[-1]));
- }
-}
-
-
-int my_casecmp(const char *s, const char *t, uint len)
-{
-#ifdef USE_MB
- if (use_mb(default_charset_info))
- {
- register uint32 l;
- register const char *end=s+len;
- while (s<end)
- {
- if ((l=my_ismbchar(default_charset_info, s,end)))
- {
- while (l--)
- if (*s++ != *t++) return 1;
- }
- else if (my_ismbhead(default_charset_info, *t)) return 1;
- else if (toupper((uchar) *s++) != toupper((uchar) *t++)) return 1;
- }
- return 0;
- }
- else
-#endif
- {
- while (len-- != 0 && toupper(*s++) == toupper(*t++)) ;
- return (int) len+1;
- }
-}
-
-
-int my_strsortcmp(const char *s, const char *t)
-{
-#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info))
- return my_strcoll(default_charset_info, (uchar *)s, (uchar *)t);
- else
-#endif
- {
- while (my_sort_order[(uchar) *s] == my_sort_order[(uchar) *t++])
- if (!*s++) return 0;
- return ((int) my_sort_order[(uchar) s[0]] -
- (int) my_sort_order[(uchar) t[-1]]);
- }
-}
-int my_sortcmp(const char *s, const char *t, uint len)
+int my_sortcmp(CHARSET_INFO *cs, const char *s, const char *t, uint len)
{
#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info))
- return my_strnncoll(default_charset_info,
- (uchar *)s, len, (uchar *)t, len);
+ if (use_strcoll(cs))
+ return my_strnncoll(cs,(uchar *)s, len, (uchar *)t, len);
else
#endif
{
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 (cs->sort_order[(uchar) *s++] != cs->sort_order[(uchar) *t++])
+ return ((int) cs->sort_order[(uchar) s[-1]] -
+ (int) cs->sort_order[(uchar) t[-1]]);
}
return 0;
}
}
-int my_sortncmp(const char *s, uint s_len, const char *t, uint t_len)
+int my_sortncmp(CHARSET_INFO *cs,
+ const char *s, uint s_len,
+ const char *t, uint t_len)
{
#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info))
- return my_strnncoll(default_charset_info,
- (uchar *)s, s_len, (uchar *)t, t_len);
+ if (use_strcoll(cs))
+ return my_strnncoll(cs, (uchar *)s, s_len, (uchar *)t, t_len);
else
#endif
{
uint len= min(s_len,t_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 (cs->sort_order[(uchar) *s++] != cs->sort_order[(uchar) *t++])
+ return ((int) cs->sort_order[(uchar) s[-1]] -
+ (int) cs->sort_order[(uchar) t[-1]]);
}
return (int) (s_len - t_len);
}
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c
index 6523abcdb12..320917c8f3e 100644
--- a/mysys/mf_dirname.c
+++ b/mysys/mf_dirname.c
@@ -108,11 +108,5 @@ char *convert_dirname(char *to, const char *from, const char *from_end)
*to++=FN_LIBCHAR;
*to=0;
}
-#ifdef FN_UPPER_CASE
- caseup_str(to_org);
-#endif
-#ifdef FN_LOWER_CASE
- casedn_str(to_org);
-#endif
return to; /* Pointer to end of dir */
} /* convert_dirname */
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index ab1904da162..e68f7df9d83 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -91,12 +91,6 @@ my_string fn_format(my_string to, const char *name, const char *dir,
name=buff;
}
pos=strmake(strmov(to,dev),name,length);
-#ifdef FN_UPPER_CASE
- caseup_str(to);
-#endif
-#ifdef FN_LOWER_CASE
- casedn_str(to);
-#endif
(void) strmov(pos,ext); /* Don't convert extension */
}
/*
diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c
index 127bf20e8fe..147850a10bc 100644
--- a/mysys/mf_iocache2.c
+++ b/mysys/mf_iocache2.c
@@ -249,7 +249,7 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args)
/* Found one '%' */
}
/* Skipp if max size is used (to be compatible with printf) */
- while (isdigit(*fmt) || *fmt == '.' || *fmt == '-')
+ while (my_isdigit(system_charset_info, *fmt) || *fmt == '.' || *fmt == '-')
fmt++;
if (*fmt == 's') /* String parameter */
{
diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c
index 4f7aa7da601..8ecd95137b0 100644
--- a/mysys/mf_soundex.c
+++ b/mysys/mf_soundex.c
@@ -34,12 +34,12 @@
#include <m_ctype.h>
#include "my_static.h"
-static char get_scode(char **ptr,pbool remove_garbage);
+static char get_scode(CHARSET_INFO * cs, char **ptr,pbool remove_garbage);
/* outputed string is 4 byte long */
/* out_pntr can be == in_pntr */
-void soundex(register my_string out_pntr, my_string in_pntr,
+void soundex(CHARSET_INFO * cs,register my_string out_pntr, my_string in_pntr,
pbool remove_garbage)
{
char ch,last_ch;
@@ -47,11 +47,11 @@ void soundex(register my_string out_pntr, my_string in_pntr,
if (remove_garbage)
{
- while (*in_pntr && isspace(*in_pntr)) /* Skipp pre-space */
+ while (*in_pntr && my_isspace(cs,*in_pntr)) /* Skipp pre-space */
in_pntr++;
}
- *out_pntr++ = toupper(*in_pntr); /* Copy first letter */
- last_ch = get_scode(&in_pntr,0); /* code of the first letter */
+ *out_pntr++ = my_toupper(cs,*in_pntr);/* Copy first letter */
+ last_ch = get_scode(cs,&in_pntr,0); /* code of the first letter */
/* for the first 'double-letter */
/* check. */
end=out_pntr+3; /* Loop on input letters until */
@@ -59,7 +59,7 @@ void soundex(register my_string out_pntr, my_string in_pntr,
/* letter code count = 3 */
in_pntr++;
- while (out_pntr < end && (ch = get_scode(&in_pntr,remove_garbage)) != 0)
+ while (out_pntr < end && (ch = get_scode(cs,&in_pntr,remove_garbage)) != 0)
{
in_pntr++;
if ((ch != '0') && (ch != last_ch)) /* if not skipped or double */
@@ -81,19 +81,19 @@ void soundex(register my_string out_pntr, my_string in_pntr,
else return 0
*/
-static char get_scode(char **ptr, pbool remove_garbage)
+static char get_scode(CHARSET_INFO * cs,char **ptr, pbool remove_garbage)
{
uchar ch;
if (remove_garbage)
{
- while (**ptr && !isalpha(**ptr))
+ while (**ptr && !my_isalpha(cs,**ptr))
(*ptr)++;
}
- ch=toupper(**ptr);
+ ch=my_toupper(cs,**ptr);
if (ch < 'A' || ch > 'Z')
{
- if (isalpha(ch)) /* If exetended alfa (country spec) */
+ if (my_isalpha(cs,ch)) /* If exetended alfa (country spec) */
return '0'; /* threat as vokal */
return 0; /* Can't map */
}
diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c
index e9e12c72755..3c10de1f238 100644
--- a/mysys/mf_wfile.c
+++ b/mysys/mf_wfile.c
@@ -54,13 +54,6 @@ WF_PACK *wf_comp(my_string str)
for (pos=str ; *pos ; pos++)
ant+= test(*pos == ' ' || *pos == ',');
-#ifdef FN_UPPER_CASE
- caseup(str,(int) (pos-str));
-#endif
-#ifdef FN_LOWER_CASE
- casedn(str,(int) (pos-str));
-#endif
-
if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(my_string*)+2)+
sizeof(WF_PACK)+ (uint) strlen(str)+1,
MYF(MY_WME)))
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 61f8c16aba5..fd0cdcc2289 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -62,7 +62,7 @@ int my_error(int nr,myf MyFlags, ...)
else
{
/* Skipp if max size is used (to be compatible with printf) */
- while (isdigit(*tpos) || *tpos == '.' || *tpos == '-')
+ while (my_isdigit(system_charset_info, *tpos) || *tpos == '.' || *tpos == '-')
tpos++;
if (*tpos == 'l') /* Skipp 'l' argument */
tpos++;
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index 22c6a4dbc2b..240b17ef87f 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -109,7 +109,8 @@ int my_setwd(const char *dir, myf MyFlags)
uint drive,drives;
pos++; /* Skipp FN_DEVCHAR */
- drive=(uint) (toupper(dir[0])-'A'+1); drives= (uint) -1;
+ drive=(uint) (my_toupper(system_charset_info,dir[0])-'A'+1);
+ drives= (uint) -1;
if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32)
{
#ifdef OS2
diff --git a/mysys/my_init.c b/mysys/my_init.c
index c4e6132aa9c..faf4e7f83f0 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -17,7 +17,6 @@
#include "mysys_priv.h"
#include "my_static.h"
#include "mysys_err.h"
-#include "m_ctype.h"
#include <m_string.h>
#include <m_ctype.h>
#ifdef THREAD
@@ -50,7 +49,7 @@ my_bool my_init_done=0;
static ulong atoi_octal(const char *str)
{
long int tmp;
- while (*str && isspace(*str))
+ while (*str && my_isspace(system_charset_info, *str))
str++;
str2int(str,
(*str == '0' ? 8 : 10), /* Octalt or decimalt */
diff --git a/mysys/my_vsnprintf.c b/mysys/my_vsnprintf.c
index 0fe6eff24a6..519faa1de03 100644
--- a/mysys/my_vsnprintf.c
+++ b/mysys/my_vsnprintf.c
@@ -41,7 +41,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
}
/* Skipp if max size is used (to be compatible with printf) */
fmt++;
- while (isdigit(*fmt) || *fmt == '.' || *fmt == '-')
+ while (my_isdigit(system_charset_info,*fmt) || *fmt == '.' || *fmt == '-')
fmt++;
if (*fmt == 'l')
fmt++;
diff --git a/mysys/typelib.c b/mysys/typelib.c
index e2c8eade5c8..e524f903b5d 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -47,7 +47,9 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name)
find=0;
for (pos=0 ; (j=typelib->type_names[pos]) ; pos++)
{
- for (i=x ; *i && toupper(*i) == toupper(*j) ; i++, j++) ;
+ for (i=x ;
+ *i && my_toupper(system_charset_info,*i) ==
+ my_toupper(system_charset_info,*j) ; i++, j++) ;
if (! *j)
{
while (*i == ' ')
diff --git a/sql/convert.cc b/sql/convert.cc
index 7a06208759c..1b9a94462c7 100644
--- a/sql/convert.cc
+++ b/sql/convert.cc
@@ -433,7 +433,17 @@ CONVERT *get_convert_set(const char *name)
{
for (CONVERT **ptr=convert_tables ; *ptr ; ptr++)
{
- if (!my_strcasecmp((*ptr)->name,name))
+ /*
+ BAR TODO: Monty's comments:
+ Why is this using system_charset_info ?
+ Isn't the character-set string given in the users default charset?
+ Please add a TODO note to the code that this has to be fixed when the user
+ will be able to cast strings to different character sets...
+ The current code will also not work if/when we introduce support for
+ 16 bit characters...
+ (I know that there is a LOT of changes to do if we ever want do this...)
+ */
+ if (!my_strcasecmp(system_charset_info,(*ptr)->name,name))
return (*ptr);
}
return 0;
diff --git a/sql/des_key_file.cc b/sql/des_key_file.cc
index d9c924b5a3c..ca92e38279b 100644
--- a/sql/des_key_file.cc
+++ b/sql/des_key_file.cc
@@ -70,9 +70,10 @@ load_des_key_file(const char *file_name)
{
offset=(char) (offset - '0');
// Remove newline and possible other control characters
- for (start=buf+1 ; isspace(*start) ; start++) ;
+ for (start=buf+1 ; my_isspace(system_charset_info, *start) ; start++) ;
end=buf+length;
- for (end=strend(buf) ; end > start && !isgraph(end[-1]) ; end--) ;
+ for (end=strend(buf) ;
+ end > start && !my_isgraph(system_charset_info, end[-1]) ; end--) ;
if (start != end)
{
diff --git a/sql/field.cc b/sql/field.cc
index 5d398d0ae5f..f2d9f51283a 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -68,7 +68,8 @@ const char field_separator=',';
*/
static bool
-number_dec(struct st_decstr *sdec, const char *str, const char *end)
+number_dec(CHARSET_INFO *cs, struct st_decstr *sdec,
+ const char *str, const char *end)
{
sdec->sign=sdec->extra=0;
if (str == end)
@@ -86,7 +87,7 @@ number_dec(struct st_decstr *sdec, const char *str, const char *end)
str++;
}
const char *start=str;
- while (str != end && isdigit(*str))
+ while (str != end && my_isdigit(cs,*str))
str++;
if (!(sdec->nr_length=(uint) (str-start)))
sdec->extra=1; // We must put one 0 before .
@@ -95,13 +96,13 @@ number_dec(struct st_decstr *sdec, const char *str, const char *end)
{
str++;
start=str;
- while (str != end && isdigit(*str))
+ while (str != end && my_isdigit(cs,*str))
str++;
}
sdec->nr_dec=(uint) (str-start);
if (current_thd->count_cuted_fields)
{
- while (str != end && isspace(*str))
+ while (str != end && my_isspace(cs,*str))
str++; /* purecov: inspected */
if (str != end)
{
@@ -135,7 +136,8 @@ bool test_if_int(const char *str,int length)
{
const char *end=str+length;
- while (str != end && isspace(*str)) // Allow start space
+ // Allow start space
+ while (str != end && my_isspace(system_charset_info,*str))
str++; /* purecov: inspected */
if (str != end && (*str == '-' || *str == '+'))
str++;
@@ -143,7 +145,7 @@ bool test_if_int(const char *str,int length)
return 0; // Error: Empty string
for ( ; str != end ; str++)
{
- if (!isdigit(*str))
+ if (!my_isdigit(system_charset_info,*str))
{
if (*str == '.')
{ // Allow '.0000'
@@ -151,10 +153,10 @@ bool test_if_int(const char *str,int length)
if (str == end)
return 1;
}
- if (!isspace(*str))
+ if (!my_isspace(system_charset_info,*str))
return 0;
for (str++ ; str != end ; str++)
- if (!isspace(*str))
+ if (!my_isspace(system_charset_info,*str))
return 0;
return 1;
}
@@ -165,7 +167,7 @@ bool test_if_int(const char *str,int length)
static bool test_if_real(const char *str,int length)
{
- while (length && isspace(*str))
+ while (length && my_isspace(system_charset_info,*str))
{ // Allow start space
length--; str++;
}
@@ -174,10 +176,10 @@ static bool test_if_real(const char *str,int length)
if (*str == '+' || *str == '-')
{
length--; str++;
- if (!length || !(isdigit(*str) || *str == '.'))
+ if (!length || !(my_isdigit(system_charset_info,*str) || *str == '.'))
return 0;
}
- while (length && isdigit(*str))
+ while (length && my_isdigit(system_charset_info,*str))
{
length--; str++;
}
@@ -186,7 +188,7 @@ static bool test_if_real(const char *str,int length)
if (*str == '.')
{
length--; str++;
- while (length && isdigit(*str))
+ while (length && my_isdigit(system_charset_info,*str))
{
length--; str++;
}
@@ -195,18 +197,19 @@ static bool test_if_real(const char *str,int length)
return 1;
if (*str == 'E' || *str == 'e')
{
- if (length < 3 || (str[1] != '+' && str[1] != '-') || !isdigit(str[2]))
+ if (length < 3 || (str[1] != '+' && str[1] != '-') ||
+ !my_isdigit(system_charset_info,str[2]))
return 0;
length-=3;
str+=3;
- while (length && isdigit(*str))
+ while (length && my_isdigit(system_charset_info,*str))
{
length--; str++;
}
}
for ( ; length ; length--, str++)
{ // Allow end space
- if (!isspace(*str))
+ if (!my_isspace(system_charset_info,*str))
return 0;
}
return 1;
@@ -405,7 +408,7 @@ void Field_decimal::store(const char *from,uint len)
if ((tmp_dec= dec))
tmp_dec++; // Calculate pos of '.'
- while (from != end && isspace(*from))
+ while (from != end && my_isspace(system_charset_info,*from))
from++;
if (zerofill)
{
@@ -416,7 +419,7 @@ void Field_decimal::store(const char *from,uint len)
}
else
fyllchar=' ';
- error=number_dec(&decstr,from,end);
+ error=number_dec(system_charset_info,&decstr,from,end);
if (decstr.sign)
{
from++;
@@ -479,7 +482,7 @@ void Field_decimal::store(const char *from,uint len)
{
if (*from != '0')
{
- if (!isspace(*from)) // Space is ok
+ if (!my_isspace(system_charset_info,*from)) // Space is ok
current_thd->cuted_fields++;
break;
}
@@ -603,8 +606,10 @@ int Field_decimal::cmp(const char *a_ptr,const char *b_ptr)
for (end=a_ptr+field_length;
a_ptr != end &&
(*a_ptr == *b_ptr ||
- ((isspace(*a_ptr) || *a_ptr == '+' || *a_ptr == '0') &&
- (isspace(*b_ptr) || *b_ptr == '+' || *b_ptr == '0')));
+ ((my_isspace(system_charset_info,*a_ptr) || *a_ptr == '+' ||
+ *a_ptr == '0') &&
+ (my_isspace(system_charset_info,*b_ptr) || *b_ptr == '+' ||
+ *b_ptr == '0')));
a_ptr++,b_ptr++)
{
if (*a_ptr == '-') // If both numbers are negative
@@ -631,7 +636,7 @@ void Field_decimal::sort_string(char *to,uint length)
char *str,*end;
for (str=ptr,end=ptr+length;
str != end &&
- ((isspace(*str) || *str == '+' || *str == '0')) ;
+ ((my_isspace(system_charset_info,*str) || *str == '+' || *str == '0')) ;
str++)
*to++=' ';
@@ -643,7 +648,7 @@ void Field_decimal::sort_string(char *to,uint length)
*to++=1; // Smaller than any number
str++;
while (str != end)
- if (isdigit(*str))
+ if (my_isdigit(system_charset_info,*str))
*to++= (char) ('9' - *str++);
else
*to++= *str++;
@@ -1265,7 +1270,7 @@ void Field_medium::sql_type(String &res) const
void Field_long::store(const char *from,uint len)
{
- while (len && isspace(*from))
+ while (len && my_isspace(system_charset_info,*from))
{
len--; from++;
}
@@ -1493,7 +1498,7 @@ void Field_long::sql_type(String &res) const
void Field_longlong::store(const char *from,uint len)
{
- while (len && isspace(*from))
+ while (len && my_isspace(system_charset_info,*from))
{ // For easy error check
len--; from++;
}
@@ -3306,7 +3311,7 @@ void Field_string::store(const char *from,uint length)
const char *end=from+length;
for (from+=field_length ; from != end ; from++)
{
- if (!isspace(*from))
+ if (!my_isspace(field_charset,*from))
{
current_thd->cuted_fields++;
break;
@@ -3377,7 +3382,7 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr)
if (binary_flag)
return memcmp(a_ptr,b_ptr,field_length);
else
- return my_sortcmp(a_ptr,b_ptr,field_length);
+ return my_sortcmp(field_charset,a_ptr,b_ptr,field_length);
}
void Field_string::sort_string(char *to,uint length)
@@ -3387,17 +3392,17 @@ void Field_string::sort_string(char *to,uint length)
else
{
#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info)) {
- uint tmp=my_strnxfrm(default_charset_info,
- (unsigned char *)to, (unsigned char *) ptr,
- length, field_length);
+ if (use_strcoll(field_charset)) {
+ uint tmp=my_strnxfrm(field_charset,
+ (unsigned char *)to, length,
+ (unsigned char *) ptr, field_length);
if (tmp < length)
bzero(to + tmp, length - tmp);
}
else
#endif
for (char *from=ptr,*end=ptr+length ; from != end ;)
- *to++=(char) my_sort_order[(uint) (uchar) *from++];
+ *to++=(char) field_charset->sort_order[(uint) (uchar) *from++];
}
}
@@ -3446,7 +3451,7 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
- return my_sortncmp(a,a_length, b,b_length);
+ return my_sortncmp(field_charset, a,a_length, b,b_length);
}
@@ -3463,7 +3468,7 @@ int Field_string::pack_cmp(const char *b, uint length)
int cmp= memcmp(ptr,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
- return my_sortncmp(ptr,a_length, b, b_length);
+ return my_sortncmp(field_charset, ptr,a_length, b, b_length);
}
@@ -3568,7 +3573,7 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr)
if (binary_flag)
diff=memcmp(a_ptr+2,b_ptr+2,min(a_length,b_length));
else
- diff=my_sortcmp(a_ptr+2,b_ptr+2,min(a_length,b_length));
+ diff=my_sortcmp(field_charset, a_ptr+2,b_ptr+2,min(a_length,b_length));
return diff ? diff : (int) (a_length - b_length);
}
@@ -3580,10 +3585,10 @@ void Field_varstring::sort_string(char *to,uint length)
else
{
#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info))
- tot_length=my_strnxfrm(default_charset_info,
- (unsigned char *) to, (unsigned char *)ptr+2,
- length, tot_length);
+ if (use_strcoll(field_charset))
+ tot_length=my_strnxfrm(field_charset,
+ (unsigned char *) to, length,
+ (unsigned char *)ptr+2, tot_length);
else
{
#endif
@@ -3591,7 +3596,7 @@ void Field_varstring::sort_string(char *to,uint length)
if (tot_length > length)
tot_length=length;
for (char *from=ptr+2,*end=from+tot_length ; from != end ;)
- *tmp++=(char) my_sort_order[(uint) (uchar) *from++];
+ *tmp++=(char) field_charset->sort_order[(uint) (uchar) *from++];
#ifdef USE_STRCOLL
}
#endif
@@ -3662,7 +3667,7 @@ int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
- return my_sortncmp(a,a_length, b,b_length);
+ return my_sortncmp(field_charset, a,a_length, b,b_length);
}
int Field_varstring::pack_cmp(const char *b, uint key_length)
@@ -3683,7 +3688,7 @@ int Field_varstring::pack_cmp(const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
- return my_sortncmp(a,a_length, b,b_length);
+ return my_sortncmp(field_charset, a,a_length, b,b_length);
}
uint Field_varstring::packed_col_length(const char *ptr, uint length)
@@ -3906,7 +3911,7 @@ int Field_blob::cmp(const char *a,uint32 a_length, const char *b,
if (binary_flag)
diff=memcmp(a,b,min(a_length,b_length));
else
- diff=my_sortcmp(a,b,min(a_length,b_length));
+ diff=my_sortcmp(field_charset, a,b,min(a_length,b_length));
return diff ? diff : (int) (a_length - b_length);
}
@@ -4063,11 +4068,11 @@ void Field_blob::sort_string(char *to,uint length)
else
{
#ifdef USE_STRCOLL
- if (use_strcoll(default_charset_info))
+ if (use_strcoll(field_charset))
{
- blob_length=my_strnxfrm(default_charset_info,
- (unsigned char *)to,(unsigned char *)blob,
- length,blob_org_length);
+ blob_length=my_strnxfrm(field_charset,
+ (unsigned char *)to, length,
+ (unsigned char *)blob, blob_org_length);
if (blob_length >= length)
return;
to+=blob_length;
@@ -4075,7 +4080,7 @@ void Field_blob::sort_string(char *to,uint length)
else
#endif
for (char *end=blob+blob_length ; blob != end ;)
- *to++=(char) my_sort_order[(uint) (uchar) *blob++];
+ *to++=(char) field_charset->sort_order[(uint) (uchar) *blob++];
}
bzero(to,length-blob_length);
}
@@ -4153,7 +4158,7 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
- return my_sortncmp(a,a_length, b,b_length);
+ return my_sortncmp(field_charset, a,a_length, b,b_length);
}
@@ -4179,7 +4184,7 @@ int Field_blob::pack_cmp(const char *b, uint key_length)
int cmp= memcmp(a,b,min(a_length,b_length));
return cmp ? cmp : (int) (a_length - b_length);
}
- return my_sortncmp(a,a_length, b,b_length);
+ return my_sortncmp(field_charset, a,a_length, b,b_length);
}
/* Create a packed key that will be used for storage from a MySQL row */
@@ -4290,14 +4295,16 @@ void Field_enum::store_type(ulonglong value)
uint find_enum(TYPELIB *lib,const char *x, uint length)
{
const char *end=x+length;
- while (end > x && isspace(end[-1]))
+ while (end > x && my_isspace(system_charset_info,end[-1]))
end--;
const char *i;
const char *j;
for (uint pos=0 ; (j=lib->type_names[pos]) ; pos++)
{
- for (i=x ; i != end && toupper(*i) == toupper(*j) ; i++, j++) ;
+ for (i=x ; i != end &&
+ my_toupper(system_charset_info,*i) ==
+ my_toupper(system_charset_info,*j) ; i++, j++) ;
if (i == end && ! *j)
return(pos+1);
}
@@ -4474,7 +4481,7 @@ void Field_enum::sql_type(String &res) const
ulonglong find_set(TYPELIB *lib,const char *x,uint length)
{
const char *end=x+length;
- while (end > x && isspace(end[-1]))
+ while (end > x && my_isspace(system_charset_info, end[-1]))
end--;
ulonglong found=0;
@@ -4600,7 +4607,8 @@ bool Field_enum::eq_def(Field *field)
if (typelib->count < from_lib->count)
return 0;
for (uint i=0 ; i < from_lib->count ; i++)
- if (my_strcasecmp(typelib->type_names[i],from_lib->type_names[i]))
+ if (my_strcasecmp(field_charset,
+ typelib->type_names[i],from_lib->type_names[i]))
return 0;
return 1;
}
diff --git a/sql/field.h b/sql/field.h
index 422e91768e6..cd1697fcf44 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -145,12 +145,7 @@ public:
virtual void set_key_image(char *buff,uint length)
{ set_image(buff,length); }
inline int cmp_image(char *buff,uint length)
- {
- if (binary())
- return memcmp(ptr,buff,length);
- else
- return my_casecmp(ptr,buff,length);
- }
+ { return memcmp(ptr,buff,length); }
inline longlong val_int_offset(uint row_offset)
{
ptr+=row_offset;
@@ -241,6 +236,8 @@ public:
class Field_str :public Field {
+protected:
+ CHARSET_INFO *field_charset;
public:
Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
@@ -248,12 +245,20 @@ public:
struct st_table *table_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg)
- {}
+ { field_charset=default_charset_info; }
Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; }
friend class create_field;
void make_field(Send_field *);
uint size_of() const { return sizeof(*this); }
+ inline int cmp_image(char *buff,uint length)
+ {
+ if (binary())
+ return memcmp(ptr,buff,length);
+ else
+ return my_strncasecmp(field_charset,ptr,buff,length);
+ }
+
};
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index c7a6d778953..02be0365002 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -276,7 +276,7 @@ static void do_cut_string(Copy_field *copy)
ptr != end ;
ptr++)
{
- if (!isspace(*ptr))
+ if (!my_isspace(system_charset_info, *ptr))
{
current_thd->cuted_fields++; // Give a warning
break;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index a5f42d5731e..675cc294de4 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -513,9 +513,8 @@ static void make_sortkey(register SORTPARAM *param,
from=param->tmp_buffer;
}
uint tmp_length=my_strnxfrm(default_charset_info,
- to,(unsigned char *) from,
- sort_field->length,
- length);
+ to,sort_field->length,
+ (unsigned char *) from, length);
if (tmp_length < sort_field->length)
bzero((char*) to+tmp_length,sort_field->length-tmp_length);
}
@@ -527,7 +526,7 @@ static void make_sortkey(register SORTPARAM *param,
memcpy(to,res->ptr(),length);
bzero((char *)to+length,diff);
if (!item->binary)
- case_sort((char*) to,length);
+ case_sort(default_charset_info, (char*) to,length);
#ifdef USE_STRCOLL
}
#endif
@@ -925,7 +924,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
sortorder->length=sortorder->field->pack_length();
#ifdef USE_STRCOLL
if (use_strcoll(default_charset_info) && !sortorder->field->binary())
- sortorder->length= sortorder->length*MY_STRXFRM_MULTIPLY;
+ sortorder->length= sortorder->length*default_charset_info->strxfrm_multiply;
#endif
}
if (sortorder->field->maybe_null())
@@ -938,7 +937,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length)
sortorder->length=sortorder->item->max_length;
#ifdef USE_STRCOLL
if (use_strcoll(default_charset_info) && !sortorder->item->binary)
- sortorder->length= sortorder->length*MY_STRXFRM_MULTIPLY;
+ sortorder->length= sortorder->length*default_charset_info->strxfrm_multiply;
#endif
break;
case INT_RESULT:
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 4cf06dfb731..d53b027a415 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -1194,7 +1194,10 @@ innobase_mysql_cmp(
case FIELD_TYPE_STRING:
case FIELD_TYPE_VAR_STRING:
- ret = my_sortncmp((const char*) a, a_length,
+ // BAR TODO: Discuss with heikki.tuuri@innodb.com
+ // so that he sends CHARSET_INFO for the field to this function.
+ ret = my_sortncmp(default_charset_info,
+ (const char*) a, a_length,
(const char*) b, b_length);
if (ret < 0) {
return(-1);
diff --git a/sql/hostname.cc b/sql/hostname.cc
index 7d4e4a8ca75..0b35f970c42 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -213,10 +213,10 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors)
/* Don't accept hostnames that starts with digits because they may be
false ip:s */
- if (isdigit(name[0]))
+ if (my_isdigit(system_charset_info,name[0]))
{
char *pos;
- for (pos= name+1 ; isdigit(*pos); pos++) ;
+ for (pos= name+1 ; my_isdigit(system_charset_info,*pos); pos++) ;
if (*pos == '.')
{
DBUG_PRINT("error",("mysqld doesn't accept hostnames that starts with a number followed by a '.'"));
diff --git a/sql/init.cc b/sql/init.cc
index df06ddd41ef..fe80c282563 100644
--- a/sql/init.cc
+++ b/sql/init.cc
@@ -24,6 +24,7 @@ void unireg_init(ulong options)
{
uint i;
double nr;
+ CHARSET_INFO *cs;
DBUG_ENTER("unireg_init");
MYSYS_PROGRAM_DONT_USE_CURSES();
@@ -54,13 +55,16 @@ void unireg_init(ulong options)
// The following is needed because of like optimization in select.cc
- uchar max_char=my_sort_order[(uchar) max_sort_char];
- for (i = 0; i < 256; i++)
+ for (cs=compiled_charsets; cs->number; cs++)
{
- if ((uchar) my_sort_order[i] > max_char)
+ uchar max_char=cs->sort_order[(uchar) cs->max_sort_char];
+ for (i = 0; i < 256; i++)
{
- max_char=(uchar) my_sort_order[i];
- max_sort_char= (char) i;
+ if ((uchar) cs->sort_order[i] > max_char)
+ {
+ max_char=(uchar) cs->sort_order[i];
+ cs->max_sort_char= (char) i;
+ }
}
}
thread_stack_min=thread_stack - STACK_MIN_SIZE;
diff --git a/sql/item.cc b/sql/item.cc
index c081fd9dd5f..0c241684474 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -50,7 +50,7 @@ void Item::set_name(char *str,uint length)
name=str; // Used by AS
else
{
- while (length && !isgraph(*str))
+ while (length && !my_isgraph(system_charset_info,*str))
{ // Fix problem with yacc
length--;
str++;
@@ -62,7 +62,7 @@ void Item::set_name(char *str,uint length)
bool Item::eq(const Item *item) const // Only doing this on conds
{
return type() == item->type() && name && item->name &&
- !my_strcasecmp(name,item->name);
+ !my_strcasecmp(system_charset_info,name,item->name);
}
/*
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 65d4413b484..09e3aab08c6 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -991,7 +991,8 @@ longlong Item_func_find_in_set::val_int()
const char *pos= f_pos;
while (pos != f_end)
{
- if (toupper(*str) != toupper(*pos))
+ if (my_toupper(find->charset(),*str) !=
+ my_toupper(find->charset(),*pos))
goto not_found;
str++;
pos++;
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index cdf909e8c4d..de07f5b1ee7 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -42,7 +42,7 @@ uint nr_of_decimals(const char *str)
if ((str=strchr(str,'.')))
{
const char *start= ++str;
- for ( ; isdigit(*str) ; str++) ;
+ for ( ; my_isdigit(system_charset_info,*str) ; str++) ;
return (uint) (str-start);
}
return 0;
@@ -1268,9 +1268,9 @@ extern "C" {
extern const char *soundex_map; // In mysys/static.c
}
-static char get_scode(char *ptr)
+static char get_scode(CHARSET_INFO *cs,char *ptr)
{
- uchar ch=toupper(*ptr);
+ uchar ch=my_toupper(cs,*ptr);
if (ch < 'A' || ch > 'Z')
{
// Thread extended alfa (country spec)
@@ -1292,21 +1292,21 @@ String *Item_func_soundex::val_str(String *str)
char *to= (char *) tmp_value.ptr();
char *from= (char *) res->ptr(), *end=from+res->length();
- while (from != end && isspace(*from)) // Skip pre-space
+ while (from != end && my_isspace(str->charset(),*from)) // Skip pre-space
from++; /* purecov: inspected */
if (from == end)
return &empty_string; // No alpha characters.
- *to++ = toupper(*from); // Copy first letter
- last_ch = get_scode(from); // code of the first letter
+ *to++ = my_toupper(str->charset(),*from);// Copy first letter
+ last_ch = get_scode(str->charset(),from);// code of the first letter
// for the first 'double-letter check.
// Loop on input letters until
// end of input (null) or output
// letter code count = 3
for (from++ ; from < end ; from++)
{
- if (!isalpha(*from))
+ if (!my_isalpha(str->charset(),*from))
continue;
- ch=get_scode(from);
+ ch=get_scode(str->charset(),from);
if ((ch != '0') && (ch != last_ch)) // if not skipped or double
{
*to++ = ch; // letter, copy to output
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index e8f16e3ed56..7ebeda19993 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -864,7 +864,8 @@ static int simple_raw_key_cmp(void* arg, byte* key1, byte* key2)
static int simple_str_key_cmp(void* arg, byte* key1, byte* key2)
{
- return my_sortcmp((char*) key1, (char*) key2, *(uint*) arg);
+ /* BAR TODO: remove default_charset_info */
+ return my_sortcmp(default_charset_info,(char*) key1, (char*) key2, *(uint*) arg);
}
/*
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 8f55a02b020..b10054e11d2 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -49,16 +49,16 @@ bool get_interval_info(const char *str,uint length,uint count,
{
const char *end=str+length;
uint i;
- while (str != end && !isdigit(*str))
+ while (str != end && !my_isdigit(system_charset_info,*str))
str++;
for (i=0 ; i < count ; i++)
{
long value;
- for (value=0; str != end && isdigit(*str) ; str++)
+ for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++)
value=value*10L + (long) (*str - '0');
values[i]= value;
- while (str != end && !isdigit(*str))
+ while (str != end && !my_isdigit(system_charset_info,*str))
str++;
if (str == end && i != count-1)
{
@@ -289,7 +289,7 @@ static bool get_interval_value(Item *args,interval_type int_type,
/* record negative intervalls in t->neg */
str=res->ptr();
const char *end=str+res->length();
- while (str != end && isspace(*str))
+ while (str != end && my_isspace(system_charset_info,*str))
str++;
if (str != end && *str == '-')
{
diff --git a/sql/key.cc b/sql/key.cc
index d2f483e3d73..a5d3d0a65b9 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -192,8 +192,9 @@ int key_cmp(TABLE *table,const byte *key,uint idx,uint key_length)
if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+
FIELDFLAG_PACK)))
{
- if (my_sortcmp((char*) key,(char*) table->record[0]+key_part->offset,
- length))
+ /* BAR TODO: I'm not sure this should be system_charset_info */
+ if (my_sortcmp(system_charset_info,(char*) key,
+ (char*) table->record[0]+key_part->offset,length))
return 1;
}
else if (memcmp(key,table->record[0]+key_part->offset,length))
diff --git a/sql/log.cc b/sql/log.cc
index 892780d3882..1a315ea9f9c 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1208,7 +1208,7 @@ static bool test_if_number(register const char *str,
while (*str++ == ' ') ;
if (*--str == '-' || *str == '+')
str++;
- while (isdigit(*str) || (allow_wildcards &&
+ while (my_isdigit(system_charset_info,*str) || (allow_wildcards &&
(*str == wild_many || *str == wild_one)))
{
flag=1;
@@ -1217,7 +1217,7 @@ static bool test_if_number(register const char *str,
if (*str == '.')
{
for (str++ ;
- isdigit(*str) ||
+ my_isdigit(system_charset_info,*str) ||
(allow_wildcards && (*str == wild_many || *str == wild_one)) ;
str++, flag=1) ;
}
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 924f85b0a89..728d6d7a35f 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -549,7 +549,7 @@ void open_log(MYSQL_LOG *log, const char *hostname,
extern uint32 server_id;
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
- max_sort_char, mysql_real_data_home[];
+ mysql_real_data_home[];
extern my_string mysql_tmpdir;
extern const char *first_keyword, *localhost, *delayed_user;
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables,
@@ -708,10 +708,10 @@ bool check_db_name(const char *db);
bool check_column_name(const char *name);
bool check_table_name(const char *name, uint length);
char *get_field(MEM_ROOT *mem,TABLE *table,uint fieldnr);
-int wild_case_compare(const char *str,const char *wildstr);
+int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
int wild_compare(const char *str,const char *str_end,
const char *wildstr,const char *wildend,char escape);
-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);
/* from hostname.cc */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5e4fc654320..40b9ab24831 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -863,7 +863,7 @@ static void set_user(const char *user)
{
// allow a numeric uid to be used
const char *pos;
- for (pos=user; isdigit(*pos); pos++) ;
+ for (pos=user; my_isdigit(system_charset_info,*pos); pos++) ;
if (*pos) // Not numeric id
{
fprintf(stderr,"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user);
@@ -3769,7 +3769,7 @@ static void get_options(int argc,char **argv)
exit(1);
}
val = p--;
- while(isspace(*p) && p > optarg) *p-- = 0;
+ while(my_isspace(system_charset_info,*p) && p > optarg) *p-- = 0;
if(p == optarg)
{
fprintf(stderr,
@@ -3778,7 +3778,7 @@ static void get_options(int argc,char **argv)
}
*val = 0;
val += 2;
- while(*val && isspace(*val)) *val++;
+ while(*val && my_isspace(system_charset_info,*val)) *val++;
if (!*val)
{
fprintf(stderr,
@@ -3937,7 +3937,7 @@ static void get_options(int argc,char **argv)
have_symlink=SHOW_OPTION_DISABLED;
break;
case (int) OPT_BIND_ADDRESS:
- if (optarg && isdigit(optarg[0]))
+ if (optarg && my_isdigit(system_charset_info,optarg[0]))
{
my_bind_addr = (ulong) inet_addr(optarg);
}
@@ -4409,7 +4409,8 @@ static ulong find_bit_type(const char *x, TYPELIB *bit_lib)
j=pos;
while (j != end)
{
- if (toupper(*i++) != toupper(*j++))
+ if (my_toupper(system_charset_info,*i++) !=
+ my_toupper(system_charset_info,*j++))
goto skipp;
}
found_int=bit;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 34ee34ecc79..8bd47913b7b 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -985,7 +985,8 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
like_error=like_range(res->ptr(),res->length(),wild_prefix,
field_length,
min_str+offset,max_str+offset,
- max_sort_char,&min_length,&max_length);
+ default_charset_info->max_sort_char,
+ &min_length,&max_length);
}
if (like_error) // Can't optimize with LIKE
DBUG_RETURN(0);
diff --git a/sql/procedure.cc b/sql/procedure.cc
index 437bd82d6e5..7779f5ce085 100644
--- a/sql/procedure.cc
+++ b/sql/procedure.cc
@@ -57,7 +57,8 @@ setup_procedure(THD *thd,ORDER *param,select_result *result,
DBUG_RETURN(0);
for (i=0 ; i < array_elements(sql_procs) ; i++)
{
- if (!my_strcasecmp((*param->item)->name,sql_procs[i].name))
+ if (!my_strcasecmp(system_charset_info,
+ (*param->item)->name,sql_procs[i].name))
{
Procedure *proc=(*sql_procs[i].init)(thd,param,result,field_list);
*error= !proc;
diff --git a/sql/slave.cc b/sql/slave.cc
index 100e305530f..9630cf6aa0e 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -237,9 +237,9 @@ void init_slave_skip_errors(char* arg)
exit(1);
}
use_slave_mask = 1;
- for (;isspace(*arg);++arg)
+ for (;my_isspace(system_charset_info,*arg);++arg)
/* empty */;
- if (!my_casecmp(arg,"all",3))
+ if (!my_strncasecmp(system_charset_info,arg,"all",3))
{
bitmap_set_all(&slave_error_mask);
return;
@@ -251,7 +251,7 @@ void init_slave_skip_errors(char* arg)
break;
if (err_code < MAX_SLAVE_ERROR)
bitmap_set_bit(&slave_error_mask,(uint)err_code);
- while (!isdigit(*p) && *p)
+ while (!my_isdigit(system_charset_info,*p) && *p)
p++;
}
}
@@ -492,7 +492,8 @@ static TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len)
{
TABLE_RULE_ENT* e ;
get_dynamic(a, (gptr)&e, i);
- if (!wild_case_compare(key, key_end, (const char*)e->db,
+ if (!wild_case_compare(system_charset_info, key, key_end,
+ (const char*)e->db,
(const char*)(e->db + e->key_len),'\\'))
return e;
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index c5782f65798..198569cec3c 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -381,7 +381,7 @@ static uint get_access(TABLE *form,uint fieldnr)
for (pos=form->field+fieldnr,bit=1 ; *pos ; pos++ , bit<<=1)
{
(*pos)->val_str(&res,&res);
- if (toupper(res[0]) == 'Y')
+ if (my_toupper(system_charset_info, res[0]) == 'Y')
access_bits|=bit;
}
return access_bits;
@@ -729,7 +729,7 @@ uint acl_get(const char *host, const char *ip, const char *bin_ip,
end=strmov((tmp_db=strmov(key+sizeof(struct in_addr),user)+1),db);
if (lower_case_table_names)
{
- casedn_str(tmp_db);
+ my_casedn_str(system_charset_info, tmp_db);
db=tmp_db;
}
key_length=(uint) (end-key);
@@ -793,7 +793,7 @@ exit:
}
-int wild_case_compare(const char *str,const char *wildstr)
+int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr)
{
reg3 int flag;
DBUG_ENTER("wild_case_compare");
@@ -804,7 +804,8 @@ int wild_case_compare(const char *str,const char *wildstr)
{
if (*wildstr == wild_prefix && wildstr[1])
wildstr++;
- if (toupper(*wildstr++) != toupper(*str++)) DBUG_RETURN(1);
+ if (my_toupper(cs, *wildstr++) !=
+ my_toupper(cs, *str++)) DBUG_RETURN(1);
}
if (! *wildstr ) DBUG_RETURN (*str != 0);
if (*wildstr++ == wild_one)
@@ -822,12 +823,12 @@ int wild_case_compare(const char *str,const char *wildstr)
char cmp;
if ((cmp= *wildstr) == wild_prefix && wildstr[1])
cmp=wildstr[1];
- cmp=toupper(cmp);
- while (*str && toupper(*str) != cmp)
+ cmp=my_toupper(cs, cmp);
+ while (*str && my_toupper(cs, *str) != cmp)
str++;
if (!*str) DBUG_RETURN (1);
}
- if (wild_case_compare(str,wildstr) == 0) DBUG_RETURN (0);
+ if (wild_case_compare(cs, str,wildstr) == 0) DBUG_RETURN (0);
} while (*str++);
DBUG_RETURN(1);
}
@@ -862,7 +863,8 @@ static void init_check_host(void)
{ // Check if host already exists
acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j,
acl_host_and_ip *);
- if (!my_strcasecmp(acl_user->host.hostname,acl->hostname))
+ if (!my_strcasecmp(system_charset_info,
+ acl_user->host.hostname, acl->hostname))
break; // already stored
}
if (j == acl_wild_hosts.elements) // If new
@@ -940,7 +942,8 @@ bool change_password(THD *thd, const char *host, const char *user,
new_password[length & 16]=0;
if (!thd || (!thd->slave_thread && ( strcmp(thd->user,user) ||
- my_strcasecmp(host,thd->host ? thd->host : thd->ip))))
+ my_strcasecmp(system_charset_info,
+ host, (thd->host ? thd->host : thd->ip)))))
{
if (check_access(thd, UPDATE_ACL, "mysql",0,1))
DBUG_RETURN(1);
@@ -1061,7 +1064,8 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname,
return (tmp & host->ip_mask) == host->ip;
}
return (!host->hostname ||
- (hostname && !wild_case_compare(hostname,host->hostname)) ||
+ (hostname && !wild_case_compare(system_charset_info,
+ hostname,host->hostname)) ||
(ip && !wild_compare(ip,host->hostname)));
}
@@ -1414,8 +1418,8 @@ public:
tname= strdup_root(&memex,t);
if (lower_case_table_names)
{
- casedn_str(db);
- casedn_str(tname);
+ my_casedn_str(system_charset_info, db);
+ my_casedn_str(system_charset_info, tname);
}
key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3;
hash_key = (char*) alloc_root(&memex,key_length);
@@ -1440,8 +1444,8 @@ public:
}
if (lower_case_table_names)
{
- casedn_str(db);
- casedn_str(tname);
+ my_casedn_str(system_charset_info, db);
+ my_casedn_str(system_charset_info, tname);
}
key_length = ((uint) strlen(db) + (uint) strlen(user) +
(uint) strlen(tname) + 3);
@@ -1534,8 +1538,10 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
}
else
{
- if ((host && !wild_case_compare(host,grant_table->host)) ||
- (ip && !wild_case_compare(ip,grant_table->host)))
+ if ((host && !wild_case_compare(system_charset_info,
+ host,grant_table->host)) ||
+ (ip && !wild_case_compare(system_charset_info,
+ ip,grant_table->host)))
found=grant_table; // Host ok
}
}
@@ -2051,7 +2057,7 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, uint rights,
if (lower_case_table_names && db)
{
strmov(tmp_db,db);
- casedn_str(tmp_db);
+ my_casedn_str(system_charset_info, tmp_db);
db=tmp_db;
}
@@ -2476,8 +2482,10 @@ bool check_grant_db(THD *thd,const char *db)
GRANT_TABLE *grant_table = (GRANT_TABLE*) hash_element(&hash_tables,idx);
if (len < grant_table->key_length &&
!memcmp(grant_table->hash_key,helping,len) &&
- (thd->host && !wild_case_compare(thd->host,grant_table->host) ||
- (thd->ip && !wild_case_compare(thd->ip,grant_table->host))))
+ (thd->host && !wild_case_compare(system_charset_info,
+ thd->host,grant_table->host) ||
+ (thd->ip && !wild_case_compare(system_charset_info,
+ thd->ip,grant_table->host))))
{
error=0; // Found match
break;
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index df8a8f1fdde..fc764333916 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -163,7 +163,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
// MySQL removes any endspaces of a string, so we must take care only of
// spaces in front of a string
- for (; str != end && isspace(*str); str++) ;
+ for (; str != end && my_isspace(system_charset_info, *str); str++) ;
if (str == end)
return 0;
@@ -176,10 +176,10 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
else
info->negative = 0;
begin = str;
- for (; str != end && isdigit(*str); str++)
+ for (; str != end && my_isdigit(system_charset_info,*str); str++)
{
if (!info->integers && *str == '0' && (str + 1) != end &&
- isdigit(*(str + 1)))
+ my_isdigit(system_charset_info,*(str + 1)))
info->zerofill = 1; // could be a postnumber for example
info->integers++;
}
@@ -205,7 +205,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
str++;
if (*str != '-' && *str != '+')
return 0;
- for (str++; str != end && isdigit(*str); str++) ;
+ for (str++; str != end && my_isdigit(system_charset_info,*str); str++) ;
if (str == end)
{
info->is_float = 1; // we can't use variable decimals here
@@ -220,7 +220,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len)
info->ullval = (ulonglong) strtoull(begin, NULL, 10);
return 1;
}
- for (; str != end && isdigit(*str); str++)
+ for (; str != end && my_isdigit(system_charset_info,*str); str++)
info->decimals++;
if (str == end)
{
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f4a70db2e5d..e73a0c63fa6 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -50,7 +50,8 @@ static byte *cache_key(const byte *record,uint *length,
void table_cache_init(void)
{
- VOID(hash_init(&open_cache,table_cache_size+16,0,0,cache_key,
+ VOID(hash_init(&open_cache,
+ table_cache_size+16,0,0,cache_key,
(void (*)(void*)) free_cache_entry,0));
mysql_rm_tmp_tables();
}
@@ -780,7 +781,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
{
if (table->key_length == key_length &&
!memcmp(table->table_cache_key,key,key_length) &&
- !my_strcasecmp(table->table_name,alias))
+ !my_strcasecmp(system_charset_info,table->table_name,alias))
goto reset;
}
my_printf_error(ER_TABLE_NOT_LOCKED,ER(ER_TABLE_NOT_LOCKED),MYF(0),alias);
@@ -1559,11 +1560,12 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length,
Field **ptr=table->field;
while ((field = *ptr++))
{
- if (!my_strcasecmp(field->field_name, name))
+ if (!my_strcasecmp(system_charset_info, field->field_name, name))
goto found;
}
}
- if (allow_rowid && !my_strcasecmp(name,"_rowid") &&
+ if (allow_rowid &&
+ !my_strcasecmp(system_charset_info, name, "_rowid") &&
(field=table->rowid_field))
goto found;
return (Field*) 0;
@@ -1686,7 +1688,8 @@ find_item_in_list(Item *find,List<Item> &items)
{
if (field_name && item->type() == Item::FIELD_ITEM)
{
- if (!my_strcasecmp(((Item_field*) item)->name,field_name))
+ if (!my_strcasecmp(system_charset_info,
+ ((Item_field*) item)->name,field_name))
{
if (!table_name)
{
@@ -1709,8 +1712,9 @@ find_item_in_list(Item *find,List<Item> &items)
}
}
else if (!table_name && (item->eq(find) ||
- find->name &&
- !my_strcasecmp(item->name,find->name)))
+ find->name &&
+ !my_strcasecmp(system_charset_info,
+ item->name,find->name)))
{
found=li.ref();
break;
@@ -1938,7 +1942,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
// TODO: This could be optimized to use hashed names if t2 had a hash
for (j=0 ; j < t2->fields ; j++)
{
- if (!my_strcasecmp(t1->field[i]->field_name,
+ if (!my_strcasecmp(system_charset_info,
+ t1->field[i]->field_name,
t2->field[j]->field_name))
{
Item_func_eq *tmp=new Item_func_eq(new Item_field(t1->field[i]),
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index c5ebeead05a..72ac20d8818 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -896,8 +896,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
Test if the query is a SELECT
(pre-space is removed in dispatch_command)
*/
- if (toupper(sql[0]) != 'S' || toupper(sql[1]) != 'E' ||
- toupper(sql[2]) !='L')
+ if (my_toupper(system_charset_info, sql[0]) != 'S' ||
+ my_toupper(system_charset_info, sql[1]) != 'E' ||
+ my_toupper(system_charset_info,sql[2]) !='L')
{
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
goto err;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index dd8ed634011..30e7262cae0 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -218,7 +218,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
DBUG_PRINT("info",("Examining: %s", file->name));
/* Check if file is a raid directory */
- if (isdigit(file->name[0]) && isdigit(file->name[1]) &&
+ if (my_isdigit(system_charset_info,file->name[0]) &&
+ my_isdigit(system_charset_info,file->name[1]) &&
!file->name[2] && !level)
{
char newpath[FN_REFLEN];
@@ -243,7 +244,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
continue;
}
strxmov(filePath,org_path,"/",file->name,NullS);
- if (db && !my_strcasecmp(fn_ext(file->name), reg_ext))
+ if (db && !my_strcasecmp(system_charset_info,
+ fn_ext(file->name), reg_ext))
{
/* Drop the table nicely */
*fn_ext(file->name)=0; // Remove extension
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 8f9d3474ce2..f4d6f3416a6 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -270,7 +270,7 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db,
for (TABLE *table=*ptr; table ; table=*ptr)
{
if (!memcmp(table->table_cache_key, db, dblen) &&
- !my_strcasecmp(table->table_name,table_name))
+ !my_strcasecmp(system_charset_info,table->table_name,table_name))
break;
ptr=&(table->next);
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 7995e7701e5..9371eb00b79 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -92,15 +92,15 @@ void lex_init(void)
/* Fill state_map with states to get a faster parser */
for (i=0; i < 256 ; i++)
{
- if (isalpha(i))
+ if (my_isalpha(system_charset_info,i))
state_map[i]=(uchar) STATE_IDENT;
- else if (isdigit(i))
+ else if (my_isdigit(system_charset_info,i))
state_map[i]=(uchar) STATE_NUMBER_IDENT;
#if defined(USE_MB) && defined(USE_MB_IDENT)
- else if (use_mb(default_charset_info) && my_ismbhead(default_charset_info, i))
+ else if (use_mb(system_charset_info) && my_ismbhead(system_charset_info, i))
state_map[i]=(uchar) STATE_IDENT;
#endif
- else if (!isgraph(i))
+ else if (!my_isgraph(system_charset_info,i))
state_map[i]=(uchar) STATE_SKIP;
else
state_map[i]=(uchar) STATE_CHAR;
@@ -220,8 +220,8 @@ static char *get_text(LEX *lex)
c = yyGet();
#ifdef USE_MB
int l;
- if (use_mb(default_charset_info) &&
- (l = my_ismbchar(default_charset_info,
+ if (use_mb(system_charset_info) &&
+ (l = my_ismbchar(system_charset_info,
(const char *)lex->ptr-1,
(const char *)lex->end_of_query))) {
lex->ptr += l-1;
@@ -265,8 +265,8 @@ static char *get_text(LEX *lex)
{
#ifdef USE_MB
int l;
- if (use_mb(default_charset_info) &&
- (l = my_ismbchar(default_charset_info,
+ if (use_mb(system_charset_info) &&
+ (l = my_ismbchar(system_charset_info,
(const char *)str, (const char *)end))) {
while (l--)
*to++ = *str++;
@@ -471,11 +471,11 @@ int yylex(void *arg)
break;
}
#if defined(USE_MB) && defined(USE_MB_IDENT)
- if (use_mb(default_charset_info))
+ if (use_mb(system_charset_info))
{
- if (my_ismbhead(default_charset_info, yyGetLast()))
+ if (my_ismbhead(system_charset_info, yyGetLast()))
{
- int l = my_ismbchar(default_charset_info,
+ int l = my_ismbchar(system_charset_info,
(const char *)lex->ptr-1,
(const char *)lex->end_of_query);
if (l == 0) {
@@ -487,10 +487,10 @@ int yylex(void *arg)
while (state_map[c=yyGet()] == STATE_IDENT ||
state_map[c] == STATE_NUMBER_IDENT)
{
- if (my_ismbhead(default_charset_info, c))
+ if (my_ismbhead(system_charset_info, c))
{
int l;
- if ((l = my_ismbchar(default_charset_info,
+ if ((l = my_ismbchar(system_charset_info,
(const char *)lex->ptr-1,
(const char *)lex->end_of_query)) == 0)
break;
@@ -533,7 +533,7 @@ int yylex(void *arg)
return((int) c);
case STATE_NUMBER_IDENT: // number or ident which num-start
- while (isdigit((c = yyGet()))) ;
+ while (my_isdigit(system_charset_info,(c = yyGet()))) ;
if (state_map[c] != STATE_IDENT)
{ // Can't be identifier
state=STATE_INT_OR_REAL;
@@ -542,12 +542,13 @@ int yylex(void *arg)
if (c == 'e' || c == 'E')
{
// The following test is written this way to allow numbers of type 1e1
- if (isdigit(yyPeek()) || (c=(yyGet())) == '+' || c == '-')
+ if (my_isdigit(system_charset_info,yyPeek()) ||
+ (c=(yyGet())) == '+' || c == '-')
{ // Allow 1E+10
- if (isdigit(yyPeek())) // Number must have digit after sign
+ if (my_isdigit(system_charset_info,yyPeek())) // Number must have digit after sign
{
yySkip();
- while (isdigit(yyGet())) ;
+ while (my_isdigit(system_charset_info,yyGet())) ;
yylval->lex_str=get_token(lex,yyLength());
return(FLOAT_NUM);
}
@@ -557,7 +558,7 @@ int yylex(void *arg)
else if (c == 'x' && (lex->ptr - lex->tok_start) == 2 &&
lex->tok_start[0] == '0' )
{ // Varbinary
- while (isxdigit((c = yyGet()))) ;
+ while (my_isxdigit(system_charset_info,(c = yyGet()))) ;
if ((lex->ptr - lex->tok_start) >= 4 && state_map[c] != STATE_IDENT)
{
yylval->lex_str=get_token(lex,yyLength());
@@ -571,11 +572,11 @@ int yylex(void *arg)
// fall through
case STATE_IDENT_START: // Incomplete ident
#if defined(USE_MB) && defined(USE_MB_IDENT)
- if (use_mb(default_charset_info))
+ if (use_mb(system_charset_info))
{
- if (my_ismbhead(default_charset_info, yyGetLast()))
+ if (my_ismbhead(system_charset_info, yyGetLast()))
{
- int l = my_ismbchar(default_charset_info,
+ int l = my_ismbchar(system_charset_info,
(const char *)lex->ptr-1,
(const char *)lex->end_of_query);
if (l == 0)
@@ -588,10 +589,10 @@ int yylex(void *arg)
while (state_map[c=yyGet()] == STATE_IDENT ||
state_map[c] == STATE_NUMBER_IDENT)
{
- if (my_ismbhead(default_charset_info, c))
+ if (my_ismbhead(system_charset_info, c))
{
int l;
- if ((l = my_ismbchar(default_charset_info,
+ if ((l = my_ismbchar(system_charset_info,
(const char *)lex->ptr-1,
(const char *)lex->end_of_query)) == 0)
break;
@@ -618,15 +619,15 @@ int yylex(void *arg)
case STATE_USER_VARIABLE_DELIMITER:
lex->tok_start=lex->ptr; // Skip first `
#ifdef USE_MB
- if (use_mb(default_charset_info))
+ if (use_mb(system_charset_info))
{
while ((c=yyGet()) && state_map[c] != STATE_USER_VARIABLE_DELIMITER &&
c != (uchar) NAMES_SEP_CHAR)
{
- if (my_ismbhead(default_charset_info, c))
+ if (my_ismbhead(system_charset_info, c))
{
int l;
- if ((l = my_ismbchar(default_charset_info,
+ if ((l = my_ismbchar(system_charset_info,
(const char *)lex->ptr-1,
(const char *)lex->end_of_query)) == 0)
break;
@@ -651,17 +652,18 @@ int yylex(void *arg)
if (prev_state == STATE_OPERATOR_OR_IDENT)
{
if (c == '-' && yyPeek() == '-' &&
- (isspace(yyPeek2()) || iscntrl(yyPeek2())))
+ (my_isspace(system_charset_info,yyPeek2()) ||
+ my_iscntrl(system_charset_info,yyPeek2())))
state=STATE_COMMENT;
else
state= STATE_CHAR; // Must be operator
break;
}
- if (!isdigit(c=yyGet()) || yyPeek() == 'x')
+ if (!my_isdigit(system_charset_info,c=yyGet()) || yyPeek() == 'x')
{
if (c != '.')
{
- if (c == '-' && isspace(yyPeek()))
+ if (c == '-' && my_isspace(system_charset_info,yyPeek()))
state=STATE_COMMENT;
else
state = STATE_CHAR; // Return sign as single char
@@ -669,9 +671,9 @@ int yylex(void *arg)
}
yyUnget(); // Fix for next loop
}
- while (isdigit(c=yyGet())) ; // Incomplete real or int number
+ while (my_isdigit(system_charset_info,c=yyGet())) ; // Incomplete real or int number
if ((c == 'e' || c == 'E') &&
- (yyPeek() == '+' || yyPeek() == '-' || isdigit(yyPeek())))
+ (yyPeek() == '+' || yyPeek() == '-' || my_isdigit(system_charset_info,yyPeek())))
{ // Real number
yyUnget();
c= '.'; // Fool next test
@@ -685,19 +687,19 @@ int yylex(void *arg)
}
// fall through
case STATE_REAL: // Incomplete real number
- while (isdigit(c = yyGet())) ;
+ while (my_isdigit(system_charset_info,c = yyGet())) ;
if (c == 'e' || c == 'E')
{
c = yyGet();
if (c == '-' || c == '+')
c = yyGet(); // Skip sign
- if (!isdigit(c))
+ if (!my_isdigit(system_charset_info,c))
{ // No digit after sign
state= STATE_CHAR;
break;
}
- while (isdigit(yyGet())) ;
+ while (my_isdigit(system_charset_info,yyGet())) ;
yylval->lex_str=get_token(lex,yyLength());
return(FLOAT_NUM);
}
@@ -706,7 +708,7 @@ int yylex(void *arg)
case STATE_HEX_NUMBER: // Found x'hexstring'
yyGet(); // Skip '
- while (isxdigit((c = yyGet()))) ;
+ while (my_isxdigit(system_charset_info,(c = yyGet()))) ;
length=(lex->ptr - lex->tok_start); // Length of hexnum+3
if (!(length & 1) || c != '\'')
{
@@ -786,7 +788,7 @@ int yylex(void *arg)
ulong version=MYSQL_VERSION_ID;
yySkip();
state=STATE_START;
- if (isdigit(yyPeek()))
+ if (my_isdigit(system_charset_info,yyPeek()))
{ // Version number
version=strtol((char*) lex->ptr,(char**) &lex->ptr,10);
}
@@ -841,7 +843,7 @@ int yylex(void *arg)
// Actually real shouldn't start
// with . but allow them anyhow
case STATE_REAL_OR_POINT:
- if (isdigit(yyPeek()))
+ if (my_isdigit(system_charset_info,yyPeek()))
state = STATE_REAL; // Real
else
{
@@ -868,7 +870,7 @@ int yylex(void *arg)
return((int) '@');
case STATE_HOSTNAME: // end '@' of user@hostname
for (c=yyGet() ;
- isalnum(c) || c == '.' || c == '_' || c == '$';
+ my_isalnum(system_charset_info,c) || c == '.' || c == '_' || c == '$';
c= yyGet()) ;
yylval->lex_str=get_token(lex,yyLength());
return(LEX_HOSTNAME);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e649f109a0d..ef6c0eb2a5d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -692,7 +692,8 @@ pthread_handler_decl(handle_bootstrap,arg)
while (fgets(buff, thd->net.max_packet, file))
{
uint length=(uint) strlen(buff);
- while (length && (isspace(buff[length-1]) || buff[length-1] == ';'))
+ while (length && (my_isspace(system_charset_info, buff[length-1]) ||
+ buff[length-1] == ';'))
length--;
buff[length]=0;
thd->current_tablenr=0;
@@ -917,13 +918,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{
packet_length--; // Remove end null
/* Remove garage at start and end of query */
- while (isspace(packet[0]) && packet_length > 0)
+ while (my_isspace(system_charset_info,packet[0]) && packet_length > 0)
{
packet++;
packet_length--;
}
char *pos=packet+packet_length; // Point at end null
- while (packet_length > 0 && (pos[-1] == ';' || isspace(pos[-1])))
+ while (packet_length > 0 &&
+ (pos[-1] == ';' || my_isspace(system_charset_info,pos[-1])))
{
pos--;
packet_length--;
@@ -2261,7 +2263,8 @@ mysql_execute_command(void)
if (user->password.str &&
(strcmp(thd->user,user->user.str) ||
user->host.str &&
- my_strcasecmp(user->host.str, thd->host_or_ip)))
+ my_strcasecmp(system_charset_info,
+ user->host.str, thd->host_or_ip)))
{
if (check_access(thd, UPDATE_ACL, "mysql",0,1))
goto error;
@@ -3112,8 +3115,8 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
ptr->name=alias_str;
if (lower_case_table_names)
{
- casedn_str(ptr->db);
- casedn_str(table->table.str);
+ my_casedn_str(system_charset_info,ptr->db);
+ my_casedn_str(system_charset_info,table->table.str);
}
ptr->real_name=table->table.str;
ptr->lock_type=flags;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 52541ffe50f..3e7b8f13844 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -209,7 +209,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
else
{
// Return only .frm files which aren't temp files.
- if (my_strcasecmp(ext=fn_ext(file->name),reg_ext) ||
+ if (my_strcasecmp(system_charset_info, ext=fn_ext(file->name),reg_ext) ||
is_prefix(file->name,tmp_file_prefix))
continue;
*ext=0;
@@ -217,7 +217,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
{
if (lower_case_table_names)
{
- if (wild_case_compare(file->name,wild))
+ if (wild_case_compare(system_charset_info,file->name,wild))
continue;
}
else if (wild_compare(file->name,wild))
@@ -472,7 +472,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
String *packet= &thd->packet;
for (ptr=table->field; (field= *ptr) ; ptr++)
{
- if (!wild || !wild[0] || !wild_case_compare(field->field_name,wild))
+ if (!wild || !wild[0] ||
+ !wild_case_compare(system_charset_info, field->field_name,wild))
{
#ifdef NOT_USED
if (thd->col_access & TABLE_ACLS ||
@@ -744,7 +745,8 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
Field **ptr,*field;
for (ptr=table->field ; (field= *ptr); ptr++)
{
- if (!wild || !wild[0] || !wild_case_compare(field->field_name,wild))
+ if (!wild || !wild[0] ||
+ !wild_case_compare(system_charset_info, field->field_name,wild))
field_list.push_back(new Item_field(field));
}
restore_record(table,2); // Get empty record
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));
}
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 6e8fefb079a..811e49a0d02 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -198,8 +198,8 @@ public:
}
bool fill(uint32 max_length,char fill);
void strip_sp();
- inline void caseup() { ::caseup(Ptr,str_length); }
- inline void casedn() { ::casedn(Ptr,str_length); }
+ inline void caseup() { my_caseup(str_charset,Ptr,str_length); }
+ inline void casedn() { my_casedn(str_charset,Ptr,str_length); }
friend int sortcmp(const String *a,const String *b);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 4b849fd850d..7e679f59fc0 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -302,7 +302,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
null_fields++;
while ((dup_field=it2++) != sql_field)
{
- if (my_strcasecmp(sql_field->field_name, dup_field->field_name) == 0)
+ if (my_strcasecmp(system_charset_info,
+ sql_field->field_name,
+ dup_field->field_name) == 0)
{
my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name);
DBUG_RETURN(-1);
@@ -496,7 +498,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
it.rewind();
field=0;
while ((sql_field=it++) &&
- my_strcasecmp(column->field_name,sql_field->field_name))
+ my_strcasecmp(system_charset_info,
+ column->field_name,
+ sql_field->field_name))
field++;
if (!sql_field)
{
@@ -727,7 +731,7 @@ static bool
check_if_keyname_exists(const char *name, KEY *start, KEY *end)
{
for (KEY *key=start ; key != end ; key++)
- if (!my_strcasecmp(name,key->name))
+ if (!my_strcasecmp(system_charset_info,name,key->name))
return 1;
return 0;
}
@@ -1235,9 +1239,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
strmov(new_name_buff,new_name);
fn_same(new_name_buff,table_name,3);
if (lower_case_table_names)
- casedn_str(new_name);
+ my_casedn_str(system_charset_info,new_name);
if ((lower_case_table_names &&
- !my_strcasecmp(new_name_buff,table_name)) ||
+ !my_strcasecmp(system_charset_info, new_name_buff,table_name)) ||
(!lower_case_table_names &&
!strcmp(new_name_buff,table_name)))
new_name=table_name; // No. Make later check easier
@@ -1348,7 +1352,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
while ((drop=drop_it++))
{
if (drop->type == Alter_drop::COLUMN &&
- !my_strcasecmp(field->field_name, drop->name))
+ !my_strcasecmp(system_charset_info,field->field_name, drop->name))
{
/* Reset auto_increment value if it was dropped */
if (MTYP_TYPENR(field->unireg_check) == Field::NEXT_NUMBER &&
@@ -1369,7 +1373,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
def_it.rewind();
while ((def=def_it++))
{
- if (def->change && !my_strcasecmp(field->field_name, def->change))
+ if (def->change &&
+ !my_strcasecmp(system_charset_info,field->field_name, def->change))
break;
}
if (def)
@@ -1393,7 +1398,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
Alter_column *alter;
while ((alter=alter_it++))
{
- if (!my_strcasecmp(field->field_name, alter->name))
+ if (!my_strcasecmp(system_charset_info,field->field_name, alter->name))
break;
}
if (alter)
@@ -1427,7 +1432,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
find_it.rewind();
while ((find=find_it++)) // Add new columns
{
- if (!my_strcasecmp(def->after, find->field_name))
+ if (!my_strcasecmp(system_charset_info,def->after, find->field_name))
break;
}
if (!find)
@@ -1473,7 +1478,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
while ((drop=drop_it++))
{
if (drop->type == Alter_drop::KEY &&
- !my_strcasecmp(key_name, drop->name))
+ !my_strcasecmp(system_charset_info,key_name, drop->name))
break;
}
if (drop)
@@ -1495,10 +1500,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if (cfield->change)
{
- if (!my_strcasecmp(key_part_name, cfield->change))
+ if (!my_strcasecmp(system_charset_info,key_part_name, cfield->change))
break;
}
- else if (!my_strcasecmp(key_part_name, cfield->field_name))
+ else if (!my_strcasecmp(system_charset_info,
+ key_part_name, cfield->field_name))
break;
}
if (!cfield)
@@ -1518,7 +1524,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (key_parts.elements)
key_list.push_back(new Key(key_info->flags & HA_SPATIAL ? Key::SPATIAL :
(key_info->flags & HA_NOSAME ?
- (!my_strcasecmp(key_name, "PRIMARY") ?
+ (!my_strcasecmp(system_charset_info,
+ key_name, "PRIMARY") ?
Key::PRIMARY : Key::UNIQUE) :
(key_info->flags & HA_FULLTEXT ?
Key::FULLTEXT : Key::MULTIPLE)),
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 41e56328613..d762c8784a3 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3654,7 +3654,8 @@ column_list_id:
LEX *lex=Lex;
while ((point=iter++))
{
- if (!my_strcasecmp(point->column.ptr(),new_str->ptr()))
+ if (!my_strcasecmp(system_charset_info,
+ point->column.ptr(), new_str->ptr()))
break;
}
lex->grant_tot_col|= lex->which_columns;
diff --git a/sql/table.cc b/sql/table.cc
index 9e6283d6ad4..2fa5d41f1ba 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1067,9 +1067,10 @@ bool check_db_name(const char *name)
while (*name)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
- if (use_mb(default_charset_info))
+ if (use_mb(system_charset_info))
{
- int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN);
+ int len=my_ismbchar(system_charset_info, name,
+ name+system_charset_info->mbmaxlen);
if (len)
{
name += len;
@@ -1099,9 +1100,9 @@ bool check_table_name(const char *name, uint length)
while (name != end)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
- if (use_mb(default_charset_info))
+ if (use_mb(system_charset_info))
{
- int len=my_ismbchar(default_charset_info, name, end);
+ int len=my_ismbchar(system_charset_info, name, end);
if (len)
{
name += len;
@@ -1121,9 +1122,10 @@ bool check_column_name(const char *name)
while (*name)
{
#if defined(USE_MB) && defined(USE_MB_IDENT)
- if (use_mb(default_charset_info))
+ if (use_mb(system_charset_info))
{
- int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN);
+ int len=my_ismbchar(system_charset_info, name,
+ name+system_charset_info->mbmaxlen);
if (len)
{
name += len;
diff --git a/sql/time.cc b/sql/time.cc
index aab886648e3..2a791ccc30e 100644
--- a/sql/time.cc
+++ b/sql/time.cc
@@ -268,13 +268,13 @@ void find_date(string pos,uint *vek,uint flag)
DBUG_PRINT("enter",("pos: '%s' flag: %d",pos,flag));
bzero((char*) vek,sizeof(int)*4);
- while (*pos && !isdigit(*pos))
+ while (*pos && !my_isdigit(system_charset_info,*pos))
pos++;
length=(uint) strlen(pos);
for (uint i=0 ; i< 3; i++)
{
start=pos; value=0;
- while (isdigit(pos[0]) &&
+ while (my_isdigit(system_charset_info,pos[0]) &&
((pos-start) < 2 || ((pos-start) < 4 && length >= 8 &&
!(flag & 3))))
{
@@ -282,7 +282,8 @@ void find_date(string pos,uint *vek,uint flag)
pos++;
}
vek[flag & 3]=value; flag>>=2;
- while (*pos && (ispunct(*pos) || isspace(*pos)))
+ while (*pos && (my_ispunct(system_charset_info,*pos) ||
+ my_isspace(system_charset_info,*pos)))
pos++;
}
DBUG_PRINT("exit",("year: %d month: %d day: %d",vek[0],vek[1],vek[2]));
@@ -434,7 +435,8 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
DBUG_ENTER("str_to_TIME");
DBUG_PRINT("enter",("str: %.*s",length,str));
- for (; str != end && !isdigit(*str) ; str++) ; // Skip garbage
+ // Skip garbage
+ for (; str != end && !my_isdigit(system_charset_info, *str) ; str++) ;
if (str == end)
DBUG_RETURN(TIMESTAMP_NONE);
/*
@@ -442,14 +444,14 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
** If length= 8 or >= 14 then year is of format YYYY.
(YYYY-MM-DD, YYYYMMDD, YYYYYMMDDHHMMSS)
*/
- for (pos=str; pos != end && isdigit(*pos) ; pos++) ;
+ for (pos=str; pos != end && my_isdigit(system_charset_info,*pos) ; pos++) ;
digits= (uint) (pos-str);
year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2;
field_length=year_length-1;
- for (i=0 ; i < 6 && str != end && isdigit(*str) ; i++)
+ for (i=0 ; i < 6 && str != end && my_isdigit(system_charset_info,*str) ; i++)
{
uint tmp_value=(uint) (uchar) (*str++ - '0');
- while (str != end && isdigit(str[0]) && field_length--)
+ while (str != end && my_isdigit(system_charset_info,str[0]) && field_length--)
{
tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0');
str++;
@@ -459,10 +461,12 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
str++; // ISO8601: CCYYMMDDThhmmss
else if ( i != 5 ) // Skip inter-field delimiters
{
- while (str != end && (ispunct(*str) || isspace(*str)))
+ while (str != end &&
+ (my_ispunct(system_charset_info,*str) ||
+ my_isspace(system_charset_info,*str)))
{
// Only allow space between days and hours
- if (isspace(*str) && i != 2)
+ if (my_isspace(system_charset_info,*str) && i != 2)
DBUG_RETURN(TIMESTAMP_NONE);
str++;
}
@@ -470,12 +474,13 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
field_length=1; // Rest fields can only be 2
}
/* Handle second fractions */
- if (i == 6 && (uint) (end-str) >= 2 && *str == '.' && isdigit(str[1]))
+ if (i == 6 && (uint) (end-str) >= 2 && *str == '.' &&
+ my_isdigit(system_charset_info,str[1]))
{
str++;
uint tmp_value=(uint) (uchar) (*str - '0');
field_length=3;
- while (str++ != end && isdigit(str[0]) && field_length--)
+ while (str++ != end && my_isdigit(system_charset_info,str[0]) && field_length--)
tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0');
date[6]=tmp_value;
}
@@ -498,7 +503,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
{
for ( ; str != end ; str++)
{
- if (!isspace(*str))
+ if (!my_isspace(system_charset_info,*str))
{
current_thd->cuted_fields++;
break;
@@ -559,7 +564,8 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
uint state;
l_time->neg=0;
- for (; str != end && !isdigit(*str) && *str != '-' ; str++)
+ for (; str != end &&
+ !my_isdigit(system_charset_info,*str) && *str != '-' ; str++)
length--;
if (str != end && *str == '-')
{
@@ -578,7 +584,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
}
/* Not a timestamp. Try to get this as a DAYS_TO_SECOND string */
- for (value=0; str != end && isdigit(*str) ; str++)
+ for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++)
value=value*10L + (long) (*str - '0');
if (*str == ' ')
@@ -589,14 +595,16 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
LINT_INIT(state);
found_days=found_hours=0;
- if ((uint) (end-str) > 1 && (*str == ' ' && isdigit(str[1])))
+ if ((uint) (end-str) > 1 && (*str == ' ' &&
+ my_isdigit(system_charset_info,str[1])))
{ // days !
date[0]=value;
state=1; // Assume next is hours
found_days=1;
str++; // Skip space;
}
- else if ((end-str) > 1 && *str == ':' && isdigit(str[1]))
+ else if ((end-str) > 1 && *str == ':' &&
+ my_isdigit(system_charset_info,str[1]))
{
date[0]=0; // Assume we found hours
date[1]=value;
@@ -618,10 +626,11 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
/* Read hours, minutes and seconds */
for (;;)
{
- for (value=0; str != end && isdigit(*str) ; str++)
+ for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++)
value=value*10L + (long) (*str - '0');
date[state++]=value;
- if (state == 4 || (end-str) < 2 || *str != ':' || !isdigit(str[1]))
+ if (state == 4 || (end-str) < 2 || *str != ':' ||
+ !my_isdigit(system_charset_info,str[1]))
break;
str++; // Skip ':'
}
@@ -641,11 +650,13 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
fractional:
/* Get fractional second part */
- if ((end-str) >= 2 && *str == '.' && isdigit(str[1]))
+ if ((end-str) >= 2 && *str == '.' && my_isdigit(system_charset_info,str[1]))
{
uint field_length=3;
str++; value=(uint) (uchar) (*str - '0');
- while (++str != end && isdigit(str[0]) && field_length--)
+ while (++str != end &&
+ my_isdigit(system_charset_info,str[0]) &&
+ field_length--)
value=value*10 + (uint) (uchar) (*str - '0');
date[4]=value;
}
@@ -670,7 +681,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
{
do
{
- if (!isspace(*str))
+ if (!my_isspace(system_charset_info,*str))
{
current_thd->cuted_fields++;
break;
diff --git a/strings/Makefile.am b/strings/Makefile.am
index c1cfe64eb70..33d048a42d1 100644
--- a/strings/Makefile.am
+++ b/strings/Makefile.am
@@ -22,19 +22,19 @@ pkglib_LIBRARIES = libmystrings.a
# Exact one of ASSEMBLER_X
if ASSEMBLER_x86
ASRCS = strings-x86.s longlong2str-x86.s
-CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c strnlen.c
+CSRCS = bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c ctype-simple.c ctype-mb.c strnlen.c
else
if ASSEMBLER_sparc
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
ASRCS = bmove_upp-sparc.s strappend-sparc.s strend-sparc.s strinstr-sparc.s strmake-sparc.s strmov-sparc.s strnmov-sparc.s strstr-sparc.s strxmov-sparc.s
-CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c strnlen.c
+CSRCS = strcont.c strfill.c strcend.c is_prefix.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c ctype-simple.c ctype-mb.c strnlen.c
else
#no assembler
ASRCS =
# These file MUST all be on the same line!! Otherwise automake
# generats a very broken makefile
-CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c strnlen.c
+CSRCS = strxmov.c bmove_upp.c strappend.c strcont.c strend.c strfill.c strcend.c is_prefix.c strstr.c strinstr.c strmake.c strnmov.c strmov.c longlong2str.c bfill.c bmove.c bmove512.c bchange.c strxnmov.c int2str.c str2int.c r_strinstr.c atof.c bcmp.c strtol.c strtoul.c strtoll.c strtoull.c llstr.c ctype.c ctype-simple.c ctype-mb.c strnlen.c
endif
endif
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 44f8a100897..2155f3e72c9 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -213,7 +213,9 @@ static uint16 big5strokexfrm(uint16 i)
return 0xA140;
}
-int my_strnncoll_big5(const uchar * s1, int len1, const uchar * s2, int len2)
+int my_strnncoll_big5(CHARSET_INFO *cs,
+ const uchar * s1, uint len1,
+ const uchar * s2, uint len2)
{
uint len;
@@ -235,10 +237,11 @@ int my_strnncoll_big5(const uchar * s1, int len1, const uchar * s2, int len2)
return (int) (len1-len2);
}
-int my_strnxfrm_big5(uchar * dest, const uchar * src, int len, int srclen)
+int my_strnxfrm_big5(CHARSET_INFO *cs,
+ uchar * dest, uint len,
+ const uchar * src, uint srclen)
{
uint16 e;
- /*uchar *d = dest; XXX: unused*/
len = srclen;
while (len--)
@@ -323,7 +326,8 @@ int my_strxfrm_big5(uchar * dest, const uchar * src, int len)
#define wild_one '_'
#define wild_many '%'
-my_bool my_like_range_big5(const char *ptr,uint ptr_length,pchar escape,
+my_bool my_like_range_big5(CHARSET_INFO *cs,
+ const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
{
diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c
index 4564ca2361b..7db37c0b5d9 100644
--- a/strings/ctype-czech.c
+++ b/strings/ctype-czech.c
@@ -280,7 +280,9 @@ int my_strxfrm_czech(uchar * dest, const uchar * src, int len)
/* Function strnncoll, actually strcoll, with Czech sorting, which expect
the length of the strings being specified */
-int my_strnncoll_czech(const uchar * s1, int len1, const uchar * s2, int len2)
+int my_strnncoll_czech(CHARSET_INFO *cs,
+ const uchar * s1, uint len1,
+ const uchar * s2, uint len2)
{
int v1, v2;
const uchar * p1, * p2, * store1, * store2;
@@ -292,8 +294,8 @@ int my_strnncoll_czech(const uchar * s1, int len1, const uchar * s2, int len2)
do
{
- NEXT_CMP_VALUE(s1, p1, store1, pass1, v1, len1);
- NEXT_CMP_VALUE(s2, p2, store2, pass2, v2, len2);
+ NEXT_CMP_VALUE(s1, p1, store1, pass1, v1, (int)len1);
+ NEXT_CMP_VALUE(s2, p2, store2, pass2, v2, (int)len2);
diff = v1 - v2;
if (diff != 0) return diff;
@@ -304,7 +306,9 @@ int my_strnncoll_czech(const uchar * s1, int len1, const uchar * s2, int len2)
/* Function strnxfrm, actually strxfrm, with Czech sorting, which expect
the length of the strings being specified */
-int my_strnxfrm_czech(uchar * dest, const uchar * src, int len, int srclen)
+int my_strnxfrm_czech(CHARSET_INFO *cs,
+ uchar * dest, uint len,
+ const uchar * src, uint srclen)
{
int value;
const uchar * p, * store;
@@ -314,8 +318,8 @@ int my_strnxfrm_czech(uchar * dest, const uchar * src, int len, int srclen)
do
{
- NEXT_CMP_VALUE(src, p, store, pass, value, srclen);
- ADD_TO_RESULT(dest, len, totlen, value);
+ NEXT_CMP_VALUE(src, p, store, pass, value, (int)srclen);
+ ADD_TO_RESULT(dest, (int)len, totlen, value);
}
while (value);
return totlen;
@@ -372,7 +376,8 @@ int my_strnxfrm_czech(uchar * dest, const uchar * src, int len, int srclen)
#define EXAMPLE
-my_bool my_like_range_czech(const char *ptr,uint ptr_length,pchar escape,
+my_bool my_like_range_czech(CHARSET_INFO *cs,
+ const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
{
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 9fccce175d8..3ef37d2f6bb 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -2579,7 +2579,9 @@ static uint16 gbksortorder(uint16 i)
}
-int my_strnncoll_gbk(const uchar * s1, int len1, const uchar * s2, int len2)
+int my_strnncoll_gbk(CHARSET_INFO *cs,
+ const uchar * s1, uint len1,
+ const uchar * s2, uint len2)
{
uint len,c1,c2;
@@ -2603,13 +2605,10 @@ int my_strnncoll_gbk(const uchar * s1, int len1, const uchar * s2, int len2)
return (int) (len1-len2);
}
-int my_strcoll_gbk(const uchar * s1, const uchar * s2)
-{
- return my_strnncoll_gbk(s1, (uint) strlen((char*) s1),
- s2, (uint) strlen((char*) s2));
-}
-int my_strnxfrm_gbk(uchar * dest, const uchar * src, int len, int srclen)
+int my_strnxfrm_gbk(CHARSET_INFO *cs,
+ uchar * dest, uint len,
+ const uchar * src, uint srclen)
{
uint16 e;
@@ -2629,10 +2628,6 @@ int my_strnxfrm_gbk(uchar * dest, const uchar * src, int len, int srclen)
return srclen;
}
-int my_strxfrm_gbk(uchar * dest, const uchar * src, int len)
-{
- return my_strnxfrm_gbk(dest,src,len,(uint) strlen((char*) src));
-}
/*
** Calculate min_str and max_str that ranges a LIKE string.
@@ -2655,7 +2650,8 @@ int my_strxfrm_gbk(uchar * dest, const uchar * src, int len)
#define wild_one '_'
#define wild_many '%'
-extern my_bool my_like_range_gbk(const char *ptr,uint ptr_length,pchar escape,
+extern my_bool my_like_range_gbk(CHARSET_INFO *cs,
+ const char *ptr,uint ptr_length,pchar escape,
uint res_length, char *min_str,char *max_str,
uint *min_length,uint *max_length)
{
diff --git a/strings/ctype-latin1_de.c b/strings/ctype-latin1_de.c
index 86b667b8f40..961112a65b4 100644
--- a/strings/ctype-latin1_de.c
+++ b/strings/ctype-latin1_de.c
@@ -162,8 +162,9 @@ uchar sort_order_latin1_de[] = {
}
-int my_strnncoll_latin1_de(const uchar * s1, int len1,
- const uchar * s2, int len2)
+int my_strnncoll_latin1_de(CHARSET_INFO *cs,
+ const uchar * s1, uint len1,
+ const uchar * s2, uint len2)
{
const uchar *e1 = s1 + len1;
const uchar *e2 = s2 + len2;
@@ -235,7 +236,9 @@ int my_strnncoll_latin1_de(const uchar * s1, int len1,
}
-int my_strnxfrm_latin1_de(uchar * dest, const uchar * src, int len, int srclen)
+int my_strnxfrm_latin1_de(CHARSET_INFO *cs,
+ uchar * dest, uint len,
+ const uchar * src, uint srclen)
{
const uchar *dest_orig = dest;
const uchar *de = dest + len;
@@ -274,19 +277,6 @@ int my_strnxfrm_latin1_de(uchar * dest, const uchar * src, int len, int srclen)
}
-int my_strcoll_latin1_de(const uchar * s1, const uchar * s2)
-{
- /* XXX QQ: This should be fixed to not call strlen */
- return my_strnncoll_latin1_de(s1, strlen((char*) s1),
- s2, strlen((char*) s2));
-}
-
-int my_strxfrm_latin1_de(uchar * dest, const uchar * src, int len)
-{
- /* XXX QQ: This should be fixed to not call strlen */
- return my_strnxfrm_latin1_de(dest, src, len, strlen((char*) src));
-}
-
/*
* Calculate min_str and max_str that ranges a LIKE string.
* Arguments:
@@ -311,7 +301,8 @@ int my_strxfrm_latin1_de(uchar * dest, const uchar * src, int len)
#define wild_one '_'
#define wild_many '%'
-my_bool my_like_range_latin1_de(const char *ptr, uint ptr_length,
+my_bool my_like_range_latin1_de(CHARSET_INFO *cs,
+ const char *ptr, uint ptr_length,
pchar escape, uint res_length,
char *min_str, char *max_str,
uint *min_length, uint *max_length)
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
new file mode 100644
index 00000000000..97de219429c
--- /dev/null
+++ b/strings/ctype-mb.c
@@ -0,0 +1,125 @@
+/* Copyright (C) 2000 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <my_global.h>
+#include "m_ctype.h"
+
+void my_caseup_str_mb(CHARSET_INFO * cs, char *str)
+{
+ register uint32 l;
+ register char *end=str+strlen(str); /* BAR TODO: remove strlen() call */
+ while (*str)
+ {
+ if ((l=my_ismbchar(cs, str,end)))
+ str+=l;
+ else
+ {
+ *str=(char)my_toupper(cs,(uchar)*str);
+ str++;
+ }
+ }
+}
+
+void my_casedn_str_mb(CHARSET_INFO * cs, char *str)
+{
+ register uint32 l;
+ register char *end=str+strlen(str);
+ while (*str)
+ {
+ if ((l=my_ismbchar(cs, str,end)))
+ str+=l;
+ else
+ {
+ *str=(char)my_tolower(cs,(uchar)*str);
+ str++;
+ }
+ }
+}
+
+void my_caseup_mb(CHARSET_INFO * cs, char *str, uint length)
+{
+ register uint32 l;
+ register char *end=str+length;
+ while (str<end)
+ {
+ if ((l=my_ismbchar(cs, str,end)))
+ str+=l;
+ else
+ {
+ *str=(char)my_toupper(cs,(uchar)*str);
+ str++;
+ }
+ }
+}
+
+void my_casedn_mb(CHARSET_INFO * cs, char *str, uint length)
+{
+ register uint32 l;
+ register char *end=str+length;
+ while (str<end)
+ {
+ if ((l=my_ismbchar(cs, str,end)))
+ str+=l;
+ else
+ {
+ *str=(char)my_tolower(cs,(uchar)*str);
+ str++;
+ }
+ }
+}
+
+int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t)
+{
+ register uint32 l;
+ register const char *end=s+strlen(s);
+ while (s<end)
+ {
+ if ((l=my_ismbchar(cs, s,end)))
+ {
+ while (l--)
+ if (*s++ != *t++)
+ return 1;
+ }
+ else if (my_ismbhead(cs, *t))
+ return 1;
+ else if (my_toupper(cs,(uchar) *s++) != my_toupper(cs,(uchar) *t++))
+ return 1;
+ }
+ return *t;
+}
+
+
+int my_strncasecmp_mb(CHARSET_INFO * cs,
+ const char *s, const char *t, uint len)
+{
+ register uint32 l;
+ register const char *end=s+len;
+ while (s<end)
+ {
+ if ((l=my_ismbchar(cs, s,end)))
+ {
+ while (l--)
+ if (*s++ != *t++)
+ return 1;
+ }
+ else if (my_ismbhead(cs, *t))
+ return 1;
+ else if (my_toupper(cs,(uchar) *s++) != my_toupper(cs,(uchar) *t++))
+ return 1;
+ }
+ return 0;
+}
+
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
new file mode 100644
index 00000000000..5473a15e4fe
--- /dev/null
+++ b/strings/ctype-simple.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 2000 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <my_global.h>
+#include "m_ctype.h"
+#include "dbug.h"
+#include "assert.h"
+
+int my_strnxfrm_simple(CHARSET_INFO * cs,
+ char *dest, uint len,
+ const char *src, uint srclen)
+{
+ DBUG_ASSERT(len >= srclen);
+
+ for ( ; len > 0 ; len-- )
+ *dest++= (char) cs->sort_order[(uchar) *src++];
+ return srclen;
+}
+
+int my_strnncoll_simple(CHARSET_INFO * cs,const char *s, uint slen,
+ const char *t, uint tlen)
+{
+ int len = ( slen > tlen ) ? tlen : slen;
+ while (len--)
+ {
+ if (cs->sort_order[(uchar) *s++] != cs->sort_order[(uchar) *t++])
+ return ((int) cs->sort_order[(uchar) s[-1]] -
+ (int) cs->sort_order[(uchar) t[-1]]);
+ }
+ return (int) (slen-tlen);
+}
+
+
+void my_caseup_str_8bit(CHARSET_INFO * cs,char *str)
+{
+ while ((*str = (char) my_toupper(cs,(uchar) *str)) != 0)
+ str++;
+}
+
+
+void my_casedn_str_8bit(CHARSET_INFO * cs,char *str)
+{
+ while ((*str = (char) my_tolower(cs,(uchar)*str)) != 0)
+ str++;
+}
+
+
+void my_caseup_8bit(CHARSET_INFO * cs, char *str, uint length)
+{
+ for ( ; length>0 ; length--, str++)
+ *str= (char) my_toupper(cs,(uchar)*str);
+}
+
+void my_casedn_8bit(CHARSET_INFO * cs, char *str, uint length)
+{
+ for ( ; length>0 ; length--, str++)
+ *str= (char)my_tolower(cs,(uchar) *str);
+}
+
+
+int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t)
+{
+ while (my_toupper(cs,(uchar) *s) == my_toupper(cs,(uchar) *t++))
+ if (!*s++) return 0;
+ return ((int) my_toupper(cs,(uchar) s[0]) - (int) my_toupper(cs,(uchar) t[-1]));
+}
+
+
+int my_strncasecmp_8bit(CHARSET_INFO * cs,
+ const char *s, const char *t, uint len)
+{
+ while (len-- != 0 && my_toupper(cs,(uchar)*s++) == my_toupper(cs,(uchar)*t++)) ;
+ return (int) len+1;
+}
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 5d5f64cc5fe..f3c5d8a2920 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -198,7 +198,9 @@ int mbcharlen_sjis(uint c)
#define sjiscode(c,d) ((((uint) (uchar)(c)) << 8) | (uint) (uchar) (d))
-int my_strnncoll_sjis(const uchar *s1, int len1, const uchar *s2, int len2)
+int my_strnncoll_sjis(CHARSET_INFO *cs,
+ const uchar *s1, uint len1,
+ const uchar *s2, uint len2)
{
const uchar *e1 = s1 + len1;
const uchar *e2 = s2 + len2;
@@ -221,13 +223,9 @@ int my_strnncoll_sjis(const uchar *s1, int len1, const uchar *s2, int len2)
return len1 - len2;
}
-int my_strcoll_sjis(const uchar *s1, const uchar *s2)
-{
- return (uint) my_strnncoll_sjis(s1,(uint) strlen((char*) s1),
- s2,(uint) strlen((char*) s2));
-}
-
-int my_strnxfrm_sjis(uchar *dest, const uchar *src, int len, int srclen)
+int my_strnxfrm_sjis(CHARSET_INFO *cs,
+ uchar *dest, uint len,
+ const uchar *src, uint srclen)
{
uchar *d_end = dest + len;
uchar *s_end = (uchar*) src + srclen;
@@ -243,12 +241,6 @@ int my_strnxfrm_sjis(uchar *dest, const uchar *src, int len, int srclen)
return srclen;
}
-int my_strxfrm_sjis(uchar *dest, const uchar *src, int len)
-{
- return my_strnxfrm_sjis(dest, src, len, (uint) strlen((char*) src));
-}
-
-
/*
** Calculate min_str and max_str that ranges a LIKE string.
** Arguments:
@@ -270,9 +262,10 @@ int my_strxfrm_sjis(uchar *dest, const uchar *src, int len)
#define wild_one '_'
#define wild_many '%'
-my_bool my_like_range_sjis(const char *ptr,uint ptr_length,pchar escape,
- uint res_length, char *min_str,char *max_str,
- uint *min_length,uint *max_length)
+my_bool my_like_range_sjis(CHARSET_INFO *cs,
+ const char *ptr,uint ptr_length,pchar escape,
+ 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 370c4c773c6..134ab527ecc 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -535,7 +535,9 @@ static uchar* thai2sortable(const uchar * tstr,uint len)
Arg: 2 Strings and it compare length
Ret: strcmp result
*/
-int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
+int my_strnncoll_tis620(CHARSET_INFO *cs,
+ const uchar * s1, uint len1,
+ const uchar * s2, uint len2)
{
uchar *tc1, *tc2;
int i;
@@ -551,7 +553,9 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
Arg: Destination buffer, source string, dest length and source length
Ret: Conveted string size
*/
-int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
+int my_strnxfrm_tis620(CHARSET_INFO *cs,
+ uchar * dest, uint len,
+ const uchar * src, uint srclen)
{
uint bufSize;
uchar *tmp;
@@ -607,7 +611,8 @@ int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
#define wild_one '_'
#define wild_many '%'
-my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape,
+my_bool my_like_range_tis620(CHARSET_INFO *cs,
+ const char *ptr, uint ptr_length, pchar escape,
uint res_length, char *min_str, char *max_str,
uint *min_length, uint *max_length)
{
diff --git a/strings/ctype.c b/strings/ctype.c
index ab17a16bb54..5e2bb38d4fd 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -1967,8 +1967,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_latin1,
sort_order_latin1,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -1976,7 +1974,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -1989,8 +1993,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_big5,
sort_order_big5,
1, /* strxfrm_multiply */
- my_strcoll_big5,
- my_strxfrm_big5,
my_strnncoll_big5,
my_strnxfrm_big5,
my_like_range_big5,
@@ -1998,7 +2000,13 @@ CHARSET_INFO compiled_charsets[] = {
ismbchar_big5,
ismbhead_big5,
mbcharlen_big5,
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_mb,
+ my_casedn_str_mb,
+ my_caseup_mb,
+ my_casedn_mb,
+ my_strcasecmp_mb,
+ my_strncasecmp_mb,
+ 0
},
#endif
@@ -2011,8 +2019,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_cp1251,
sort_order_cp1251,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2020,7 +2026,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2033,8 +2045,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_cp1257,
sort_order_cp1257,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2042,7 +2052,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2055,8 +2071,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_croat,
sort_order_croat,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2064,7 +2078,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2077,8 +2097,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_czech,
sort_order_czech,
4, /* strxfrm_multiply */
- my_strcoll_czech,
- my_strxfrm_czech,
my_strnncoll_czech,
my_strnxfrm_czech,
my_like_range_czech,
@@ -2086,7 +2104,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2099,8 +2123,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_danish,
sort_order_danish,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2108,7 +2130,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2121,8 +2149,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_dec8,
sort_order_dec8,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2130,7 +2156,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2143,8 +2175,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_dos,
sort_order_dos,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2152,7 +2182,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2165,8 +2201,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_estonia,
sort_order_estonia,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2174,7 +2208,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2187,8 +2227,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_euc_kr,
sort_order_euc_kr,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2196,7 +2234,13 @@ CHARSET_INFO compiled_charsets[] = {
ismbchar_euc_kr,
ismbhead_euc_kr,
mbcharlen_euc_kr,
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_mb,
+ my_casedn_str_mb,
+ my_caseup_mb,
+ my_casedn_mb,
+ my_strcasecmp_mb,
+ my_strncasecmp_mb,
+ 0
},
#endif
@@ -2209,8 +2253,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_gb2312,
sort_order_gb2312,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2218,7 +2260,13 @@ CHARSET_INFO compiled_charsets[] = {
ismbchar_gb2312,
ismbhead_gb2312,
mbcharlen_gb2312,
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_mb,
+ my_casedn_str_mb,
+ my_caseup_mb,
+ my_casedn_mb,
+ my_strcasecmp_mb,
+ my_strncasecmp_mb,
+ 0
},
#endif
@@ -2231,8 +2279,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_gbk,
sort_order_gbk,
1, /* strxfrm_multiply */
- my_strcoll_gbk,
- my_strxfrm_gbk,
my_strnncoll_gbk,
my_strnxfrm_gbk,
my_like_range_gbk,
@@ -2240,7 +2286,13 @@ CHARSET_INFO compiled_charsets[] = {
ismbchar_gbk,
ismbhead_gbk,
mbcharlen_gbk,
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_mb,
+ my_casedn_str_mb,
+ my_caseup_mb,
+ my_casedn_mb,
+ my_strcasecmp_mb,
+ my_strncasecmp_mb,
+ 0
},
#endif
@@ -2253,8 +2305,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_german1,
sort_order_german1,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2262,7 +2312,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2275,8 +2331,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_greek,
sort_order_greek,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2284,7 +2338,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2297,8 +2357,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_hebrew,
sort_order_hebrew,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2306,7 +2364,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2319,8 +2383,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_hp8,
sort_order_hp8,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2328,7 +2390,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2341,8 +2409,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_hungarian,
sort_order_hungarian,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2350,7 +2416,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2363,8 +2435,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_koi8_ru,
sort_order_koi8_ru,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2372,7 +2442,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2385,8 +2461,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_koi8_ukr,
sort_order_koi8_ukr,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2394,7 +2468,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2407,8 +2487,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_latin1_de,
sort_order_latin1_de,
2, /* strxfrm_multiply */
- my_strcoll_latin1_de,
- my_strxfrm_latin1_de,
my_strnncoll_latin1_de,
my_strnxfrm_latin1_de,
my_like_range_latin1_de,
@@ -2416,7 +2494,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2429,8 +2513,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_latin2,
sort_order_latin2,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2438,7 +2520,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2451,8 +2539,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_latin5,
sort_order_latin5,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2460,7 +2546,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2473,8 +2565,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_sjis,
sort_order_sjis,
1, /* strxfrm_multiply */
- my_strcoll_sjis,
- my_strxfrm_sjis,
my_strnncoll_sjis,
my_strnxfrm_sjis,
my_like_range_sjis,
@@ -2482,7 +2572,13 @@ CHARSET_INFO compiled_charsets[] = {
ismbchar_sjis,
ismbhead_sjis,
mbcharlen_sjis,
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2495,8 +2591,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_swe7,
sort_order_swe7,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2504,7 +2598,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2517,8 +2617,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_tis620,
sort_order_tis620,
4, /* strxfrm_multiply */
- my_strcoll_tis620,
- my_strxfrm_tis620,
my_strnncoll_tis620,
my_strnxfrm_tis620,
my_like_range_tis620,
@@ -2526,7 +2624,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2539,8 +2643,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_ujis,
sort_order_ujis,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2548,7 +2650,13 @@ CHARSET_INFO compiled_charsets[] = {
ismbchar_ujis,
ismbhead_ujis,
mbcharlen_ujis,
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_mb,
+ my_casedn_str_mb,
+ my_caseup_mb,
+ my_casedn_mb,
+ my_strcasecmp_mb,
+ my_strncasecmp_mb,
+ 0
},
#endif
@@ -2561,8 +2669,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_usa7,
sort_order_usa7,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2570,7 +2676,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2583,8 +2695,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_win1250,
sort_order_win1250,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2592,7 +2702,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2605,8 +2721,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_win1251ukr,
sort_order_win1251ukr,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2614,7 +2728,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2627,8 +2747,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_armscii8,
sort_order_armscii8,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2636,7 +2754,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2649,8 +2773,6 @@ CHARSET_INFO compiled_charsets[] = {
to_upper_win1251,
sort_order_win1251,
0, /* strxfrm_multiply */
- NULL, /* strcoll */
- NULL, /* strxfrm */
NULL, /* strnncoll */
NULL, /* strnxfrm */
NULL, /* like_range */
@@ -2658,7 +2780,13 @@ CHARSET_INFO compiled_charsets[] = {
NULL, /* ismbchar */
NULL, /* ismbhead */
NULL, /* mbcharlen */
- NULL,NULL,NULL,NULL,NULL,NULL
+ my_caseup_str_8bit,
+ my_casedn_str_8bit,
+ my_caseup_8bit,
+ my_casedn_8bit,
+ my_strcasecmp_8bit,
+ my_strncasecmp_8bit,
+ 0
},
#endif
@@ -2673,18 +2801,23 @@ CHARSET_INFO compiled_charsets[] = {
NULL,
NULL,
NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
NULL,
NULL,
- 0,
NULL,
NULL,
NULL,
- NULL,NULL,NULL,NULL,NULL,NULL
+ 0
}
};
CHARSET_INFO *default_charset_info = &compiled_charsets[0];
+CHARSET_INFO *system_charset_info = &compiled_charsets[0];
CHARSET_INFO *find_compiled_charset(uint cs_number)
{
diff --git a/strings/str2int.c b/strings/str2int.c
index 58669287473..d7e6bb9aabc 100644
--- a/strings/str2int.c
+++ b/strings/str2int.c
@@ -98,7 +98,7 @@ char *str2int(register const char *src, register int radix, long int lower,
converted value (and the scale!) as *negative* numbers,
so the sign is the opposite of what you might expect.
*/
- while (isspace(*src)) src++;
+ while (my_isspace(system_charset_info,*src)) src++;
sign = -1;
if (*src == '+') src++; else
if (*src == '-') src++, sign = 1;
diff --git a/strings/strto.c b/strings/strto.c
index 84dccbcbeb8..9af101296a3 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 (isspace (*s))
+ while (my_isspace (system_charset_info, *s))
++s;
if (*s == '\0')
{
@@ -116,7 +116,7 @@ function (const char *nptr,char **endptr,int base)
else
negative = 0;
- if (base == 16 && s[0] == '0' && toupper (s[1]) == 'X')
+ if (base == 16 && s[0] == '0' && my_toupper (system_charset_info, s[1]) == 'X')
s += 2;
/* If BASE is zero, figure it out ourselves. */
@@ -124,7 +124,7 @@ function (const char *nptr,char **endptr,int base)
{
if (*s == '0')
{
- if (toupper (s[1]) == 'X')
+ if (my_toupper (system_charset_into, s[1]) == 'X')
{
s += 2;
base = 16;
@@ -146,10 +146,10 @@ function (const char *nptr,char **endptr,int base)
i = 0;
for (c = *s; c != '\0'; c = *++s)
{
- if (isdigit (c))
+ if (my_isdigit (system_charset_info, c))
c -= '0';
- else if (isalpha (c))
- c = toupper (c) - 'A' + 10;
+ else if (my_isalpha (system_charset_info, c))
+ c = my_toupper (system_charset_into, c) - 'A' + 10;
else
break;
if (c >= base)
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index bd43c6bc0ec..9dbf433d8a1 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -402,8 +402,8 @@ static int exec_line(struct manager_thd* thd,char* buf,char* buf_end)
{
char* p=buf;
struct manager_cmd* cmd;
- for (;p<buf_end && !isspace(*p);p++)
- *p=tolower(*p);
+ for (;p<buf_end && !my_isspace(system_charset_info,*p);p++)
+ *p=my_tolower(system_charset_info,*p);
log_info("Command '%s'", buf);
if (!(cmd=lookup_cmd(buf,(int)(p-buf))))
{
@@ -413,7 +413,7 @@ static int exec_line(struct manager_thd* thd,char* buf,char* buf_end)
thd->fatal=1;
return 1;
}
- for (;p<buf_end && isspace(*p);p++);
+ for (;p<buf_end && my_isspace(system_charset_info,*p);p++);
return cmd->handler_func(thd,p,buf_end);
}
@@ -691,7 +691,7 @@ HANDLE_DECL(handle_query)
int num_fields,i,ident_len;
char* ident,*query;
query=ident=args_start;
- while (!isspace(*query))
+ while (!my_isspace(system_charset_info,*query))
query++;
if (query == ident)
{
@@ -699,7 +699,7 @@ HANDLE_DECL(handle_query)
goto err;
}
ident_len=(int)(query-ident);
- while (query<args_end && isspace(*query))
+ while (query<args_end && my_isspace(system_charset_info,*query))
query++;
if (query == args_end)
{
@@ -976,7 +976,7 @@ static int authenticate(struct manager_thd* thd)
for (buf=thd->cmd_buf,p=thd->user,p_end=p+MAX_USER_NAME;
buf<buf_end && (c=*buf) && p<p_end; buf++,p++)
{
- if (isspace(c))
+ if (my_isspace(system_charset_info,c))
{
*p=0;
break;
@@ -989,7 +989,7 @@ static int authenticate(struct manager_thd* thd)
if (!(u=(struct manager_user*)hash_search(&user_hash,thd->user,
(uint)(p-thd->user))))
return 1;
- for (;isspace(*buf) && buf<buf_end;buf++) /* empty */;
+ for (;my_isspace(system_charset_info,*buf) && buf<buf_end;buf++) /* empty */;
my_MD5Init(&context);
my_MD5Update(&context,(uchar*) buf,(uint)(buf_end-buf));
@@ -1596,9 +1596,9 @@ static void manager_exec_free(void* e)
static int hex_val(char c)
{
- if (isdigit(c))
+ if (my_isdigit(system_charset_info,c))
return c-'0';
- c=tolower(c);
+ c=my_tolower(system_charset_info,c);
return c-'a'+10;
}