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
083211f5
Commit
083211f5
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 WriteRawChars.
Signed-off-by:
David Kahurani
<
k.kahurani@gmail.com
>
parent
f3cfbef6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
5 deletions
+143
-5
writer.c
dlls/xmllite/tests/writer.c
+116
-0
writer.c
dlls/xmllite/writer.c
+27
-5
No files found.
dlls/xmllite/tests/writer.c
View file @
083211f5
...
@@ -456,6 +456,9 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
...
@@ -456,6 +456,9 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
hr
=
IXmlWriter_WriteChars
(
writer
,
L"a"
,
1
);
hr
=
IXmlWriter_WriteChars
(
writer
,
L"a"
,
1
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L"a"
,
1
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#lx.
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#lx.
\n
"
,
hr
);
...
@@ -1906,6 +1909,118 @@ static void test_WriteCharEntity(void)
...
@@ -1906,6 +1909,118 @@ static void test_WriteCharEntity(void)
IStream_Release
(
stream
);
IStream_Release
(
stream
);
}
}
static
void
test_WriteRawChars
(
void
)
{
IXmlWriter
*
writer
;
IStream
*
stream
;
HRESULT
hr
;
static
WCHAR
surrogates
[]
=
{
0xd800
,
0xdc00
,
0
};
hr
=
CreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
NULL
,
0
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L""
,
0
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
NULL
,
5
);
ok
(
hr
==
E_INVALIDARG
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L""
,
6
);
ok
(
hr
==
E_UNEXPECTED
,
"Unexpected hr %#lx.
\n
"
,
hr
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"sub"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L"<rawChars>"
,
5
);
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
,
"<sub><rawC"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L"a"
,
1
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"sub"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L"<;;>"
,
10
);
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
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>a<sub><;;>"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"sub"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
surrogates
,
1
);
ok
(
hr
==
WR_E_INVALIDSURROGATEPAIR
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
surrogates
,
2
);
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
,
"<sub>\U00010000"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"sub"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L""
,
5
);
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
,
"<sub>"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"sub"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L""
,
0
);
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
,
"<sub"
);
IStream_Release
(
stream
);
stream
=
writer_set_output
(
writer
);
/* Force document close */
hr
=
IXmlWriter_WriteEndElement
(
writer
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L"a"
,
1
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"Unexpected hr %#lx.
\n
"
,
hr
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
}
static
void
test_WriteString
(
void
)
static
void
test_WriteString
(
void
)
{
{
static
const
WCHAR
surrogates
[]
=
{
0xd800
,
0xdc00
,
'x'
,
'y'
,
'\0'
};
static
const
WCHAR
surrogates
[]
=
{
0xd800
,
0xdc00
,
'x'
,
'y'
,
'\0'
};
...
@@ -2787,6 +2902,7 @@ START_TEST(writer)
...
@@ -2787,6 +2902,7 @@ START_TEST(writer)
test_WriteFullEndElement
();
test_WriteFullEndElement
();
test_WriteCharEntity
();
test_WriteCharEntity
();
test_WriteChars
();
test_WriteChars
();
test_WriteRawChars
();
test_WriteString
();
test_WriteString
();
test_WriteDocType
();
test_WriteDocType
();
test_WriteWhitespace
();
test_WriteWhitespace
();
...
...
dlls/xmllite/writer.c
View file @
083211f5
...
@@ -1808,13 +1808,21 @@ static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)
...
@@ -1808,13 +1808,21 @@ static HRESULT WINAPI xmlwriter_WriteRaw(IXmlWriter *iface, LPCWSTR data)
return
hr
;
return
hr
;
}
}
static
HRESULT
WINAPI
xmlwriter_WriteRawChars
(
IXmlWriter
*
iface
,
const
WCHAR
*
pwch
,
UINT
cwc
h
)
static
HRESULT
WINAPI
xmlwriter_WriteRawChars
(
IXmlWriter
*
iface
,
const
WCHAR
*
characters
,
UINT
lengt
h
)
{
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
xmlwriter
*
writer
=
impl_from_IXmlWriter
(
iface
);
HRESULT
hr
=
S_OK
;
unsigned
int
count
;
FIXME
(
"%p %s %d
\n
"
,
This
,
wine_dbgstr_w
(
pwch
),
cwc
h
);
TRACE
(
"%p, %s, %d.
\n
"
,
iface
,
debugstr_wn
(
characters
,
length
),
lengt
h
);
switch
(
This
->
state
)
if
((
characters
==
NULL
&&
length
!=
0
))
return
E_INVALIDARG
;
if
(
length
==
0
)
return
S_OK
;
switch
(
writer
->
state
)
{
{
case
XmlWriterState_Initial
:
case
XmlWriterState_Initial
:
return
E_UNEXPECTED
;
return
E_UNEXPECTED
;
...
@@ -1822,11 +1830,25 @@ static HRESULT WINAPI xmlwriter_WriteRawChars(IXmlWriter *iface, const WCHAR *p
...
@@ -1822,11 +1830,25 @@ static HRESULT WINAPI xmlwriter_WriteRawChars(IXmlWriter *iface, const WCHAR *p
return
MX_E_ENCODING
;
return
MX_E_ENCODING
;
case
XmlWriterState_DocClosed
:
case
XmlWriterState_DocClosed
:
return
WR_E_INVALIDACTION
;
return
WR_E_INVALIDACTION
;
case
XmlWriterState_Ready
:
write_xmldecl
(
writer
,
XmlStandalone_Omit
);
break
;
case
XmlWriterState_ElemStarted
:
writer_close_starttag
(
writer
);
default:
default:
;
;
}
}
return
E_NOTIMPL
;
while
(
length
)
{
if
(
FAILED
(
hr
=
writer_get_next_write_count
(
characters
,
length
,
&
count
)))
return
hr
;
if
(
FAILED
(
hr
=
write_output_buffer
(
writer
->
output
,
characters
,
count
)))
return
hr
;
characters
+=
count
;
length
-=
count
;
}
return
hr
;
}
}
static
HRESULT
WINAPI
xmlwriter_WriteStartDocument
(
IXmlWriter
*
iface
,
XmlStandalone
standalone
)
static
HRESULT
WINAPI
xmlwriter_WriteStartDocument
(
IXmlWriter
*
iface
,
XmlStandalone
standalone
)
...
...
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