mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
sql_string.cc:
Use of new CHARSET_INFO function sql/sql_string.cc: Use of new CHARSET_INFO function
This commit is contained in:
parent
a6438797a9
commit
2bce5e5709
1 changed files with 4 additions and 60 deletions
|
@ -573,66 +573,10 @@ void String::qs_append(const char &c)
|
|||
|
||||
int sortcmp(const String *x,const String *y)
|
||||
{
|
||||
const char *s= x->ptr();
|
||||
const char *t= y->ptr();
|
||||
uint32 x_len=x->length(),y_len=y->length(),len=min(x_len,y_len);
|
||||
|
||||
if (use_strnxfrm(x->str_charset))
|
||||
{
|
||||
#ifndef CMP_ENDSPACE
|
||||
while (x_len && my_isspace(x->str_charset,s[x_len-1]))
|
||||
x_len--;
|
||||
while (y_len && my_isspace(x->str_charset,t[y_len-1]))
|
||||
y_len--;
|
||||
#endif
|
||||
return my_strnncoll(x->str_charset,
|
||||
(unsigned char *)s,x_len,(unsigned char *)t,y_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
x_len-=len; // For easy end space test
|
||||
y_len-=len;
|
||||
if (x->str_charset->sort_order)
|
||||
{
|
||||
while (len--)
|
||||
{
|
||||
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]]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len--)
|
||||
{
|
||||
if (*s++ != *t++)
|
||||
return ((int) s[-1] - (int) t[-1]);
|
||||
}
|
||||
}
|
||||
#ifndef CMP_ENDSPACE
|
||||
/* Don't compare end space in strings */
|
||||
{
|
||||
if (y_len)
|
||||
{
|
||||
const char *end=t+y_len;
|
||||
for (; t != end ; t++)
|
||||
if (!my_isspace(x->str_charset,*t))
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *end=s+x_len;
|
||||
for (; s != end ; s++)
|
||||
if (!my_isspace(x->str_charset,*s))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return (int) (x_len-y_len);
|
||||
#endif /* CMP_ENDSPACE */
|
||||
}
|
||||
CHARSET_INFO *cs= x->str_charset;
|
||||
return cs->strnncollsp(cs,
|
||||
(unsigned char *) x->ptr(),x->length(),
|
||||
(unsigned char *) y->ptr(),y->length());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue