Alexandre Julliard : ntdll: Use the NLS case mapping table for RtlHashUnicodeString().
Alexandre Julliard
julliard at winehq.org
Thu Mar 26 16:27:23 CDT 2020
Module: wine
Branch: master
Commit: 9bbb66fdf72a4090e38da46bda0eff0a6ab642ac
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9bbb66fdf72a4090e38da46bda0eff0a6ab642ac
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Mar 26 11:26:13 2020 +0100
ntdll: Use the NLS case mapping table for RtlHashUnicodeString().
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/locale.c | 34 ++++++++++++++++++++++++++++++++++
dlls/ntdll/rtlstr.c | 25 -------------------------
dlls/ntdll/tests/rtlstr.c | 20 ++++++++++++--------
3 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index afd65f3c02..1be3086a1e 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -1288,6 +1288,40 @@ BOOLEAN WINAPI RtlPrefixUnicodeString( const UNICODE_STRING *s1, const UNICODE_S
}
+
+/******************************************************************************
+ * RtlHashUnicodeString (NTDLL.@)
+ */
+NTSTATUS WINAPI RtlHashUnicodeString( const UNICODE_STRING *string, BOOLEAN case_insensitive,
+ ULONG alg, ULONG *hash )
+{
+ unsigned int i;
+
+ if (!string || !hash) return STATUS_INVALID_PARAMETER;
+
+ switch (alg)
+ {
+ case HASH_STRING_ALGORITHM_DEFAULT:
+ case HASH_STRING_ALGORITHM_X65599:
+ break;
+ default:
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ *hash = 0;
+ if (!case_insensitive)
+ for (i = 0; i < string->Length / sizeof(WCHAR); i++)
+ *hash = *hash * 65599 + string->Buffer[i];
+ else if (nls_info.UpperCaseTable)
+ for (i = 0; i < string->Length / sizeof(WCHAR); i++)
+ *hash = *hash * 65599 + casemap( nls_info.UpperCaseTable, string->Buffer[i] );
+ else /* locale not setup yet */
+ for (i = 0; i < string->Length / sizeof(WCHAR); i++)
+ *hash = *hash * 65599 + casemap_ascii( string->Buffer[i] );
+ return STATUS_SUCCESS;
+}
+
+
/**************************************************************************
* RtlCustomCPToUnicodeN (NTDLL.@)
*/
diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c
index c0d8ec6477..6f2a2e85c2 100644
--- a/dlls/ntdll/rtlstr.c
+++ b/dlls/ntdll/rtlstr.c
@@ -1708,28 +1708,3 @@ NTSTATUS WINAPI RtlStringFromGUID(const GUID* guid, UNICODE_STRING *str)
return STATUS_SUCCESS;
}
-
-/******************************************************************************
- * RtlHashUnicodeString [NTDLL.@]
- */
-NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING string, BOOLEAN case_insensitive, ULONG alg, ULONG *hash)
-{
- unsigned int i;
-
- if (!string || !hash) return STATUS_INVALID_PARAMETER;
-
- switch (alg)
- {
- case HASH_STRING_ALGORITHM_DEFAULT:
- case HASH_STRING_ALGORITHM_X65599:
- break;
- default:
- return STATUS_INVALID_PARAMETER;
- }
-
- *hash = 0;
- for (i = 0; i < string->Length/sizeof(WCHAR); i++)
- *hash = *hash*65599 + (case_insensitive ? toupperW(string->Buffer[i]) : string->Buffer[i]);
-
- return STATUS_SUCCESS;
-}
diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c
index f872422954..cd95ec3a48 100644
--- a/dlls/ntdll/tests/rtlstr.c
+++ b/dlls/ntdll/tests/rtlstr.c
@@ -1942,14 +1942,18 @@ struct hash_unicodestring_test {
};
static const struct hash_unicodestring_test hash_test[] = {
- { {'T',0}, FALSE, 0x00000054 },
- { {'T','e','s','t',0}, FALSE, 0x766bb952 },
- { {'T','e','S','t',0}, FALSE, 0x764bb172 },
- { {'t','e','s','t',0}, FALSE, 0x4745d132 },
- { {'t','e','s','t',0}, TRUE, 0x6689c132 },
- { {'T','E','S','T',0}, TRUE, 0x6689c132 },
- { {'T','E','S','T',0}, FALSE, 0x6689c132 },
- { {'a','b','c','d','e','f',0}, FALSE, 0x971318c3 },
+ { L"T", FALSE, 0x00000054 },
+ { L"Test", FALSE, 0x766bb952 },
+ { L"TeSt", FALSE, 0x764bb172 },
+ { L"test", FALSE, 0x4745d132 },
+ { L"test", TRUE, 0x6689c132 },
+ { L"TEST", TRUE, 0x6689c132 },
+ { L"TEST", FALSE, 0x6689c132 },
+ { L"t\xe9st", FALSE, 0x8845cfb6 },
+ { L"t\xe9st", TRUE, 0xa789bfb6 },
+ { L"T\xc9ST", TRUE, 0xa789bfb6 },
+ { L"T\xc9ST", FALSE, 0xa789bfb6 },
+ { L"abcdef", FALSE, 0x971318c3 },
{ { 0 } }
};
More information about the wine-cvs
mailing list