wine-staging/patches/combase-WindowsString/0004-combase-Implement-WindowsTrimStringEnd.patch

72 lines
3.0 KiB
Diff
Raw Normal View History

From ea49da0c37d81de96f1789306cca9322cf93e3e5 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 17 Jan 2016 05:56:50 +0100
Subject: combase: Implement WindowsTrimStringEnd.
---
.../api-ms-win-core-winrt-string-l1-1-0.spec | 2 +-
dlls/combase/combase.spec | 2 +-
dlls/combase/string.c | 27 ++++++++++++++++++++++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
index fe63810..8b60a91 100644
--- a/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
+++ b/dlls/api-ms-win-core-winrt-string-l1-1-0/api-ms-win-core-winrt-string-l1-1-0.spec
@@ -23,5 +23,5 @@
@ stdcall WindowsStringHasEmbeddedNull(ptr ptr) combase.WindowsStringHasEmbeddedNull
@ stdcall WindowsSubstring(ptr long ptr) combase.WindowsSubstring
@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr) combase.WindowsSubstringWithSpecifiedLength
-@ stub WindowsTrimStringEnd
+@ stdcall WindowsTrimStringEnd(ptr ptr ptr) combase.WindowsTrimStringEnd
@ stdcall WindowsTrimStringStart(ptr ptr ptr) combase.WindowsTrimStringStart
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
index 69f47d0..4bda470 100644
--- a/dlls/combase/combase.spec
+++ b/dlls/combase/combase.spec
@@ -304,5 +304,5 @@
@ stdcall WindowsStringHasEmbeddedNull(ptr ptr)
@ stdcall WindowsSubstring(ptr long ptr)
@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr)
-@ stub WindowsTrimStringEnd
+@ stdcall WindowsTrimStringEnd(ptr ptr ptr)
@ stdcall WindowsTrimStringStart(ptr ptr ptr)
diff --git a/dlls/combase/string.c b/dlls/combase/string.c
index 868411c..56d84ad 100644
--- a/dlls/combase/string.c
+++ b/dlls/combase/string.c
@@ -433,3 +433,30 @@ HRESULT WINAPI WindowsTrimStringStart(HSTRING str1, HSTRING str2, HSTRING *out)
return start ? WindowsCreateString(&priv1->buffer[start], priv1->length - start, out) :
WindowsDuplicateString(str1, out);
}
+
+/***********************************************************************
+ * WindowsTrimStringEnd (combase.@)
+ */
+HRESULT WINAPI WindowsTrimStringEnd(HSTRING str1, HSTRING str2, HSTRING *out)
+{
+ struct hstring_private *priv1 = impl_from_HSTRING(str1);
+ struct hstring_private *priv2 = impl_from_HSTRING(str2);
+ UINT32 len;
+
+ TRACE("(%p, %p, %p)\n", str1, str2, out);
+
+ if (!out || !str2 || !priv2->length)
+ return E_INVALIDARG;
+ if (!str1)
+ {
+ *out = NULL;
+ return S_OK;
+ }
+ for (len = priv1->length; len > 0; len--)
+ {
+ if (!memchrW(priv2->buffer, priv1->buffer[len - 1], priv2->length))
+ break;
+ }
+ return (len < priv1->length) ? WindowsCreateString(priv1->buffer, len, out) :
+ WindowsDuplicateString(str1, out);
+}
--
2.6.4