Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
a4b24978
Commit
a4b24978
authored
13 years ago
by
Nikolay Sivov
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
msxml3: Use libxml2 buffer support through helpers.
parent
486a20c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/msxml3/mxwriter.c
+40
-23
40 additions, 23 deletions
dlls/msxml3/mxwriter.c
dlls/msxml3/tests/saxreader.c
+29
-0
29 additions, 0 deletions
dlls/msxml3/tests/saxreader.c
with
69 additions
and
23 deletions
dlls/msxml3/mxwriter.c
+
40
−
23
View file @
a4b24978
...
...
@@ -148,12 +148,23 @@ static HRESULT write_data_to_stream(mxwriter *This)
return
hres
;
}
static
void
write_output_buffer
(
const
mxwriter
*
This
,
const
char
*
data
,
int
len
)
{
xmlOutputBufferWrite
(
This
->
buffer
,
len
,
data
);
}
static
void
write_output_buffer_str
(
const
mxwriter
*
This
,
const
char
*
data
)
{
xmlOutputBufferWriteString
(
This
->
buffer
,
data
);
}
/* Newly added element start tag left unclosed cause for empty elements
we have to close it differently. */
static
void
close_element_starttag
(
const
mxwriter
*
This
)
{
static
const
char
gt
=
'>'
;
if
(
!
This
->
element
)
return
;
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
">"
);
write_o
utput
_b
uffer
(
This
,
&
gt
,
1
);
}
static
void
set_element_name
(
mxwriter
*
This
,
const
WCHAR
*
name
,
int
len
)
...
...
@@ -609,6 +620,12 @@ static HRESULT WINAPI mxwriter_saxcontent_putDocumentLocator(
static
HRESULT
WINAPI
mxwriter_saxcontent_startDocument
(
ISAXContentHandler
*
iface
)
{
static
const
char
version
[]
=
"<?xml version=
\"
"
;
static
const
char
encoding
[]
=
" encoding=
\"
"
;
static
const
char
standalone
[]
=
" standalone=
\"
"
;
static
const
char
yes
[]
=
"yes
\"
?>"
;
static
const
char
no
[]
=
"no
\"
?>"
;
mxwriter
*
This
=
impl_from_ISAXContentHandler
(
iface
);
xmlChar
*
s
;
...
...
@@ -627,25 +644,25 @@ static HRESULT WINAPI mxwriter_saxcontent_startDocument(ISAXContentHandler *ifac
if
(
This
->
props
[
MXWriter_OmitXmlDecl
]
==
VARIANT_TRUE
)
return
S_OK
;
/* version */
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"<?xml
version
=
\"
"
);
write_o
utput
_b
uffer
(
This
,
version
,
sizeof
(
version
)
-
1
);
s
=
xmlchar_from_wchar
(
This
->
version
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
(
char
*
)
s
);
write_o
utput
_b
uffer
_str
(
This
,
(
char
*
)
s
);
heap_free
(
s
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"
\"
"
);
write_o
utput
_b
uffer
(
This
,
"
\"
"
,
1
);
/* encoding */
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"
encoding
=
\"
"
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
xmlGetCharEncodingName
(
This
->
encoding
));
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"
\"
"
);
write_o
utput
_b
uffer
(
This
,
encoding
,
sizeof
(
encoding
)
-
1
);
write_o
utput
_b
uffer
_str
(
This
,
xmlGetCharEncodingName
(
This
->
encoding
));
write_o
utput
_b
uffer
(
This
,
"
\"
"
,
1
);
/* standalone */
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"
standalone
=
\"
"
);
write_o
utput
_b
uffer
(
This
,
standalone
,
sizeof
(
standalone
)
-
1
);
if
(
This
->
props
[
MXWriter_Standalone
]
==
VARIANT_TRUE
)
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"yes
\"
?>"
);
write_o
utput
_b
uffer
(
This
,
yes
,
sizeof
(
yes
)
-
1
);
else
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"no
\"
?>"
);
write_o
utput
_b
uffer
(
This
,
no
,
sizeof
(
no
)
-
1
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
crlfA
);
write_o
utput
_b
uffer
(
This
,
crlfA
,
sizeof
(
crlfA
)
-
1
)
;
if
(
This
->
dest
&&
This
->
encoding
==
XML_CHAR_ENCODING_UTF16LE
)
{
static
const
CHAR
utf16BOM
[]
=
{
0xff
,
0xfe
};
...
...
@@ -713,9 +730,9 @@ static HRESULT WINAPI mxwriter_saxcontent_startElement(
set_element_name
(
This
,
QName
?
QName
:
emptyW
,
QName
?
nQName
:
0
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"<"
);
write_o
utput
_b
uffer
(
This
,
"<"
,
1
);
s
=
xmlchar_from_wcharn
(
QName
,
nQName
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
(
char
*
)
s
);
write_o
utput
_b
uffer
_str
(
This
,
(
char
*
)
s
);
heap_free
(
s
);
if
(
attr
)
...
...
@@ -736,23 +753,23 @@ static HRESULT WINAPI mxwriter_saxcontent_startElement(
if
(
FAILED
(
hr
))
return
hr
;
/* space separator in front of every attribute */
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
" "
);
write_o
utput
_b
uffer
(
This
,
" "
,
1
);
s
=
xmlchar_from_wcharn
(
str
,
len
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
(
char
*
)
s
);
write_o
utput
_b
uffer
_str
(
This
,
(
char
*
)
s
);
heap_free
(
s
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"=
\"
"
);
write_o
utput
_b
uffer
(
This
,
"=
\"
"
,
2
);
len
=
0
;
hr
=
ISAXAttributes_getValue
(
attr
,
i
,
&
str
,
&
len
);
if
(
FAILED
(
hr
))
return
hr
;
s
=
xmlchar_from_wcharn
(
str
,
len
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
(
char
*
)
s
);
write_o
utput
_b
uffer
_str
(
This
,
(
char
*
)
s
);
heap_free
(
s
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"
\"
"
);
write_o
utput
_b
uffer
(
This
,
"
\"
"
,
1
);
}
}
...
...
@@ -778,15 +795,15 @@ static HRESULT WINAPI mxwriter_saxcontent_endElement(
if
(
This
->
element
&&
QName
&&
!
strncmpW
(
This
->
element
,
QName
,
nQName
))
{
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"/>"
);
write_o
utput
_b
uffer
(
This
,
"/>"
,
2
);
}
else
{
xmlChar
*
s
=
xmlchar_from_wcharn
(
QName
,
nQName
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
"</"
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
(
char
*
)
s
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
">"
);
write_o
utput
_b
uffer
(
This
,
"</"
,
2
);
write_o
utput
_b
uffer
_str
(
This
,
(
char
*
)
s
);
write_o
utput
_b
uffer
(
This
,
">"
,
1
);
heap_free
(
s
);
}
...
...
@@ -813,7 +830,7 @@ static HRESULT WINAPI mxwriter_saxcontent_characters(
if
(
nchars
)
{
xmlChar
*
s
=
xmlchar_from_wcharn
(
chars
,
nchars
);
xmlO
utput
B
uffer
WriteString
(
This
->
buffer
,
(
char
*
)
s
);
write_o
utput
_b
uffer
_str
(
This
,
(
char
*
)
s
);
heap_free
(
s
);
}
...
...
This diff is collapsed.
Click to expand it.
dlls/msxml3/tests/saxreader.c
+
29
−
0
View file @
a4b24978
...
...
@@ -2552,6 +2552,35 @@ static void test_mxwriter_stream(void)
"Got wrong content: %s
\n
"
,
wine_dbgstr_w
(
V_BSTR
(
&
dest
)));
VariantClear
(
&
dest
);
/* test when BOM is written to output stream */
V_VT
(
&
dest
)
=
VT_EMPTY
;
hr
=
IMXWriter_put_output
(
writer
,
dest
);
EXPECT_HR
(
hr
,
S_OK
);
pos
.
QuadPart
=
0
;
hr
=
IStream_Seek
(
stream
,
pos
,
STREAM_SEEK_SET
,
NULL
);
EXPECT_HR
(
hr
,
S_OK
);
V_VT
(
&
dest
)
=
VT_UNKNOWN
;
V_UNKNOWN
(
&
dest
)
=
(
IUnknown
*
)
stream
;
hr
=
IMXWriter_put_output
(
writer
,
dest
);
EXPECT_HR
(
hr
,
S_OK
);
hr
=
IMXWriter_put_byteOrderMark
(
writer
,
VARIANT_TRUE
);
EXPECT_HR
(
hr
,
S_OK
);
hr
=
IMXWriter_put_encoding
(
writer
,
_bstr_
(
"UTF-16"
));
EXPECT_HR
(
hr
,
S_OK
);
hr
=
ISAXContentHandler_startDocument
(
content
);
EXPECT_HR
(
hr
,
S_OK
);
pos
.
QuadPart
=
0
;
pos2
.
QuadPart
=
0
;
hr
=
IStream_Seek
(
stream
,
pos
,
STREAM_SEEK_CUR
,
&
pos2
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
pos2
.
QuadPart
==
2
,
"got wrong position
\n
"
);
ISAXContentHandler_Release
(
content
);
IMXWriter_Release
(
writer
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment