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
7b8929e0
Commit
7b8929e0
authored
Mar 15, 2016
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 16, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Implement WriteCData().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
254e76fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
3 deletions
+115
-3
writer.c
dlls/xmllite/tests/writer.c
+67
-0
writer.c
dlls/xmllite/writer.c
+48
-3
No files found.
dlls/xmllite/tests/writer.c
View file @
7b8929e0
...
...
@@ -814,6 +814,72 @@ static void test_WriteComment(void)
IStream_Release
(
stream
);
}
static
void
test_WriteCData
(
void
)
{
static
const
WCHAR
closeW
[]
=
{
']'
,
']'
,
'>'
,
0
};
static
const
WCHAR
close2W
[]
=
{
'a'
,
']'
,
']'
,
'>'
,
'b'
,
0
};
static
const
WCHAR
aW
[]
=
{
'a'
,
0
};
static
const
WCHAR
bW
[]
=
{
'b'
,
0
};
IXmlWriter
*
writer
;
IStream
*
stream
;
HGLOBAL
hglobal
;
HRESULT
hr
;
char
*
ptr
;
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
pCreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetProperty
(
writer
,
XmlWriterProperty_OmitXmlDeclaration
,
TRUE
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteCData
(
writer
,
aW
);
ok
(
hr
==
E_UNEXPECTED
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
bW
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteCData
(
writer
,
aW
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteCData
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteCData
(
writer
,
closeW
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteCData
(
writer
,
close2W
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
GetHGlobalFromStream
(
stream
,
&
hglobal
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
ptr
!=
NULL
,
"got %p
\n
"
,
ptr
);
ok
(
!
strncmp
(
ptr
,
"<b>"
"<![CDATA[a]]>"
"<![CDATA[]]>"
"<![CDATA[]]]]>"
"<![CDATA[>]]>"
"<![CDATA[a]]]]>"
"<![CDATA[>b]]>"
,
84
),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
IXmlWriter_Release
(
writer
);
IStream_Release
(
stream
);
}
START_TEST
(
writer
)
{
if
(
!
init_pointers
())
...
...
@@ -829,4 +895,5 @@ START_TEST(writer)
test_bom
();
test_writeenddocument
();
test_WriteComment
();
test_WriteCData
();
}
dlls/xmllite/writer.c
View file @
7b8929e0
...
...
@@ -556,13 +556,58 @@ static HRESULT WINAPI xmlwriter_WriteAttributeString(IXmlWriter *iface, LPCWSTR
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
xmlwriter_WriteCData
(
IXmlWriter
*
iface
,
LPCWSTR
pwszText
)
static
void
write_cdata_section
(
xmlwriteroutput
*
output
,
const
WCHAR
*
data
,
int
len
)
{
static
const
WCHAR
cdataopenW
[]
=
{
'<'
,
'!'
,
'['
,
'C'
,
'D'
,
'A'
,
'T'
,
'A'
,
'['
};
static
const
WCHAR
cdatacloseW
[]
=
{
']'
,
']'
,
'>'
};
write_output_buffer
(
output
,
cdataopenW
,
ARRAY_SIZE
(
cdataopenW
));
if
(
data
)
write_output_buffer
(
output
,
data
,
len
);
write_output_buffer
(
output
,
cdatacloseW
,
ARRAY_SIZE
(
cdatacloseW
));
}
static
HRESULT
WINAPI
xmlwriter_WriteCData
(
IXmlWriter
*
iface
,
LPCWSTR
data
)
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
int
len
;
FIXME
(
"%p %s
\n
"
,
This
,
wine_dbgstr_w
(
pwszText
));
TRACE
(
"%p %s
\n
"
,
This
,
debugstr_w
(
data
));
return
E_NOTIMPL
;
switch
(
This
->
state
)
{
case
XmlWriterState_Initial
:
return
E_UNEXPECTED
;
case
XmlWriterState_ElemStarted
:
writer_close_starttag
(
This
);
break
;
case
XmlWriterState_DocClosed
:
return
WR_E_INVALIDACTION
;
default:
;
}
len
=
data
?
strlenW
(
data
)
:
0
;
if
(
!
len
)
write_cdata_section
(
This
->
output
,
NULL
,
0
);
else
{
static
const
WCHAR
cdatacloseW
[]
=
{
']'
,
']'
,
'>'
,
0
};
while
(
len
)
{
const
WCHAR
*
str
=
strstrW
(
data
,
cdatacloseW
);
if
(
str
)
{
str
+=
2
;
write_cdata_section
(
This
->
output
,
data
,
str
-
data
);
len
-=
str
-
data
;
data
=
str
;
}
else
{
write_cdata_section
(
This
->
output
,
data
,
len
);
break
;
}
}
}
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_WriteCharEntity
(
IXmlWriter
*
iface
,
WCHAR
wch
)
...
...
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