Commit 67386352 authored by Duane Clark's avatar Duane Clark Committed by Alexandre Julliard

msvcrt: Add function _mbsspnp.

parent ce5fb9bb
......@@ -1196,6 +1196,40 @@ MSVCRT_size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* se
}
/*********************************************************************
* _mbsspnp (MSVCRT.@)
*/
const unsigned char* CDECL _mbsspnp(const unsigned char* string, const unsigned char* set)
{
const unsigned char *p, *q;
for (p = string; *p; p++)
{
if (MSVCRT_isleadbyte(*p))
{
for (q = set; *q; q++)
{
if (!q[1])
break;
if ((*p == *q) && (p[1] == q[1]))
break;
q++;
}
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 p;
}
/*********************************************************************
* _mbscspn(MSVCRT.@)
*/
MSVCRT_size_t CDECL _mbscspn(const unsigned char* str, const unsigned char* cmp)
......
......@@ -386,7 +386,7 @@
@ cdecl _mbsrev(str)
@ cdecl _mbsset(str long)
@ cdecl _mbsspn(str str)
@ stub _mbsspnp #(str str)
@ cdecl _mbsspnp(str str)
@ cdecl _mbsstr(str str)
@ cdecl _mbstok(str str)
@ cdecl _mbstrlen(str)
......
......@@ -99,6 +99,24 @@ static void test_mbsspn( void)
ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
}
static void test_mbsspnp( void)
{
unsigned char str1[]="cabernet";
unsigned char str2[]="shiraz";
unsigned char set[]="abc";
unsigned char empty[]="";
unsigned char full[]="abcenrt";
unsigned char* ret;
ret=_mbsspnp( str1, set);
ok( ret[0]=='e', "_mbsspnp returns %c should be e\n", ret[0]);
ret=_mbsspnp( str2, set);
ok( ret[0]=='s', "_mbsspnp returns %c should be s\n", ret[0]);
ret=_mbsspnp( str1, empty);
ok( ret[0]=='c', "_mbsspnp returns %c should be c\n", ret[0]);
ret=_mbsspnp( str1, full);
ok( ret==NULL, "_mbsspnp returns %p should be NULL\n", ret);
}
static void test_strdup(void)
{
char *str;
......@@ -138,6 +156,7 @@ START_TEST(string)
test_ismbblead();
/* test _mbsspn */
test_mbsspn();
test_mbsspnp();
/* test _strdup */
test_strdup();
}
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