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>
(cherry picked from commit f0f93c791f)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Akihiro Sagawa 2019-09-02 19:50:24 +02:00 committed by Michael Stefaniuc
parent ed576ab2f9
commit ce8d7855f2
2 changed files with 10 additions and 18 deletions

View File

@ -2006,27 +2006,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)
{
const unsigned char *p, *q;
unsigned int pc, qc;
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++)
if (*p == *q)
break;
if (!*q) break;
qc = _mbsnextc(q);
if (pc == qc) break;
if (qc > 255 && q[1]) q++;
}
if (!*q) break;
if (pc > 255 && p[1]) p++;
}
return p - string;
}

View File

@ -530,13 +530,13 @@ static void test_mbsspn( void)
_setmbcp( 932);
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);
ok( ret==1, "_mbsspn returns %d should be 1\n", ret);
ret=_mbsspn( mbstr+8, mbset1);
ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
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);
}