Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8f3ae201
Commit
8f3ae201
authored
Jun 30, 2008
by
Zac Brown
Committed by
Alexandre Julliard
Jul 01, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Implement checking for control characters in RtlIsTextUnicode.
parent
45632628
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
rtlstr.c
dlls/ntdll/rtlstr.c
+26
-0
rtlstr.c
dlls/ntdll/tests/rtlstr.c
+5
-16
No files found.
dlls/ntdll/rtlstr.c
View file @
8f3ae201
...
...
@@ -1592,6 +1592,8 @@ NTSTATUS WINAPI RtlFindCharInUnicodeString(
*/
BOOLEAN
WINAPI
RtlIsTextUnicode
(
LPCVOID
buf
,
INT
len
,
INT
*
pf
)
{
static
const
WCHAR
std_control_chars
[]
=
{
'\r'
,
'\n'
,
'\t'
,
' '
,
0x3000
,
0
};
static
const
WCHAR
byterev_control_chars
[]
=
{
0x0d00
,
0x0a00
,
0x0900
,
0x2000
,
0x0030
,
0
};
const
WCHAR
*
s
=
buf
;
int
i
;
unsigned
int
flags
=
~
0U
,
out_flags
=
0
;
...
...
@@ -1651,6 +1653,30 @@ BOOLEAN WINAPI RtlIsTextUnicode( LPCVOID buf, INT len, INT *pf )
}
}
if
(
flags
&
IS_TEXT_UNICODE_CONTROLS
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
strchrW
(
std_control_chars
,
s
[
i
]))
{
out_flags
|=
IS_TEXT_UNICODE_CONTROLS
;
break
;
}
}
}
if
(
flags
&
IS_TEXT_UNICODE_REVERSE_CONTROLS
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
strchrW
(
byterev_control_chars
,
s
[
i
]))
{
out_flags
|=
IS_TEXT_UNICODE_REVERSE_CONTROLS
;
break
;
}
}
}
if
(
pf
)
{
out_flags
&=
*
pf
;
...
...
dlls/ntdll/tests/rtlstr.c
View file @
8f3ae201
...
...
@@ -1693,7 +1693,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
);
...
...
@@ -1712,7 +1711,7 @@ static void test_RtlIsTextUnicode(void)
be_unicode
[
i
+
1
]
=
(
unicode
[
i
]
>>
8
)
|
((
unicode
[
i
]
&
0xff
)
<<
8
);
}
ok
(
!
pRtlIsTextUnicode
(
be_unicode
,
sizeof
(
unicode
)
+
2
,
NULL
),
"Reverse endian should not be Unicode
\n
"
);
todo_wine
ok
(
!
pRtlIsTextUnicode
(
&
be_unicode
[
1
],
sizeof
(
unicode
),
NULL
),
"Reverse endian should not be Unicode
\n
"
);
ok
(
!
pRtlIsTextUnicode
(
&
be_unicode
[
1
],
sizeof
(
unicode
),
NULL
),
"Reverse endian should not be Unicode
\n
"
);
flags
=
IS_TEXT_UNICODE_REVERSE_MASK
;
ok
(
!
pRtlIsTextUnicode
(
&
be_unicode
[
1
],
sizeof
(
unicode
),
&
flags
),
"Reverse endian should be Unicode
\n
"
);
...
...
@@ -1722,7 +1721,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
);
...
...
@@ -1750,11 +1748,8 @@ static void test_RtlIsTextUnicode(void)
ok
(
flags
==
0
,
"Expected flags 0x0, obtained %x
\n
"
,
flags
);
flags
=
IS_TEXT_UNICODE_CONTROLS
;
todo_wine
{
ok
(
pRtlIsTextUnicode
(
unicode
,
sizeof
(
unicode
),
&
flags
),
"Test should pass on Unicode string lacking control characters.
\n
"
);
ok
(
flags
==
IS_TEXT_UNICODE_CONTROLS
,
"Expected flags 0x04, obtained %x
\n
"
,
flags
);
}
ok
(
pRtlIsTextUnicode
(
unicode
,
sizeof
(
unicode
),
&
flags
),
"Test should pass on Unicode string lacking control characters.
\n
"
);
ok
(
flags
==
IS_TEXT_UNICODE_CONTROLS
,
"Expected flags 0x04, obtained %x
\n
"
,
flags
);
flags
=
IS_TEXT_UNICODE_CONTROLS
;
ok
(
!
pRtlIsTextUnicode
(
be_unicode_no_controls
,
sizeof
(
unicode_no_controls
)
+
2
,
&
flags
),
...
...
@@ -1762,11 +1757,8 @@ static void test_RtlIsTextUnicode(void)
ok
(
flags
==
0
,
"Expected flags 0x0, obtained %x
\n
"
,
flags
);
flags
=
IS_TEXT_UNICODE_CONTROLS
;
todo_wine
{
ok
(
pRtlIsTextUnicode
(
mixed_controls
,
sizeof
(
mixed_controls
),
&
flags
),
"Test should pass on a string containing control characters.
\n
"
);
ok
(
flags
==
IS_TEXT_UNICODE_CONTROLS
,
"Expected flags 0x04, obtained %x
\n
"
,
flags
);
}
ok
(
pRtlIsTextUnicode
(
mixed_controls
,
sizeof
(
mixed_controls
),
&
flags
),
"Test should pass on a string containing control characters.
\n
"
);
ok
(
flags
==
IS_TEXT_UNICODE_CONTROLS
,
"Expected flags 0x04, obtained %x
\n
"
,
flags
);
/* Test IS_TEXT_UNICODE_REVERSE_CONTROLS flag */
flags
=
IS_TEXT_UNICODE_REVERSE_CONTROLS
;
...
...
@@ -1784,18 +1776,15 @@ static void test_RtlIsTextUnicode(void)
flags
=
IS_TEXT_UNICODE_REVERSE_CONTROLS
;
ok
(
!
pRtlIsTextUnicode
(
be_unicode
,
sizeof
(
unicode
)
+
2
,
&
flags
),
"Test should pass with byte-reversed Unicode string containing control characters.
\n
"
);
todo_wine
ok
(
flags
==
IS_TEXT_UNICODE_REVERSE_CONTROLS
,
"Expected flags 0x40, obtained %x
\n
"
,
flags
);
flags
=
IS_TEXT_UNICODE_REVERSE_CONTROLS
;
ok
(
!
pRtlIsTextUnicode
(
mixed_controls
,
sizeof
(
mixed_controls
),
&
flags
),
"Test should pass on a string containing byte-reversed control characters.
\n
"
);
todo_wine
ok
(
flags
==
IS_TEXT_UNICODE_REVERSE_CONTROLS
,
"Expected flags 0x40, obtained %x
\n
"
,
flags
);
/* Test with flags for both byte-reverse and standard Unicode characters */
flags
=
IS_TEXT_UNICODE_CONTROLS
|
IS_TEXT_UNICODE_REVERSE_CONTROLS
;
ok
(
!
pRtlIsTextUnicode
(
mixed_controls
,
sizeof
(
mixed_controls
),
&
flags
),
"Test should pass on string containing both byte-reversed and standard control characters.
\n
"
);
todo_wine
ok
(
flags
==
(
IS_TEXT_UNICODE_CONTROLS
|
IS_TEXT_UNICODE_REVERSE_CONTROLS
),
"Expected flags 0x44, obtained %x
\n
"
,
flags
);
HeapFree
(
GetProcessHeap
(),
0
,
be_unicode
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment