msvcrt: Reimplement _mbsspnp using _mbsspn.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47693
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 ab525d3f6f)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Akihiro Sagawa 2019-09-02 19:50:29 +02:00 committed by Michael Stefaniuc
parent ce8d7855f2
commit 8ce3f98888
2 changed files with 17 additions and 34 deletions

View File

@ -2006,19 +2006,26 @@ 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++)
{
pc = _mbsnextc(p);
for (q = set; *q; q++)
{
qc = _mbsnextc(q);
if (pc == qc) break;
if (qc > 255 && q[1]) q++;
if (_ismbblead(*q))
{
if (p[0] == q[0] && p[1] == q[1])
{
p++;
break;
}
q++;
}
else
{
if (p[0] == q[0]) break;
}
}
if (!*q) break;
if (pc > 255 && p[1]) p++;
}
return p - string;
}
@ -2028,32 +2035,8 @@ MSVCRT_size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* se
*/
unsigned char* CDECL _mbsspnp(const unsigned char* string, const unsigned char* set)
{
const unsigned char *p, *q;
for (p = string; *p; p++)
{
if (_ismbblead(*p))
{
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;
}
}
if (*p == '\0')
return NULL;
return (unsigned char *)p;
string += _mbsspn( string, set );
return *string ? (unsigned char*)string : NULL;
}
/*********************************************************************

View File

@ -565,13 +565,13 @@ static void test_mbsspnp( void)
_setmbcp( 932);
ret=_mbsspnp( mbstr, mbset1);
todo_wine ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
ret=_mbsspnp( mbstr, mbset2);
ok( ret==mbstr+1, "_mbsspnp returns %p should be %p\n", ret, mbstr+1);
ret=_mbsspnp( mbstr+8, mbset1);
ok( ret==mbstr+8, "_mbsspnp returns %p should be %p\n", ret, mbstr+8);
ret=_mbsspnp( mbstr+8, mbset2);
todo_wine ok( ret==mbstr+10, "_mbsspnp returns %p should be %p\n", ret, mbstr+10);
ok( ret==mbstr+10, "_mbsspnp returns %p should be %p\n", ret, mbstr+10);
_setmbcp( cp);
}