More use of new CHARSET_INFO functions and two bug fixes
This commit is contained in:
parent
24be8669a0
commit
4f62ac93f0
@ -363,46 +363,13 @@ bool String::append(IO_CACHE* file, uint32 arg_length)
|
|||||||
|
|
||||||
uint32 String::numchars()
|
uint32 String::numchars()
|
||||||
{
|
{
|
||||||
#ifdef USE_MB
|
return str_charset->numchars(str_charset, Ptr, Ptr+str_length);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int String::charpos(int i,uint32 offset)
|
int String::charpos(int i,uint32 offset)
|
||||||
{
|
{
|
||||||
#ifdef USE_MB
|
if (i<0) return i;
|
||||||
register uint32 mblen;
|
return str_charset->charpos(str_charset,Ptr+offset,Ptr+str_length,i);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int String::strstr(const String &s,uint32 offset)
|
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)),
|
uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)),
|
||||||
const char *b __attribute__((unused)),
|
const char *b, const char *e, uint pos)
|
||||||
const char *e __attribute__((unused)),
|
|
||||||
uint pos)
|
|
||||||
{
|
{
|
||||||
uint res=0, mblen;
|
uint mblen;
|
||||||
const char *b0;
|
const char *b0=b;
|
||||||
|
|
||||||
while (pos && b<e)
|
while (pos && b<e)
|
||||||
{
|
{
|
||||||
|
@ -3079,7 +3079,7 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
|
|||||||
const char *e __attribute__((unused)),
|
const char *e __attribute__((unused)),
|
||||||
uint pos)
|
uint pos)
|
||||||
{
|
{
|
||||||
return pos/2;
|
return pos*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHARSET_INFO my_charset_ucs2 =
|
CHARSET_INFO my_charset_ucs2 =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user