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
05db7cf0
Commit
05db7cf0
authored
Oct 29, 2022
by
David Kahurani
Committed by
Alexandre Julliard
Nov 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Implement WriteSurrogateCharEntity.
Signed-off-by:
David Kahurani
<
k.kahurani@gmail.com
>
parent
083211f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
5 deletions
+90
-5
writer.c
dlls/xmllite/tests/writer.c
+63
-2
writer.c
dlls/xmllite/writer.c
+27
-3
No files found.
dlls/xmllite/tests/writer.c
View file @
05db7cf0
...
...
@@ -138,6 +138,8 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
{
IXmlReader
*
reader
;
HRESULT
hr
;
WCHAR
low
=
0xdcef
;
WCHAR
high
=
0xdaff
;
hr
=
CreateXmlReader
(
&
IID_IXmlReader
,
(
void
**
)
&
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
...
...
@@ -217,7 +219,8 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
hr
=
IXmlWriter_WriteString
(
writer
,
L"a"
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
/* FIXME: add WriteSurrogateCharEntity */
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
low
,
high
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L" "
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
...
...
@@ -372,6 +375,8 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
{
IXmlReader
*
reader
;
HRESULT
hr
;
WCHAR
low
=
0xdcef
;
WCHAR
high
=
0xdaff
;
hr
=
CreateXmlReader
(
&
IID_IXmlReader
,
(
void
**
)
&
reader
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
...
...
@@ -448,7 +453,8 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
hr
=
IXmlWriter_WriteString
(
writer
,
L"a"
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
/* TODO: WriteSurrogateCharEntity */
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
low
,
high
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L" "
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
...
...
@@ -2021,6 +2027,60 @@ static void test_WriteRawChars(void)
IXmlWriter_Release
(
writer
);
}
static
void
test_WriteSurrogateCharEntity
(
void
)
{
IXmlWriter
*
writer
;
IStream
*
stream
;
HRESULT
hr
;
WCHAR
low
=
0xdcef
;
WCHAR
high
=
0xdaff
;
hr
=
CreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
high
,
low
);
ok
(
hr
==
WC_E_XMLCHARACTER
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
low
,
high
);
ok
(
hr
==
E_UNEXPECTED
,
"Unexpected hr %#lx.
\n
"
,
hr
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"root"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
high
,
low
);
ok
(
hr
==
WC_E_XMLCHARACTER
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<root"
);
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
low
,
high
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteFullEndElement
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
"<root>󏳯</root>"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteEndElement
(
writer
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteSurrogateCharEntity
(
writer
,
low
,
high
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"Unexpected hr %#lx.
\n
"
,
hr
);
IXmlWriter_Release
(
writer
);
IStream_Release
(
stream
);
}
static
void
test_WriteString
(
void
)
{
static
const
WCHAR
surrogates
[]
=
{
0xd800
,
0xdc00
,
'x'
,
'y'
,
'\0'
};
...
...
@@ -2903,6 +2963,7 @@ START_TEST(writer)
test_WriteCharEntity
();
test_WriteChars
();
test_WriteRawChars
();
test_WriteSurrogateCharEntity
();
test_WriteString
();
test_WriteDocType
();
test_WriteWhitespace
();
...
...
dlls/xmllite/writer.c
View file @
05db7cf0
...
...
@@ -1979,11 +1979,35 @@ static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, const WCHAR *stri
static
HRESULT
WINAPI
xmlwriter_WriteSurrogateCharEntity
(
IXmlWriter
*
iface
,
WCHAR
wchLow
,
WCHAR
wchHigh
)
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
xmlwriter
*
writer
=
impl_from_IXmlWriter
(
iface
);
int
codepoint
;
WCHAR
bufW
[
16
];
FIXME
(
"%p %d %d
\n
"
,
This
,
wchLow
,
wchHigh
);
TRACE
(
"%p, %d, %d.
\n
"
,
iface
,
wchLow
,
wchHigh
);
return
E_NOTIMPL
;
if
(
!
IS_SURROGATE_PAIR
(
wchHigh
,
wchLow
))
return
WC_E_XMLCHARACTER
;
switch
(
writer
->
state
)
{
case
XmlWriterState_Initial
:
return
E_UNEXPECTED
;
case
XmlWriterState_InvalidEncoding
:
return
MX_E_ENCODING
;
case
XmlWriterState_ElemStarted
:
writer_close_starttag
(
writer
);
break
;
case
XmlWriterState_DocClosed
:
return
WR_E_INVALIDACTION
;
default:
;
}
codepoint
=
((
wchHigh
-
0xd800
)
*
0x400
)
+
(
wchLow
-
0xdc00
)
+
0x10000
;
swprintf
(
bufW
,
ARRAY_SIZE
(
bufW
),
L"&#x%X;"
,
codepoint
);
write_output_buffer
(
writer
->
output
,
bufW
,
-
1
);
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_WriteWhitespace
(
IXmlWriter
*
iface
,
LPCWSTR
text
)
...
...
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