Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- 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)