From 67386352c8794df0c56b3ea55409e12f13a3d7d7 Mon Sep 17 00:00:00 2001 From: Duane Clark Date: Fri, 22 Dec 2006 15:24:30 -0800 Subject: [PATCH] msvcrt: Add function _mbsspnp. --- dlls/msvcrt/mbcs.c | 34 ++++++++++++++++++++++++++++++++++ dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrt/tests/string.c | 19 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 06c07e49f27..91549eb05e5 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -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.@) */ diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 771204583cb..165ad428d60 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -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) diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index cd4ca028d55..8ff8bbd9751 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -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(); }