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

67 lines
2.1 KiB
Diff
Raw Normal View History

From 93a197217df87f95ed2111358fbb6efb89ba0c04 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.
---
dlls/combase/combase.spec | 2 +-
dlls/combase/string.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
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