Commit 564b796e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

scrrun/dictionary: Handle VT_EMPTY/VT_NULL keys.

parent e89bedb7
...@@ -188,6 +188,10 @@ static BOOL is_matching_key(const struct dictionary *dict, const struct keyitem_ ...@@ -188,6 +188,10 @@ static BOOL is_matching_key(const struct dictionary *dict, const struct keyitem_
{ {
return hash == pair->hash && numeric_key_eq(key, &pair->key); return hash == pair->hash && numeric_key_eq(key, &pair->key);
} }
else if (V_VT(&pair->key) == VT_EMPTY || V_VT(&pair->key) == VT_NULL)
{
return V_VT(&pair->key) == V_VT(key);
}
else else
{ {
WARN("Unexpected key type %#x.\n", V_VT(key)); WARN("Unexpected key type %#x.\n", V_VT(key));
......
...@@ -1009,6 +1009,45 @@ static void test_Add(void) ...@@ -1009,6 +1009,45 @@ static void test_Add(void)
VariantClear(&item); VariantClear(&item);
/* Empty and null keys. */
hr = IDictionary_RemoveAll(dict);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
V_VT(&key1) = VT_EMPTY;
V_I4(&key1) = 1;
V_VT(&item) = VT_BSTR;
V_BSTR(&item) = SysAllocString(L"empty");
hr = IDictionary_Add(dict, &key1, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
V_VT(&key2) = VT_EMPTY;
V_I4(&key2) = 2;
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == CTL_E_KEY_ALREADY_EXISTS, "Unexpected hr %#lx.\n", hr);
V_VT(&key2) = VT_NULL;
V_I4(&key2) = 2;
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_RemoveAll(dict);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_Add(dict, &key2, &item);
ok(hr == CTL_E_KEY_ALREADY_EXISTS, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_Add(dict, &key1, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
VariantClear(&item);
IDictionary_Release(dict); IDictionary_Release(dict);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment