[PATCH] blah
Zac Brown
zac at zacbrown.org
Thu Jun 19 14:49:28 CDT 2008
---
dlls/ntdll/rtlstr.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
dlls/ntdll/tests/rtlstr.c | 2 -
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c
index deec931..619f2e9 100644
--- a/dlls/ntdll/rtlstr.c
+++ b/dlls/ntdll/rtlstr.c
@@ -1591,6 +1591,23 @@ NTSTATUS WINAPI RtlFindCharInUnicodeString(
*/
BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf )
{
+ /*
+ * Enum for possible control characters.
+ * BR = byte reversed, for use in byte reversed strings.
+ */
+ enum control_chars {
+ TAB = '\t',
+ BR_TAB = 0x0900,
+ CRET = '\r',
+ BR_CRET = 0x0d00,
+ NEWLINE = '\n',
+ BR_NEWLINE = 0x0a00,
+ SPACE = ' ',
+ BR_SPACE = 0x2000,
+ CJKSPACE = 0x3000,
+ BR_CJKSPACE = 0x0030
+ };
+
const WCHAR *s = buf;
int i;
unsigned int flags = ~0U, out_flags = 0;
@@ -1650,6 +1667,44 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf )
}
}
+ /* Check for control characters in string. */
+ if (flags & IS_TEXT_UNICODE_CONTROLS)
+ {
+ for (i = 0; i < len; i++)
+ {
+ switch (s[i])
+ {
+ case TAB:
+ case CRET:
+ case NEWLINE:
+ case SPACE:
+ case CJKSPACE:
+ out_flags |= IS_TEXT_UNICODE_CONTROLS;
+ goto control_char_done;
+ }
+ }
+ }
+
+ /* Check for control characters in byte reversed string. */
+ if ((flags & IS_TEXT_UNICODE_REVERSE_CONTROLS) && (out_flags & IS_TEXT_UNICODE_REVERSE_SIGNATURE))
+ {
+ for (i = 0; i < len; i++)
+ {
+ switch (s[i])
+ {
+ case BR_TAB:
+ case BR_CRET:
+ case BR_NEWLINE:
+ case BR_SPACE:
+ case BR_CJKSPACE:
+ out_flags |= IS_TEXT_UNICODE_REVERSE_CONTROLS;
+ goto control_char_done;
+ }
+ }
+ }
+
+ control_char_done:
+
if (pf)
{
out_flags &= *pf;
diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c
index aa4a391..5d77f9a 100644
--- a/dlls/ntdll/tests/rtlstr.c
+++ b/dlls/ntdll/tests/rtlstr.c
@@ -1689,7 +1689,6 @@ static void test_RtlIsTextUnicode(void)
flags = IS_TEXT_UNICODE_UNICODE_MASK;
ok(pRtlIsTextUnicode(unicode, sizeof(unicode), &flags), "Text should not pass a Unicode\n");
- todo_wine
ok(flags == (IS_TEXT_UNICODE_STATISTICS | IS_TEXT_UNICODE_CONTROLS),
"Expected flags 0x6, obtained %x\n", flags);
@@ -1718,7 +1717,6 @@ static void test_RtlIsTextUnicode(void)
flags = IS_TEXT_UNICODE_REVERSE_MASK;
ok(!pRtlIsTextUnicode(be_unicode, sizeof(unicode) + 2, &flags), "Reverse endian should be Unicode\n");
- todo_wine
ok(flags == (IS_TEXT_UNICODE_REVERSE_CONTROLS | IS_TEXT_UNICODE_REVERSE_SIGNATURE),
"Expected flags 0xc0, obtained %x\n", flags);
HeapFree(GetProcessHeap(), 0, be_unicode);
--
1.5.3.6
--------------080400000200060607070002--
More information about the wine-patches
mailing list