msvcrt: Fix _mbsspn implementation.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2019-09-02 19:50:24 +02:00 committed by Alexandre Julliard
parent c62c51c04a
commit f0f93c791f
2 changed files with 10 additions and 18 deletions

View File

@ -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) qc = _mbsnextc(q);
{ if (pc == qc) break;
if (!q[1]) if (qc > 255 && q[1]) q++;
break;
if ((*p == *q) && (p[1] == q[1]))
break;
}
if (!q[0] || !q[1]) break;
}
else
{
for (q = set; *q; q++)
if (*p == *q)
break;
if (!*q) break;
} }
if (!*q) break;
if (pc > 255 && p[1]) p++;
} }
return p - string; return p - string;
} }

View File

@ -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);
} }