Robert Shearman : ole32: Fix the algorithm used in ItemMonikerImpl_Hash to match native.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 8 09:06:17 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: e97709ff6da534c1050ca346471f50eb0a9a902e
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=e97709ff6da534c1050ca346471f50eb0a9a902e

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon May  8 12:41:58 2006 +0100

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 d812df5..d8ec893 100644
--- a/dlls/ole32/itemmoniker.c
+++ b/dlls/ole32/itemmoniker.c
@@ -661,8 +661,8 @@ HRESULT WINAPI ItemMonikerImpl_IsEqual(I
 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(IMon
     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 07e6b96..8ae5c40 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);




More information about the wine-cvs mailing list