Commit f845e66b authored by unknown's avatar unknown

More use of new CHARSET_INFO functions and two bug fixes


sql/sql_string.cc:
  More use of new CHARSET_INFO functions
strings/ctype-mb.c:
  Bug fix
strings/ctype-utf8.c:
  Bug fix
parent 953e2720
......@@ -363,46 +363,13 @@ bool String::append(IO_CACHE* file, uint32 arg_length)
uint32 String::numchars()
{
#ifdef USE_MB
register uint32 n=0,mblen;
register const char *mbstr=Ptr;
register const char *end=mbstr+str_length;
if (use_mb(str_charset))
{
while (mbstr < end) {
if ((mblen=my_ismbchar(str_charset, mbstr,end))) mbstr+=mblen;
else ++mbstr;
++n;
}
return n;
}
else
#endif
return str_length;
return str_charset->numchars(str_charset, Ptr, Ptr+str_length);
}
int String::charpos(int i,uint32 offset)
{
#ifdef USE_MB
register uint32 mblen;
register const char *mbstr=Ptr+offset;
register const char *end=Ptr+str_length;
if (use_mb(str_charset))
{
if (i<=0) return i;
while (i && mbstr < end) {
if ((mblen=my_ismbchar(str_charset, mbstr,end))) mbstr+=mblen;
else ++mbstr;
--i;
}
if ( INT_MAX32-i <= (int) (mbstr-Ptr-offset))
return INT_MAX32;
else
return (int) ((mbstr-Ptr-offset)+i);
}
else
#endif
return i;
if (i<0) return i;
return str_charset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
}
int String::strstr(const String &s,uint32 offset)
......
......@@ -289,12 +289,10 @@ uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)),
}
uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)),
const char *b __attribute__((unused)),
const char *e __attribute__((unused)),
uint pos)
const char *b, const char *e, uint pos)
{
uint res=0, mblen;
const char *b0;
uint mblen;
const char *b0=b;
while (pos && b<e)
{
......
......@@ -3079,7 +3079,7 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *e __attribute__((unused)),
uint pos)
{
return pos/2;
return pos*2;
}
CHARSET_INFO my_charset_ucs2 =
......
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