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
225e7b34
Commit
225e7b34
authored
Sep 14, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Implement WriteWhitespace().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
31aac84a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
18 deletions
+74
-18
reader.c
dlls/xmllite/reader.c
+0
-5
writer.c
dlls/xmllite/tests/writer.c
+42
-9
writer.c
dlls/xmllite/writer.c
+27
-4
xmllite_private.h
dlls/xmllite/xmllite_private.h
+5
-0
No files found.
dlls/xmllite/reader.c
View file @
225e7b34
...
...
@@ -1159,11 +1159,6 @@ static void reader_skipn(xmlreader *reader, int n)
}
}
static
inline
BOOL
is_wchar_space
(
WCHAR
ch
)
{
return
ch
==
' '
||
ch
==
'\t'
||
ch
==
'\r'
||
ch
==
'\n'
;
}
/* [3] S ::= (#x20 | #x9 | #xD | #xA)+ */
static
int
reader_skipspaces
(
xmlreader
*
reader
)
{
...
...
dlls/xmllite/tests/writer.c
View file @
225e7b34
...
...
@@ -148,28 +148,30 @@ static void check_writer_state(IXmlWriter *writer, HRESULT exp_hr)
/* FIXME: add WriteNodeShallow */
hr
=
IXmlWriter_WriteProcessingInstruction
(
writer
,
L"a"
,
L"a"
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteQualifiedName
(
writer
,
L"a"
,
NULL
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteRaw
(
writer
,
L"a"
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteRawChars
(
writer
,
L"a"
,
1
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Omit
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"a"
,
NULL
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
hr
=
IXmlWriter_WriteString
(
writer
,
L"a"
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx
.
, expected %#lx.
\n
"
,
hr
,
exp_hr
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
/* FIXME: add WriteSurrogateCharEntity */
/* FIXME: add WriteWhitespace */
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L" "
);
ok
(
hr
==
exp_hr
,
"Unexpected hr %#lx, expected %#lx.
\n
"
,
hr
,
exp_hr
);
}
static
IStream
*
writer_set_output
(
IXmlWriter
*
writer
)
...
...
@@ -388,7 +390,9 @@ static void test_invalid_output_encoding(IXmlWriter *writer, IUnknown *output)
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
/* TODO: WriteSurrogateCharEntity */
/* TODO: WriteWhitespace */
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L" "
);
ok
(
hr
==
MX_E_ENCODING
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#lx.
\n
"
,
hr
);
...
...
@@ -2063,6 +2067,34 @@ static void test_WriteDocType(void)
IXmlWriter_Release
(
writer
);
}
static
void
test_WriteWhitespace
(
void
)
{
IXmlWriter
*
writer
;
IStream
*
stream
;
HRESULT
hr
;
hr
=
CreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
stream
=
writer_set_output
(
writer
);
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L" "
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L"ab"
);
ok
(
hr
==
WR_E_NONWHITESPACE
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
L"w"
,
NULL
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_WriteWhitespace
(
writer
,
L"
\t
"
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#lx.
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"Failed to flush, hr %#lx.
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
" <w>
\t
"
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
}
START_TEST
(
writer
)
{
test_writer_create
();
...
...
@@ -2085,4 +2117,5 @@ START_TEST(writer)
test_WriteCharEntity
();
test_WriteString
();
test_WriteDocType
();
test_WriteWhitespace
();
}
dlls/xmllite/writer.c
View file @
225e7b34
...
...
@@ -1752,13 +1752,36 @@ static HRESULT WINAPI xmlwriter_WriteSurrogateCharEntity(IXmlWriter *iface, WCHA
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
xmlwriter_WriteWhitespace
(
IXmlWriter
*
iface
,
LPCWSTR
pwszWhitespace
)
static
HRESULT
WINAPI
xmlwriter_WriteWhitespace
(
IXmlWriter
*
iface
,
LPCWSTR
text
)
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
xmlwriter
*
writer
=
impl_from_IXmlWriter
(
iface
);
size_t
length
=
0
;
FIXME
(
"%p %s
\n
"
,
This
,
wine_dbgstr_w
(
pwszWhitespace
));
TRACE
(
"%p, %s.
\n
"
,
iface
,
wine_dbgstr_w
(
text
));
return
E_NOTIMPL
;
switch
(
writer
->
state
)
{
case
XmlWriterState_Initial
:
return
E_UNEXPECTED
;
case
XmlWriterState_ElemStarted
:
writer_close_starttag
(
writer
);
break
;
case
XmlWriterState_InvalidEncoding
:
return
MX_E_ENCODING
;
case
XmlWriterState_Ready
:
break
;
default:
return
WR_E_INVALIDACTION
;
}
while
(
text
[
length
])
{
if
(
!
is_wchar_space
(
text
[
length
]))
return
WR_E_NONWHITESPACE
;
length
++
;
}
write_output_buffer
(
writer
->
output
,
text
,
length
);
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_Flush
(
IXmlWriter
*
iface
)
...
...
dlls/xmllite/xmllite_private.h
View file @
225e7b34
...
...
@@ -63,4 +63,9 @@ BOOL is_pubchar(WCHAR ch) DECLSPEC_HIDDEN;
BOOL
is_namestartchar
(
WCHAR
ch
)
DECLSPEC_HIDDEN
;
BOOL
is_namechar
(
WCHAR
ch
)
DECLSPEC_HIDDEN
;
static
inline
BOOL
is_wchar_space
(
WCHAR
ch
)
{
return
ch
==
' '
||
ch
==
'\t'
||
ch
==
'\r'
||
ch
==
'\n'
;
}
#endif
/* __XMLLITE_PRIVATE__ */
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