Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/compositemoniker.c | 65 ++++++++++++++--------------------- dlls/ole32/tests/moniker.c | 18 +++++++--- 2 files changed, 39 insertions(+), 44 deletions(-)
diff --git a/dlls/ole32/compositemoniker.c b/dlls/ole32/compositemoniker.c index 4eb9b32fe5e..60d11b3ba90 100644 --- a/dlls/ole32/compositemoniker.c +++ b/dlls/ole32/compositemoniker.c @@ -558,56 +558,41 @@ static HRESULT WINAPI CompositeMonikerImpl_Enum(IMoniker *iface, BOOL forward, I return hr; }
-/****************************************************************************** - * CompositeMoniker_IsEqual - ******************************************************************************/ -static HRESULT WINAPI -CompositeMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker) +static HRESULT WINAPI CompositeMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other) { - IEnumMoniker *enumMoniker1,*enumMoniker2; - IMoniker *tempMk1,*tempMk2; - HRESULT res1,res2,res; - BOOL done; - - TRACE("(%p,%p)\n",iface,pmkOtherMoniker); + CompositeMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker; + IMoniker **components, **other_components; + unsigned int i; + HRESULT hr;
- if (pmkOtherMoniker==NULL) - return S_FALSE; + TRACE("%p, %p.\n", iface, other);
- /* This method returns S_OK if the components of both monikers are equal when compared in the */ - /* left-to-right order.*/ - IMoniker_Enum(pmkOtherMoniker,TRUE,&enumMoniker1); + if (!other) + return E_INVALIDARG;
- if (enumMoniker1==NULL) + if (!(other_moniker = unsafe_impl_from_IMoniker(other))) return S_FALSE;
- IMoniker_Enum(iface,TRUE,&enumMoniker2); - - do { - - res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL); - res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL); - - if((res1==S_OK)&&(res2==S_OK)){ - done = (res = IMoniker_IsEqual(tempMk1,tempMk2)) == S_FALSE; - } - else - { - res = (res1==S_FALSE) && (res2==S_FALSE); - done = TRUE; - } + if (moniker->comp_count != other_moniker->comp_count) + return S_FALSE;
- if (res1==S_OK) - IMoniker_Release(tempMk1); + if (FAILED(hr = composite_get_components_alloc(moniker, &components))) return hr; + if (FAILED(hr = composite_get_components_alloc(other_moniker, &other_components))) + { + heap_free(components); + return hr; + }
- if (res2==S_OK) - IMoniker_Release(tempMk2); - } while (!done); + for (i = 0; i < moniker->comp_count; ++i) + { + if ((hr = IMoniker_IsEqual(components[i], other_components[i]) != S_OK)) + break; + }
- IEnumMoniker_Release(enumMoniker1); - IEnumMoniker_Release(enumMoniker2); + heap_free(other_components); + heap_free(components);
- return res; + return hr; }
static HRESULT WINAPI CompositeMonikerImpl_Hash(IMoniker *iface, DWORD *hash) diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 1e4c2e0211d..962ae6c269f 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -3303,20 +3303,16 @@ todo_wine
/* With itself */ hr = IMoniker_CommonPrefixWith(moniker, moniker, &moniker2); -todo_wine ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr); hr = IMoniker_IsEqual(moniker, moniker2); -todo_wine ok(hr == S_OK && moniker2 != moniker, "Unexpected hr %#x.\n", hr); IMoniker_Release(moniker2);
/* Equal composites */ hr = IMoniker_CommonPrefixWith(moniker, moniker1, &moniker2); -todo_wine ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr); ok(moniker2 != moniker && moniker2 != moniker1, "Unexpected object.\n"); hr = IMoniker_IsEqual(moniker, moniker2); -todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); IMoniker_Release(moniker2);
@@ -3349,6 +3345,20 @@ todo_wine IMoniker_Release(moniker); IMoniker_Release(moniker1);
+ /* IsEqual() */ + hr = create_moniker_from_desc("CI1I2", &moniker1); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = create_moniker_from_desc("CI1I2", &moniker2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMoniker_IsEqual(moniker1, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + hr = IMoniker_IsEqual(moniker1, moniker2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMoniker_IsEqual(moniker1, moniker1); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IMoniker_Release(moniker2); + IMoniker_Release(moniker1); + IBindCtx_Release(bindctx); }