From e97709ff6da534c1050ca346471f50eb0a9a902e Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Mon, 8 May 2006 12:41:58 +0100 Subject: [PATCH] ole32: Fix the algorithm used in ItemMonikerImpl_Hash to match native. --- dlls/ole32/itemmoniker.c | 17 ++++------------- dlls/ole32/tests/moniker.c | 1 - 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index d812df50416..d8ec89340d7 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -661,8 +661,8 @@ HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) { ItemMonikerImpl *This = (ItemMonikerImpl *)iface; - - int h = 0,i,skip,len; + DWORD h = 0; + int i,len; int off = 0; LPOLESTR val; @@ -672,17 +672,8 @@ HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash) val = This->itemName; len = lstrlenW(val); - if (len < 16) { - for (i = len ; i > 0; i--) { - h = (h * 37) + val[off++]; - } - } else { - /* only sample some characters */ - skip = len / 8; - for (i = len ; i > 0; i -= skip, off += skip) { - h = (h * 39) + val[off]; - } - } + for (i = len ; i > 0; i--) + h = (h * 3) ^ toupperW(val[off++]); *pdwHash=h; diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 07e6b966aeb..8ae5c408bfd 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -570,7 +570,6 @@ static void test_item_moniker(void) hr = IMoniker_Hash(moniker, &hash); ok_ole_success(hr, IMoniker_Hash); - todo_wine ok(hash == 0x73c, "Hash value != 0x73c, instead was 0x%08lx\n", hash);