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
41fcd104
Commit
41fcd104
authored
Mar 14, 2016
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Implement WriteComment().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a62d1787
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
3 deletions
+103
-3
writer.c
dlls/xmllite/tests/writer.c
+60
-0
writer.c
dlls/xmllite/writer.c
+43
-3
No files found.
dlls/xmllite/tests/writer.c
View file @
41fcd104
...
...
@@ -755,6 +755,65 @@ static void test_writeenddocument(void)
IStream_Release
(
stream
);
}
static
void
test_WriteComment
(
void
)
{
static
const
WCHAR
closeW
[]
=
{
'-'
,
'-'
,
'>'
,
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_WriteComment
(
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_WriteStartDocument
(
writer
,
XmlStandalone_Omit
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteComment
(
writer
,
aW
);
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_WriteComment
(
writer
,
aW
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteComment
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteComment
(
writer
,
closeW
);
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
,
"<!--a--><b><!--a--><!----><!--- ->-->"
,
37
),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
IXmlWriter_Release
(
writer
);
IStream_Release
(
stream
);
}
START_TEST
(
writer
)
{
if
(
!
init_pointers
())
...
...
@@ -769,4 +828,5 @@ START_TEST(writer)
test_omitxmldeclaration
();
test_bom
();
test_writeenddocument
();
test_WriteComment
();
}
dlls/xmllite/writer.c
View file @
41fcd104
...
...
@@ -43,6 +43,7 @@ static const WCHAR closeelementW[] = {'<','/'};
static
const
WCHAR
closepiW
[]
=
{
'?'
,
'>'
};
static
const
WCHAR
ltW
[]
=
{
'<'
};
static
const
WCHAR
gtW
[]
=
{
'>'
};
static
const
WCHAR
spaceW
[]
=
{
' '
};
struct
output_buffer
{
...
...
@@ -578,9 +579,49 @@ static HRESULT WINAPI xmlwriter_WriteChars(IXmlWriter *iface, const WCHAR *pwch,
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
xmlwriter_WriteComment
(
IXmlWriter
*
iface
,
LPCWSTR
pwszC
omment
)
static
HRESULT
WINAPI
xmlwriter_WriteComment
(
IXmlWriter
*
iface
,
LPCWSTR
c
omment
)
{
return
E_NOTIMPL
;
static
const
WCHAR
copenW
[]
=
{
'<'
,
'!'
,
'-'
,
'-'
};
static
const
WCHAR
ccloseW
[]
=
{
'-'
,
'-'
,
'>'
};
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
TRACE
(
"%p %s
\n
"
,
This
,
debugstr_w
(
comment
));
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:
;
}
write_output_buffer
(
This
->
output
,
copenW
,
ARRAY_SIZE
(
copenW
));
if
(
comment
)
{
int
len
=
strlenW
(
comment
),
i
;
/* Make sure there's no two hyphen sequences in a string, space is used as a separator to produce compliant
comment string */
if
(
len
>
1
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
write_output_buffer
(
This
->
output
,
comment
+
i
,
1
);
if
(
comment
[
i
]
==
'-'
&&
(
i
+
1
<
len
)
&&
comment
[
i
+
1
]
==
'-'
)
write_output_buffer
(
This
->
output
,
spaceW
,
ARRAY_SIZE
(
spaceW
));
}
}
else
write_output_buffer
(
This
->
output
,
comment
,
len
);
if
(
len
&&
comment
[
len
-
1
]
==
'-'
)
write_output_buffer
(
This
->
output
,
spaceW
,
ARRAY_SIZE
(
spaceW
));
}
write_output_buffer
(
This
->
output
,
ccloseW
,
ARRAY_SIZE
(
ccloseW
));
return
S_OK
;
}
static
HRESULT
WINAPI
xmlwriter_WriteDocType
(
IXmlWriter
*
iface
,
LPCWSTR
pwszName
,
LPCWSTR
pwszPublicId
,
...
...
@@ -763,7 +804,6 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
static
const
WCHAR
xmlW
[]
=
{
'x'
,
'm'
,
'l'
,
0
};
static
const
WCHAR
openpiW
[]
=
{
'<'
,
'?'
};
static
const
WCHAR
spaceW
[]
=
{
' '
};
TRACE
(
"(%p)->(%s %s)
\n
"
,
This
,
wine_dbgstr_w
(
name
),
wine_dbgstr_w
(
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