Nikolay Sivov : ole32: Remove explicit type check in CommonPrefixWith() for item moniker.
Alexandre Julliard
julliard at winehq.org
Mon Sep 20 16:26:20 CDT 2021
Module: wine
Branch: master
Commit: 828a0ae6ea5ba2429a6954cb5e4e4c4c37bca063
URL: https://source.winehq.org/git/wine.git/?a=commit;h=828a0ae6ea5ba2429a6954cb5e4e4c4c37bca063
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Sep 20 13:08:46 2021 +0300
ole32: Remove explicit type check in CommonPrefixWith() for item moniker.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ole32/itemmoniker.c | 28 ++++++++--------------------
dlls/ole32/tests/moniker.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c
index 786d183d598..c42cc75c224 100644
--- a/dlls/ole32/itemmoniker.c
+++ b/dlls/ole32/itemmoniker.c
@@ -753,31 +753,19 @@ static HRESULT WINAPI ItemMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
return CreateAntiMoniker(ppmk);
}
-/******************************************************************************
- * ItemMoniker_CommonPrefixWith
- ******************************************************************************/
-static HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
+static HRESULT WINAPI ItemMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other,
+ IMoniker **prefix)
{
- DWORD mkSys;
-
- TRACE("(%p,%p)\n", pmkOther, ppmkPrefix);
-
- IMoniker_IsSystemMoniker(pmkOther,&mkSys);
- /* If the other moniker is an item moniker that is equal to this moniker, this method sets *ppmkPrefix */
- /* to this moniker and returns MK_S_US */
-
- if((mkSys==MKSYS_ITEMMONIKER) && (IMoniker_IsEqual(iface,pmkOther)==S_OK) ){
-
- *ppmkPrefix=iface;
+ TRACE("%p, %p, %p\n", iface, other, prefix);
+ if (IMoniker_IsEqual(iface, other) == S_OK)
+ {
+ *prefix = iface;
IMoniker_AddRef(iface);
-
return MK_S_US;
}
- else
- /* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */
- /* the case where the other moniker is a generic composite. */
- return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
+
+ return MonikerCommonPrefixWith(iface, other, prefix);
}
/******************************************************************************
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c
index df4b5c7bc88..b584f370d70 100644
--- a/dlls/ole32/tests/moniker.c
+++ b/dlls/ole32/tests/moniker.c
@@ -2276,7 +2276,7 @@ static void test_item_moniker(void)
"Moniker_IsRunning",
NULL
};
- IMoniker *moniker, *moniker2, *reduced, *anti, *inverse;
+ IMoniker *moniker, *moniker2, *moniker3, *reduced, *anti, *inverse;
DWORD i, hash, eaten, cookie;
HRESULT hr;
IBindCtx *bindctx;
@@ -2611,6 +2611,34 @@ todo_wine
IMoniker_Release(anti);
IMoniker_Release(moniker);
+
+ /* CommonPrefixWith */
+ hr = CreateItemMoniker(L"!", L"Item", &moniker);
+ ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr);
+ hr = CreateItemMoniker(L"#", L"Item", &moniker2);
+ ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr);
+
+ hr = IMoniker_CommonPrefixWith(moniker, moniker2, &moniker3);
+ ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
+ ok(moniker3 == moniker, "Unexpected object.\n");
+ IMoniker_Release(moniker3);
+
+ IMoniker_Release(moniker2);
+
+ hr = CreateItemMoniker(L"!", L"Item2", &moniker2);
+ ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr);
+
+ moniker3 = (void *)0xdeadbeef;
+ hr = IMoniker_CommonPrefixWith(moniker, moniker2, &moniker3);
+todo_wine
+{
+ ok(hr == MK_E_NOPREFIX, "Unexpected hr %#x.\n", hr);
+ ok(!moniker3, "Unexpected object.\n");
+}
+
+ IMoniker_Release(moniker2);
+
+ IMoniker_Release(moniker);
}
static void stream_write_dword(IStream *stream, DWORD value)
More information about the wine-cvs
mailing list