shlwapi: Implement StrChrNW.

This commit is contained in:
Aric Stewart 2009-09-24 07:31:17 -05:00 committed by Alexandre Julliard
parent 1775ab4a11
commit 0443f2c7d1
3 changed files with 44 additions and 0 deletions

View file

@ -757,6 +757,7 @@
@ stdcall StrChrA (str long)
@ stdcall StrChrIA (str long)
@ stdcall StrChrIW (wstr long)
@ stdcall StrChrNW(wstr long long)
@ stdcall StrChrW (wstr long)
@ stdcall StrCmpIW (wstr wstr)
@ stdcall StrCmpLogicalW(wstr wstr)

View file

@ -318,6 +318,25 @@ LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch)
return (LPWSTR)lpszStr;
}
/*************************************************************************
* StrChrNW [SHLWAPI.@]
*/
LPWSTR WINAPI StrChrNW(LPCWSTR lpszStr, WCHAR ch, UINT cchMax)
{
TRACE("(%s(%i),%i)\n", debugstr_wn(lpszStr,cchMax), cchMax, ch);
if (lpszStr)
{
while (*lpszStr && cchMax-- > 0)
{
if (*lpszStr == ch)
return (LPWSTR)lpszStr;
lpszStr++;
}
}
return NULL;
}
/*************************************************************************
* StrCmpIW [SHLWAPI.@]
*

View file

@ -58,6 +58,7 @@ static HRESULT (WINAPI *pStrRetToBufA)(STRRET*,LPCITEMIDLIST,LPSTR,UINT);
static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
static INT (WINAPIV *pwnsprintfA)(LPSTR,INT,LPCSTR, ...);
static INT (WINAPIV *pwnsprintfW)(LPWSTR,INT,LPCWSTR, ...);
static LPWSTR (WINAPI *pStrChrNW)(LPWSTR,WCHAR,UINT);
static int strcmpW(const WCHAR *str1, const WCHAR *str2)
{
@ -373,6 +374,27 @@ static void test_StrCpyW(void)
}
}
static void test_StrChrNW(void)
{
static WCHAR string[] = {'T','e','s','t','i','n','g',' ','S','t','r','i','n','g',0};
LPWSTR p;
if (!pStrChrNW)
{
win_skip("StrChrNW not available\n");
return;
}
p = pStrChrNW(string,'t',10);
ok(*p=='t',"Found wrong 't'\n");
ok(*(p+1)=='i',"next should be 'i'\n");
p = pStrChrNW(string,'S',10);
ok(*p=='S',"Found wrong 'S'\n");
p = pStrChrNW(string,'r',10);
ok(p==NULL,"Should not have found 'r'\n");
}
static void test_StrToIntA(void)
{
@ -911,6 +933,7 @@ START_TEST(string)
pStrCatBuffW = (void *)GetProcAddress(hShlwapi, "StrCatBuffW");
pStrCpyNXA = (void *)GetProcAddress(hShlwapi, (LPSTR)399);
pStrCpyNXW = (void *)GetProcAddress(hShlwapi, (LPSTR)400);
pStrChrNW = (void *)GetProcAddress(hShlwapi, "StrChrNW");
pStrFormatByteSize64A = (void *)GetProcAddress(hShlwapi, "StrFormatByteSize64A");
pStrFormatKBSizeA = (void *)GetProcAddress(hShlwapi, "StrFormatKBSizeA");
pStrFormatKBSizeW = (void *)GetProcAddress(hShlwapi, "StrFormatKBSizeW");
@ -929,6 +952,7 @@ START_TEST(string)
test_StrRChrA();
test_StrRChrW();
test_StrCpyW();
test_StrChrNW();
test_StrToIntA();
test_StrToIntW();
test_StrToIntExA();