Apply only specified tests.

Implement IS_TEXT_UNICODE_REVERSE_SIGNATURE, IS_TEXT_UNICODE_STATISTICS
and IS_TEXT_UNICODE_NULL_BYTES tests.
Revert IS_TEXT_UNICODE_ODD_LENGTH test.
This commit is contained in:
Dmitry Timoshkov 2003-08-20 03:34:45 +00:00 committed by Alexandre Julliard
parent 00e5ccfa17
commit 4aec75f017
1 changed files with 38 additions and 4 deletions

View File

@ -1405,7 +1405,11 @@ NTSTATUS WINAPI RtlFindCharInUnicodeString(
*/
/* Tests that we currently implement */
#define ITU_IMPLEMENTED_TESTS \
(IS_TEXT_UNICODE_SIGNATURE|IS_TEXT_UNICODE_ODD_LENGTH)
(IS_TEXT_UNICODE_SIGNATURE | \
IS_TEXT_UNICODE_REVERSE_SIGNATURE | \
IS_TEXT_UNICODE_ODD_LENGTH | \
IS_TEXT_UNICODE_STATISTICS | \
IS_TEXT_UNICODE_NULL_BYTES)
/**************************************************************************
* RtlIsTextUnicode (NTDLL.@)
@ -1443,13 +1447,43 @@ DWORD WINAPI RtlIsTextUnicode(
*/
/* Check for an odd length ... pass if even. */
if (!(len & 1))
if ((flags & IS_TEXT_UNICODE_ODD_LENGTH) && (len & 1))
out_flags |= IS_TEXT_UNICODE_ODD_LENGTH;
/* Check for the special unicode marker byte. */
if (*s == 0xFEFF)
/* Check for the special byte order unicode marks. */
if ((flags & IS_TEXT_UNICODE_SIGNATURE) && *s == 0xFEFF)
out_flags |= IS_TEXT_UNICODE_SIGNATURE;
if ((flags & IS_TEXT_UNICODE_REVERSE_SIGNATURE) && *s == 0xFFFE)
out_flags |= IS_TEXT_UNICODE_REVERSE_SIGNATURE;
/* apply some statistical analysis */
if (flags & IS_TEXT_UNICODE_STATISTICS)
{
DWORD i, stats = 0;
/* FIXME: checks only for ASCII characters in the unicode stream */
for (i = 0; i < len / sizeof(WCHAR); i++)
{
if (s[i] <= 255) stats++;
}
if (stats > len / sizeof(WCHAR) / 2)
out_flags |= IS_TEXT_UNICODE_STATISTICS;
}
/* Check for unicode NULL chars */
if (flags & IS_TEXT_UNICODE_NULL_BYTES)
{
DWORD i;
for (i = 0; i < len / sizeof(WCHAR); i++)
{
if (!s[i])
{
out_flags |= IS_TEXT_UNICODE_NULL_BYTES;
break;
}
}
}
/*
* Check whether the string passed all of the tests.
*/