From 8a60c9da79b9b03c8fa9e2b971b0f3e3c074014a Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 24 Oct 2015 17:54:52 +0200 Subject: combase: Implement WindowsSubstringWithSpecifiedLength. --- .../api-ms-win-core-winrt-string-l1-1-0.spec | 2 +- dlls/combase/combase.spec | 2 +- dlls/combase/string.c | 22 ++++++++++++++++++++++ 3 files changed, 24 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 825980d..cb354f9 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 @@ -22,6 +22,6 @@ @ stub WindowsReplaceString @ stdcall WindowsStringHasEmbeddedNull(ptr ptr) combase.WindowsStringHasEmbeddedNull @ stdcall WindowsSubstring(ptr long ptr) combase.WindowsSubstring -@ stub WindowsSubstringWithSpecifiedLength +@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr) combase.WindowsSubstringWithSpecifiedLength @ stub WindowsTrimStringEnd @ stub WindowsTrimStringStart diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index bf8607a..3b3fd9c 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -303,6 +303,6 @@ @ stub WindowsReplaceString @ stdcall WindowsStringHasEmbeddedNull(ptr ptr) @ stdcall WindowsSubstring(ptr long ptr) -@ stub WindowsSubstringWithSpecifiedLength +@ stdcall WindowsSubstringWithSpecifiedLength(ptr long long ptr) @ stub WindowsTrimStringEnd @ stub WindowsTrimStringStart diff --git a/dlls/combase/string.c b/dlls/combase/string.c index 4344d36..92666b4 100644 --- a/dlls/combase/string.c +++ b/dlls/combase/string.c @@ -308,6 +308,28 @@ HRESULT WINAPI WindowsSubstring(HSTRING str, UINT32 start, HSTRING *out) } /*********************************************************************** + * WindowsSubstringWithSpecifiedLength (combase.@) + */ +HRESULT WINAPI WindowsSubstringWithSpecifiedLength(HSTRING str, UINT32 start, UINT32 len, HSTRING *out) +{ + struct hstring_private *priv = impl_from_HSTRING(str); + + TRACE("(%p, %u, %u, %p)\n", str, start, len, out); + + if (out == NULL) + return E_INVALIDARG; + if (start + len < start || + start + len > WindowsGetStringLen(str)) + return E_BOUNDS; + if (len == 0) + { + *out = NULL; + return S_OK; + } + return WindowsCreateString(&priv->buffer[start], len, out); +} + +/*********************************************************************** * WindowsIsStringEmpty (combase.@) */ BOOL WINAPI WindowsIsStringEmpty(HSTRING str) -- 2.6.1