combase: Implement WindowsTrimStringEnd.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2016-02-10 23:27:40 +01:00 committed by Alexandre Julliard
parent 211b8b5f61
commit 441c8dcc65
3 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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);
}