StrCatChainW implementation
Huw Campbell
huw.campbell at gmail.com
Thu Mar 6 05:17:49 CST 2014
Hello
Please see my implementation of this function, which has not been seen in
wine previously. Explorer.exe calls it, so it's kind of important.
I ran a lot of tests on the edge cases: including: same ends, 0 ends, end
beyond the length...
Huw
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20140306/382785e9/attachment.html>
-------------- next part --------------
diff --git a/dlls/shlwapi/shlwapi.spec b/dlls/shlwapi/shlwapi.spec
index b7aac08..b47380f 100644
--- a/dlls/shlwapi/shlwapi.spec
+++ b/dlls/shlwapi/shlwapi.spec
@@ -760,6 +760,7 @@
@ stdcall StrCatBuffA (str str long)
@ stdcall StrCatBuffW (wstr wstr long)
@ stdcall StrCatW (ptr wstr)
+@ stdcall StrCatChainW (ptr long long wstr)
@ stdcall StrChrA (str long)
@ stdcall StrChrIA (str long)
@ stdcall StrChrIW (wstr long)
diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c
index 1a4ad14..fd4b145 100644
--- a/dlls/shlwapi/string.c
+++ b/dlls/shlwapi/string.c
@@ -459,6 +459,50 @@ LPWSTR WINAPI StrCatW(LPWSTR lpszStr, LPCWSTR lpszSrc)
}
/*************************************************************************
+ * StrCatChainW [SHLWAPI.@]
+ *
+ * Concatenates two Unicode strings.
+ *
+ * PARAMS
+ * pszDst [O] Initial string
+ * cchDst Length of destination buffer
+ * ichAt Offset from the destination buffer to begin concatenation
+ * pszSrc [I] String to concatenate
+ *
+ * RETURNS
+ * The offset from the beginning of pszDst to the terminating NULL.
+ */
+
+DWORD WINAPI StrCatChainW(PWSTR pszDst, DWORD cchDst, DWORD ichAt, PCWSTR pszSrc)
+{
+ LPWSTR d = pszDst;
+ LPCWSTR s = pszSrc;
+ DWORD mark;
+
+ TRACE("(%s,%i,%i,%s)\n", debugstr_w(pszDst), cchDst, ichAt, debugstr_w(pszSrc));
+
+ if (ichAt == -1)
+ mark = strlenW(pszDst);
+ else
+ mark = ichAt;
+ if (mark > cchDst || cchDst == 0)
+ return mark;
+ if (mark == cchDst)
+ mark--;
+ d = d + mark;
+ if (pszSrc)
+ {
+ while ((mark < cchDst-1) && *s)
+ {
+ mark++;
+ *d++ = *s++;
+ }
+ }
+ *d = 0;
+ return mark;
+}
+
+/*************************************************************************
* StrCpyW [SHLWAPI.@]
*
* Copy a string to another string.
More information about the wine-patches
mailing list