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
b0f704da
Commit
b0f704da
authored
13 years ago
by
Nikolay Sivov
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
msxml3: Properly handle writer output in a form of BSTR.
parent
197d4115
No related branches found
Branches containing commit
No related tags found
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
+55
-32
55 additions, 32 deletions
dlls/msxml3/mxwriter.c
dlls/msxml3/tests/saxreader.c
+10
-3
10 additions, 3 deletions
dlls/msxml3/tests/saxreader.c
with
65 additions
and
35 deletions
dlls/msxml3/mxwriter.c
+
55
−
32
View file @
b0f704da
...
...
@@ -78,8 +78,8 @@ typedef struct _mxwriter
IStream
*
dest
;
ULONG
dest_written
;
INT
decl_count
;
/* practically how many times startDocument was called */
INT
decl_written
;
/* byte length of document prolog */
int
decl_count
;
/* practically how many times startDocument was called */
int
decl_written
;
/* byte length of document prolog */
xmlOutputBufferPtr
buffer
;
}
mxwriter
;
...
...
@@ -385,11 +385,6 @@ static HRESULT WINAPI mxwriter_put_output(IMXWriter *iface, VARIANT dest)
{
if
(
This
->
dest
)
IStream_Release
(
This
->
dest
);
This
->
dest
=
NULL
;
/* We need to reset the output buffer to UTF-16, since the only way
* the content of the mxwriter can be accessed now is through a BSTR.
*/
This
->
encoding
=
xmlParseCharEncoding
(
"UTF-16"
);
reset_output_buffer
(
This
);
break
;
}
...
...
@@ -427,48 +422,76 @@ static HRESULT WINAPI mxwriter_get_output(IMXWriter *iface, VARIANT *dest)
if
(
!
This
->
dest
)
{
BSTR
output
;
xmlOutputBufferPtr
prolog
;
BSTR
output
,
body
=
NULL
;
xmlBufferPtr
buffer
;
WCHAR
*
ptr
;
HRESULT
hr
;
int
i
;
hr
=
flush_output_buffer
(
This
);
if
(
FAILED
(
hr
))
return
hr
;
/* TODO: Windows always seems to re-encode the XML to UTF-16 (this includes
* updating the XML decl so it says "UTF-16" instead of "UTF-8"). We don't
* support this yet...
*/
if
(
This
->
encoding
==
XML_CHAR_ENCODING_UTF8
)
{
FIXME
(
"XML re-encoding not supported yet
\n
"
);
return
E_NOTIMPL
;
if
(
This
->
decl_count
)
{
prolog
=
xmlAllocOutputBuffer
(
xmlGetCharEncodingHandler
(
xmlParseCharEncoding
(
"UTF-16"
)));
write_prolog_buffer
(
This
,
xmlParseCharEncoding
(
"UTF-16"
),
prolog
);
}
else
prolog
=
NULL
;
if
(
This
->
decl_count
)
/* optimize some paticular cases */
/* 1. no prolog and UTF-8 buffer */
if
(
This
->
encoding
==
XML_CHAR_ENCODING_UTF8
&&
!
prolog
)
{
xmlOutputBufferPtr
prolog
;
INT
i
=
This
->
decl_count
;
WCHAR
*
ptr
;
V_VT
(
dest
)
=
VT_BSTR
;
V_BSTR
(
dest
)
=
bstr_from_xmlChar
(
This
->
buffer
->
buffer
->
content
);
return
S_OK
;
}
prolog
=
xmlAllocOutputBuffer
(
xmlGetCharEncodingHandler
(
xmlParseCharEncoding
(
"UTF-16"
)));
/* 2. no prolog and UTF-16 buffer */
if
(
!
prolog
)
{
V_VT
(
dest
)
=
VT_BSTR
;
V_BSTR
(
dest
)
=
SysAllocStringLen
((
const
WCHAR
*
)
This
->
buffer
->
conv
->
content
,
This
->
buffer
->
conv
->
use
/
sizeof
(
WCHAR
));
return
S_OK
;
}
write_prolog_buffer
(
This
,
xmlParseCharEncoding
(
"UTF-16"
),
prolog
)
;
V_BSTR
(
dest
)
=
NULL
;
if
(
This
->
encoding
==
XML_CHAR_ENCODING_UTF8
)
{
buffer
=
This
->
buffer
->
buffer
;
body
=
bstr_from_xmlChar
(
buffer
->
content
+
This
->
decl_written
);
ptr
=
output
=
SysAllocStringByteLen
(
NULL
,
prolog
->
conv
->
use
*
This
->
decl_count
+
This
->
buffer
->
conv
->
use
-
This
->
decl_written
);
while
(
i
--
)
{
memcpy
(
ptr
,
prolog
->
conv
->
content
,
prolog
->
conv
->
use
);
ptr
+=
prolog
->
conv
->
use
/
sizeof
(
WCHAR
);
}
memcpy
(
ptr
,
This
->
buffer
->
conv
->
content
+
This
->
decl_written
,
This
->
buffer
->
conv
->
use
-
This
->
decl_written
);
xmlOutputBufferClose
(
prolog
);
SysStringByteLen
(
body
));
}
else
{
output
=
SysAllocStringLen
((
const
WCHAR
*
)
This
->
buffer
->
conv
->
content
,
This
->
buffer
->
conv
->
use
/
sizeof
(
WCHAR
));
buffer
=
This
->
buffer
->
conv
;
ptr
=
output
=
SysAllocStringByteLen
(
NULL
,
prolog
->
conv
->
use
*
This
->
decl_count
+
buffer
->
use
-
This
->
decl_written
);
}
/* write prolog part */
i
=
This
->
decl_count
;
while
(
i
--
)
{
memcpy
(
ptr
,
prolog
->
conv
->
content
,
prolog
->
conv
->
use
);
ptr
+=
prolog
->
conv
->
use
/
sizeof
(
WCHAR
);
}
xmlOutputBufferClose
(
prolog
);
/* write main part */
if
(
body
)
{
memcpy
(
ptr
,
body
,
SysStringByteLen
(
body
));
SysFreeString
(
body
);
}
else
memcpy
(
ptr
,
buffer
->
content
+
This
->
decl_written
,
buffer
->
use
-
This
->
decl_written
);
V_VT
(
dest
)
=
VT_BSTR
;
V_BSTR
(
dest
)
=
output
;
...
...
This diff is collapsed.
Click to expand it.
dlls/msxml3/tests/saxreader.c
+
10
−
3
View file @
b0f704da
...
...
@@ -2303,6 +2303,13 @@ static void test_mxwriter_startendelement(void)
hr
=
IMXWriter_put_output
(
writer
,
dest
);
EXPECT_HR
(
hr
,
S_OK
);
V_VT
(
&
dest
)
=
VT_EMPTY
;
hr
=
IMXWriter_get_output
(
writer
,
&
dest
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
V_VT
(
&
dest
)
==
VT_BSTR
,
"got %d
\n
"
,
V_VT
(
&
dest
));
ok
(
!
lstrcmpW
(
_bstr_
(
""
),
V_BSTR
(
&
dest
)),
"got wrong content %s
\n
"
,
wine_dbgstr_w
(
V_BSTR
(
&
dest
)));
VariantClear
(
&
dest
);
hr
=
ISAXContentHandler_startDocument
(
content
);
EXPECT_HR
(
hr
,
S_OK
);
...
...
@@ -2615,9 +2622,9 @@ static void test_mxwriter_encoding(void)
*/
V_VT
(
&
dest
)
=
VT_EMPTY
;
hr
=
IMXWriter_get_output
(
writer
,
&
dest
);
todo_wine
ok
(
hr
==
S_OK
,
"get_output failed: %08x
\n
"
,
hr
);
todo_wine
ok
(
V_VT
(
&
dest
)
==
VT_BSTR
,
"Expected VT_BSTR, got %d
\n
"
,
V_VT
(
&
dest
));
if
(
V_VT
(
&
dest
)
==
VT_BSTR
)
todo_wine
ok
(
!
lstrcmpW
(
_bstr_
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-16
\"
standalone=
\"
no
\"
?>
\r\n
"
),
V_BSTR
(
&
dest
)),
EXPECT_HR
(
hr
,
S_OK
);
ok
(
V_VT
(
&
dest
)
==
VT_BSTR
,
"Expected VT_BSTR, got %d
\n
"
,
V_VT
(
&
dest
));
ok
(
!
lstrcmpW
(
_bstr_
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-16
\"
standalone=
\"
no
\"
?>
\r\n
"
),
V_BSTR
(
&
dest
)),
"got wrong content: %s
\n
"
,
wine_dbgstr_w
(
V_BSTR
(
&
dest
)));
VariantClear
(
&
dest
);
...
...
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