ole32: Simplify CommonPrefixWith() for class moniker.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-09-14 11:47:53 +03:00 committed by Alexandre Julliard
parent 5e1a8ada72
commit e2f8a3e4ed
1 changed files with 12 additions and 24 deletions

View File

@ -452,39 +452,27 @@ static HRESULT WINAPI ClassMoniker_Inverse(IMoniker* iface,IMoniker** ppmk)
return CreateAntiMoniker(ppmk); return CreateAntiMoniker(ppmk);
} }
/****************************************************************************** static HRESULT WINAPI ClassMoniker_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix)
* ClassMoniker_CommonPrefixWith
******************************************************************************/
static HRESULT WINAPI ClassMoniker_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
{ {
DWORD mkSys; ClassMoniker *moniker = impl_from_IMoniker(iface), *other_moniker;
TRACE("(%p, %p)\n", pmkOther, ppmkPrefix);
*ppmkPrefix = NULL; TRACE("%p, %p, %p\n", iface, other, prefix);
IMoniker_IsSystemMoniker(pmkOther, &mkSys); *prefix = NULL;
/* If the other moniker is an class moniker that is equal to this moniker, this method sets *ppmkPrefix */ other_moniker = unsafe_impl_from_IMoniker(other);
/* to this moniker and returns MK_S_US */
if (mkSys == MKSYS_CLASSMONIKER) if (other_moniker)
{ {
if (IMoniker_IsEqual(iface, pmkOther) == S_OK) if (!IsEqualGUID(&moniker->clsid, &other_moniker->clsid)) return MK_E_NOPREFIX;
{
*ppmkPrefix = iface;
IMoniker_AddRef(iface); *prefix = iface;
IMoniker_AddRef(iface);
return MK_S_US; return MK_S_US;
}
else
return MK_E_NOPREFIX;
} }
else
/* otherwise, the method calls the MonikerCommonPrefixWith function. This function correctly handles */ return MonikerCommonPrefixWith(iface, other, prefix);
/* the case where the other moniker is a generic composite. */
return MonikerCommonPrefixWith(iface, pmkOther, ppmkPrefix);
} }
/****************************************************************************** /******************************************************************************