msvcrt: Add function _mbsspnp.

This commit is contained in:
Duane Clark 2006-12-22 15:24:30 -08:00 committed by Alexandre Julliard
parent ce5fb9bb29
commit 67386352c8
3 changed files with 54 additions and 1 deletions

View File

@ -1195,6 +1195,40 @@ MSVCRT_size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* se
return p - string;
}
/*********************************************************************
* _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.@)
*/

View File

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

View File

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