use String->charset instead of default_charset_info

parent b37ce8e7
......@@ -972,13 +972,13 @@ static bool add_line(String &buffer,char *line,char *in_string)
for (pos=out=line ; (inchar= (uchar) *pos) ; pos++)
{
if (my_isspace(default_charset_info,inchar) && out == line &&
if (my_isspace(system_charset_info,inchar) && out == line &&
buffer.is_empty())
continue;
#ifdef USE_MB
int l;
if (use_mb(default_charset_info) &&
(l = my_ismbchar(default_charset_info, pos, strend))) {
if (use_mb(system_charset_info) &&
(l = my_ismbchar(system_charset_info, pos, strend))) {
while (l--)
*out++ = *pos++;
pos--;
......@@ -1813,8 +1813,8 @@ safe_put_field(const char *pos,ulong length)
{
#ifdef USE_MB
int l;
if (use_mb(default_charset_info) &&
(l = my_ismbchar(default_charset_info, pos, end))) {
if (use_mb(system_charset_info) &&
(l = my_ismbchar(system_charset_info, pos, end))) {
while (l--)
tee_putc(*pos++, PAGER);
pos--;
......@@ -2361,7 +2361,7 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql));
tee_fprintf(stdout, "Connection:\t\t%s\n", mysql_get_host_info(&mysql));
tee_fprintf(stdout, "Client characterset:\t%s\n",
default_charset_info->name);
system_charset_info->name);
tee_fprintf(stdout, "Server characterset:\t%s\n", mysql.charset->name);
if (strstr(mysql_get_host_info(&mysql),"TCP/IP") || ! mysql.unix_socket)
tee_fprintf(stdout, "TCP port:\t\t%d\n", mysql.port);
......
......@@ -170,33 +170,6 @@ extern my_bool ismbhead_ujis(uint);
extern int mbcharlen_ujis(uint);
/* Don't include std ctype.h when this is included */
#define _CTYPE_H
#define _CTYPE_H_
#define _CTYPE_INCLUDED
#define __CTYPE_INCLUDED
#define _CTYPE_USING /* Don't put names in global namespace. */
/* Fix things, if ctype.h would have been included before */
#undef toupper
#undef _toupper
#undef _tolower
#undef toupper
#undef tolower
#undef isalpha
#undef isupper
#undef islower
#undef isdigit
#undef isxdigit
#undef isalnum
#undef isspace
#undef ispunct
#undef isprint
#undef isgraph
#undef iscntrl
#undef isascii
#undef toascii
#define _U 01 /* Upper case */
#define _L 02 /* Lower case */
#define _N 04 /* Numeral (digit) */
......@@ -207,14 +180,10 @@ extern int mbcharlen_ujis(uint);
#define _X 0200 /* heXadecimal digit */
#define isascii(c) (!((c) & ~0177))
#define toascii(c) ((c) & 0177)
#define tocntrl(c) ((c) & 31)
#define toprint(c) ((c) | 64)
#ifdef ctype
#undef ctype
#endif /* ctype */
#define my_isascii(c) (!((c) & ~0177))
#define my_toascii(c) ((c) & 0177)
#define my_tocntrl(c) ((c) & 31)
#define my_toprint(c) ((c) | 64)
#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
......
......@@ -329,6 +329,14 @@ static CHARSET_INFO *add_charset(uint cs_number, const char *cs_name, myf flags)
memcpy((char*) cs->to_upper, (char*) tmp_to_upper, sizeof(tmp_to_upper));
memcpy((char*) cs->sort_order, (char*) tmp_sort_order,
sizeof(tmp_sort_order));
cs->caseup_str = my_caseup_str_8bit;
cs->casedn_str = my_casedn_str_8bit;
cs->caseup = my_caseup_8bit;
cs->casedn = my_casedn_8bit;
cs->strcasecmp = my_strcasecmp_8bit;
cs->strncasecmp = my_strncasecmp_8bit;
insert_dynamic(&cs_info_table, (gptr) &cs);
return cs;
}
......@@ -396,6 +404,7 @@ my_bool set_default_charset(uint cs, myf flags)
DBUG_RETURN(TRUE); /* error */
}
default_charset_info = new_charset;
system_charset_info = new_charset;
DBUG_RETURN(FALSE);
}
......@@ -428,6 +437,7 @@ my_bool set_default_charset_by_name(const char *cs_name, myf flags)
}
default_charset_info = new_charset;
system_charset_info = new_charset;
DBUG_RETURN(FALSE);
}
......
......@@ -830,7 +830,7 @@ longlong Item_func_locate::val_int()
{
start=(uint) args[2]->val_int()-1;
#ifdef USE_MB
if (use_mb(default_charset_info))
if (use_mb(a->str_charset))
{
start0=start;
if (!binary_str)
......@@ -843,7 +843,7 @@ longlong Item_func_locate::val_int()
if (!b->length()) // Found empty string at start
return (longlong) (start+1);
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary_str)
if (use_mb(a->str_charset) && !binary_str)
{
const char *ptr=a->ptr()+start;
const char *search=b->ptr();
......@@ -862,7 +862,7 @@ longlong Item_func_locate::val_int()
return (longlong) start0+1;
}
skipp:
if ((l=my_ismbchar(default_charset_info,ptr,strend))) ptr+=l;
if ((l=my_ismbchar(a->str_charset,ptr,strend))) ptr+=l;
else ++ptr;
++start0;
}
......@@ -913,11 +913,10 @@ longlong Item_func_ord::val_int()
null_value=0;
if (!res->length()) return 0;
#ifdef USE_MB
if (use_mb(default_charset_info) && !args[0]->binary)
if (use_mb(res->str_charset) && !args[0]->binary)
{
register const char *str=res->ptr();
register uint32 n=0, l=my_ismbchar(default_charset_info,
str,str+res->length());
register uint32 n=0, l=my_ismbchar(res->str_charset,str,str+res->length());
if (!l) return (longlong)((uchar) *str);
while (l--)
n=(n<<8)|(uint32)((uchar) *str++);
......
......@@ -510,7 +510,7 @@ String *Item_func_reverse::val_str(String *str)
ptr = (char *) res->ptr();
end=ptr+res->length();
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
String tmpstr;
tmpstr.copy(*res);
......@@ -518,7 +518,7 @@ String *Item_func_reverse::val_str(String *str)
register uint32 l;
while (ptr < end)
{
if ((l=my_ismbchar(default_charset_info, ptr,end)))
if ((l=my_ismbchar(res->str_charset, ptr,end)))
tmp-=l, memcpy(tmp,ptr,l), ptr+=l;
else
*--tmp=*ptr++;
......@@ -561,8 +561,7 @@ String *Item_func_replace::val_str(String *str)
#ifdef USE_MB
const char *ptr,*end,*strend,*search,*search_end;
register uint32 l;
bool binary_str = (args[0]->binary || args[1]->binary ||
!use_mb(default_charset_info));
bool binary_str;
#endif
null_value=0;
......@@ -573,6 +572,10 @@ String *Item_func_replace::val_str(String *str)
if (args[1]->null_value)
goto null;
#ifdef USE_MB
binary_str = (args[0]->binary || args[1]->binary || !use_mb(res->str_charset));
#endif
if (res2->length() == 0)
return res;
#ifndef USE_MB
......@@ -618,7 +621,7 @@ String *Item_func_replace::val_str(String *str)
goto redo;
}
skipp:
if ((l=my_ismbchar(default_charset_info, ptr,strend))) ptr+=l;
if ((l=my_ismbchar(res->str_charset, ptr,strend))) ptr+=l;
else ++ptr;
}
}
......@@ -676,7 +679,7 @@ String *Item_func_insert::val_str(String *str)
args[3]->null_value)
goto null; /* purecov: inspected */
#ifdef USE_MB
if (use_mb(default_charset_info) && !args[0]->binary)
if (use_mb(res->str_charset) && !args[0]->binary)
{
start=res->charpos(start);
length=res->charpos(length,start);
......@@ -748,7 +751,7 @@ String *Item_func_left::val_str(String *str)
if (length <= 0)
return &empty_string;
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
length = res->charpos(length);
#endif
if (res->length() > (ulong) length)
......@@ -796,7 +799,7 @@ String *Item_func_right::val_str(String *str)
if (res->length() <= (uint) length)
return res; /* purecov: inspected */
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
uint start=res->numchars()-(uint) length;
if (start<=0) return res;
......@@ -829,7 +832,7 @@ String *Item_func_substr::val_str(String *str)
(arg_count == 3 && args[2]->null_value))))
return 0; /* purecov: inspected */
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
start=res->charpos(start);
length=res->charpos(length,start);
......@@ -889,7 +892,7 @@ String *Item_func_substr_index::val_str(String *str)
return &empty_string; // Wrong parameters
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
const char *ptr=res->ptr();
const char *strend = ptr+res->length();
......@@ -914,7 +917,7 @@ String *Item_func_substr_index::val_str(String *str)
continue;
}
skipp:
if ((l=my_ismbchar(default_charset_info, ptr,strend))) ptr+=l;
if ((l=my_ismbchar(res->str_charset, ptr,strend))) ptr+=l;
else ++ptr;
} /* either not found or got total number when count<0 */
if (pass == 0) /* count<0 */
......@@ -1043,11 +1046,11 @@ String *Item_func_rtrim::val_str(String *str)
{
char chr=(*remove_str)[0];
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
while (ptr < end)
{
if ((l=my_ismbchar(default_charset_info, ptr,end))) ptr+=l,p=ptr;
if ((l=my_ismbchar(res->str_charset, ptr,end))) ptr+=l,p=ptr;
else ++ptr;
}
ptr=p;
......@@ -1060,12 +1063,12 @@ String *Item_func_rtrim::val_str(String *str)
{
const char *r_ptr=remove_str->ptr();
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
loop:
while (ptr + remove_length < end)
{
if ((l=my_ismbchar(default_charset_info, ptr,end))) ptr+=l;
if ((l=my_ismbchar(res->str_charset, ptr,end))) ptr+=l;
else ++ptr;
}
if (ptr + remove_length == end && !memcmp(ptr,r_ptr,remove_length))
......@@ -1111,14 +1114,14 @@ String *Item_func_trim::val_str(String *str)
while (ptr+remove_length <= end && !memcmp(ptr,r_ptr,remove_length))
ptr+=remove_length;
#ifdef USE_MB
if (use_mb(default_charset_info) && !binary)
if (use_mb(res->str_charset) && !binary)
{
char *p=ptr;
register uint32 l;
loop:
while (ptr + remove_length < end)
{
if ((l=my_ismbchar(default_charset_info, ptr,end))) ptr+=l;
if ((l=my_ismbchar(res->str_charset, ptr,end))) ptr+=l;
else ++ptr;
}
if (ptr + remove_length == end && !memcmp(ptr,r_ptr,remove_length))
......
......@@ -3043,8 +3043,8 @@ static void remove_escape(char *name)
#ifdef USE_MB
int l;
/* if ((l = ismbchar(name, name+MBMAXLEN))) { Wei He: I think it's wrong */
if (use_mb(default_charset_info) &&
(l = my_ismbchar(default_charset_info, name, strend)))
if (use_mb(system_charset_info) &&
(l = my_ismbchar(system_charset_info, name, strend)))
{
while (l--)
*to++ = *name++;
......
......@@ -617,7 +617,7 @@ int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end,
{
int result= -1; // Not found, using wildcards
#ifdef USE_MB
bool use_mb_flag=use_mb(default_charset_info);
bool use_mb_flag=use_mb(cs);
#endif
while (wildstr != wildend)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment