Commit f0f93c79 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

msvcrt: Fix _mbsspn implementation.

parent c62c51c0
...@@ -2028,27 +2028,19 @@ int CDECL _mbsupr_s(unsigned char* s, MSVCRT_size_t len) ...@@ -2028,27 +2028,19 @@ int CDECL _mbsupr_s(unsigned char* s, MSVCRT_size_t len)
MSVCRT_size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* set) MSVCRT_size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* set)
{ {
const unsigned char *p, *q; const unsigned char *p, *q;
unsigned int pc, qc;
for (p = string; *p; p++) for (p = string; *p; p++)
{ {
if (_ismbblead(*p)) pc = _mbsnextc(p);
{ for (q = set; *q; q++)
for (q = set; *q; q += 2)
{
if (!q[1])
break;
if ((*p == *q) && (p[1] == q[1]))
break;
}
if (!q[0] || !q[1]) break;
}
else
{ {
for (q = set; *q; q++) qc = _mbsnextc(q);
if (*p == *q) if (pc == qc) break;
break; if (qc > 255 && q[1]) q++;
if (!*q) break;
} }
if (!*q) break;
if (pc > 255 && p[1]) p++;
} }
return p - string; return p - string;
} }
......
...@@ -530,13 +530,13 @@ static void test_mbsspn( void) ...@@ -530,13 +530,13 @@ static void test_mbsspn( void)
_setmbcp( 932); _setmbcp( 932);
ret=_mbsspn( mbstr, mbset1); ret=_mbsspn( mbstr, mbset1);
todo_wine ok( ret==8, "_mbsspn returns %d should be 8\n", ret); ok( ret==8, "_mbsspn returns %d should be 8\n", ret);
ret=_mbsspn( mbstr, mbset2); ret=_mbsspn( mbstr, mbset2);
ok( ret==1, "_mbsspn returns %d should be 1\n", ret); ok( ret==1, "_mbsspn returns %d should be 1\n", ret);
ret=_mbsspn( mbstr+8, mbset1); ret=_mbsspn( mbstr+8, mbset1);
ok( ret==0, "_mbsspn returns %d should be 0\n", ret); ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
ret=_mbsspn( mbstr+8, mbset2); ret=_mbsspn( mbstr+8, mbset2);
todo_wine ok( ret==2, "_mbsspn returns %d should be 2\n", ret); ok( ret==2, "_mbsspn returns %d should be 2\n", ret);
_setmbcp( cp); _setmbcp( cp);
} }
......
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