Aric Stewart : shlwapi: Implement StrChrNW.

Alexandre Julliard julliard at winehq.org
Thu Sep 24 10:55:20 CDT 2009


Module: wine
Branch: master
Commit: 0443f2c7d13076e9e3da17207a8030bd376add62
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0443f2c7d13076e9e3da17207a8030bd376add62

Author: Aric Stewart <aric at codeweavers.com>
Date:   Thu Sep 24 07:31:17 2009 -0500

shlwapi: Implement StrChrNW.

---

 dlls/shlwapi/shlwapi.spec   |    1 +
 dlls/shlwapi/string.c       |   19 +++++++++++++++++++
 dlls/shlwapi/tests/string.c |   24 ++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec
index 4acda49..3427722 100644
--- a/dlls/shlwapi/shlwapi.spec
+++ b/dlls/shlwapi/shlwapi.spec
@@ -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)
diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c
index 755360d..cfb59ea 100644
--- a/dlls/shlwapi/string.c
+++ b/dlls/shlwapi/string.c
@@ -319,6 +319,25 @@ LPWSTR WINAPI StrChrIW(LPCWSTR lpszStr, WCHAR ch)
 }
 
 /*************************************************************************
+ * 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.@]
  *
  * Compare two strings, ignoring case.
diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c
index fa50626..eae8905 100644
--- a/dlls/shlwapi/tests/string.c
+++ b/dlls/shlwapi/tests/string.c
@@ -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();




More information about the wine-cvs mailing list