wine-staging/patches/combase-WindowsString/0003-combase-Implement-WindowsTrimStringStart.patch

78 lines
2.9 KiB
Diff

From 6b4166e822951ced51c2ac5637f37427a3a640a5 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 17 Jan 2016 05:55:43 +0100
Subject: combase: Implement WindowsTrimStringStart.
---
.../api-ms-win-core-winrt-string-l1-1-0.spec | 2 +-
dlls/combase/combase.spec | 2 +-
dlls/combase/string.c | 28 ++++++++++++++++++++++
3 files changed, 30 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 1b661aa..fe63810 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
@@ -24,4 +24,4 @@
@ stdcall WindowsSubstring(ptr long ptr) combase.WindowsSubstring
@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr) combase.WindowsSubstringWithSpecifiedLength
@ stub WindowsTrimStringEnd
-@ stub WindowsTrimStringStart
+@ stdcall WindowsTrimStringStart(ptr ptr ptr) combase.WindowsTrimStringStart
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
index 430ca95..69f47d0 100644
--- a/dlls/combase/combase.spec
+++ b/dlls/combase/combase.spec
@@ -305,4 +305,4 @@
@ stdcall WindowsSubstring(ptr long ptr)
@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr)
@ stub WindowsTrimStringEnd
-@ stub WindowsTrimStringStart
+@ stdcall WindowsTrimStringStart(ptr ptr ptr)
diff --git a/dlls/combase/string.c b/dlls/combase/string.c
index bd18a73..868411c 100644
--- a/dlls/combase/string.c
+++ b/dlls/combase/string.c
@@ -21,6 +21,7 @@
#include "windows.h"
#include "winerror.h"
#include "hstring.h"
+#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(winstring);
@@ -405,3 +406,30 @@ HRESULT WINAPI WindowsCompareStringOrdinal(HSTRING str1, HSTRING str2, INT32 *re
*res = CompareStringOrdinal(buf1, len1, buf2, len2, FALSE) - CSTR_EQUAL;
return S_OK;
}
+
+/***********************************************************************
+ * WindowsTrimStringStart (combase.@)
+ */
+HRESULT WINAPI WindowsTrimStringStart(HSTRING str1, HSTRING str2, HSTRING *out)
+{
+ struct hstring_private *priv1 = impl_from_HSTRING(str1);
+ struct hstring_private *priv2 = impl_from_HSTRING(str2);
+ UINT32 start = 0;
+
+ TRACE("(%p, %p, %p)\n", str1, str2, out);
+
+ if (!out || !str2 || !priv2->length)
+ return E_INVALIDARG;
+ if (!str1)
+ {
+ *out = NULL;
+ return S_OK;
+ }
+ for (start = 0; start < priv1->length; start++)
+ {
+ if (!memchrW(priv2->buffer, priv1->buffer[start], priv2->length))
+ break;
+ }
+ return start ? WindowsCreateString(&priv1->buffer[start], priv1->length - start, out) :
+ WindowsDuplicateString(str1, out);
+}
--
2.6.4