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
a68e51ce
Commit
a68e51ce
authored
Mar 30, 2017
by
Nikolay Sivov
Committed by
Alexandre Julliard
Apr 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Preserve original encoding name spelling in writer output.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ef023c3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
7 deletions
+56
-7
writer.c
dlls/xmllite/tests/writer.c
+29
-0
writer.c
dlls/xmllite/writer.c
+27
-7
No files found.
dlls/xmllite/tests/writer.c
View file @
a68e51ce
...
...
@@ -324,9 +324,12 @@ todo_wine
static
void
test_writestartdocument
(
void
)
{
static
const
char
fullprolog
[]
=
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?>"
;
static
const
char
*
prologversion2
=
"<?xml version=
\"
1.0
\"
encoding=
\"
uS-asCii
\"
?>"
;
static
const
char
prologversion
[]
=
"<?xml version=
\"
1.0
\"
?>"
;
static
const
WCHAR
versionW
[]
=
{
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
,
0
};
static
const
WCHAR
usasciiW
[]
=
{
'u'
,
'S'
,
'-'
,
'a'
,
's'
,
'C'
,
'i'
,
'i'
,
0
};
static
const
WCHAR
xmlW
[]
=
{
'x'
,
'm'
,
'l'
,
0
};
IXmlWriterOutput
*
output
;
IXmlWriter
*
writer
;
IStream
*
stream
;
HRESULT
hr
;
...
...
@@ -386,6 +389,32 @@ static void test_writestartdocument(void)
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
/* create with us-ascii */
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
output
=
NULL
;
hr
=
CreateXmlWriterOutputWithEncodingName
((
IUnknown
*
)
stream
,
NULL
,
usasciiW
,
&
output
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
CreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
output
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Omit
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
CHECK_OUTPUT
(
stream
,
prologversion2
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
IUnknown_Release
(
output
);
}
static
void
test_flush
(
void
)
...
...
dlls/xmllite/writer.c
View file @
a68e51ce
...
...
@@ -73,6 +73,7 @@ typedef struct
ISequentialStream
*
stream
;
IMalloc
*
imalloc
;
xml_encoding
encoding
;
WCHAR
*
encoding_name
;
/* exactly as specified on output creation */
struct
output_buffer
buffer
;
}
xmlwriteroutput
;
...
...
@@ -373,6 +374,14 @@ static HRESULT write_encoding_bom(xmlwriter *writer)
return
S_OK
;
}
static
const
WCHAR
*
get_output_encoding_name
(
xmlwriteroutput
*
output
)
{
if
(
output
->
encoding_name
)
return
output
->
encoding_name
;
return
get_encoding_name
(
output
->
encoding
);
}
static
HRESULT
write_xmldecl
(
xmlwriter
*
writer
,
XmlStandalone
standalone
)
{
static
const
WCHAR
versionW
[]
=
{
'<'
,
'?'
,
'x'
,
'm'
,
'l'
,
' '
,
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
};
...
...
@@ -387,7 +396,7 @@ static HRESULT write_xmldecl(xmlwriter *writer, XmlStandalone standalone)
/* encoding */
write_output_buffer
(
writer
->
output
,
encodingW
,
ARRAY_SIZE
(
encodingW
));
write_output_buffer_quoted
(
writer
->
output
,
get_
encoding_name
(
writer
->
output
->
encoding
),
-
1
);
write_output_buffer_quoted
(
writer
->
output
,
get_
output_encoding_name
(
writer
->
output
),
-
1
);
/* standalone */
if
(
standalone
==
XmlStandalone_Omit
)
...
...
@@ -1366,6 +1375,7 @@ static ULONG WINAPI xmlwriteroutput_Release(IXmlWriterOutput *iface)
if
(
This
->
output
)
IUnknown_Release
(
This
->
output
);
if
(
This
->
stream
)
ISequentialStream_Release
(
This
->
stream
);
free_output_buffer
(
This
);
writeroutput_free
(
This
,
This
->
encoding_name
);
writeroutput_free
(
This
,
This
);
if
(
imalloc
)
IMalloc_Release
(
imalloc
);
}
...
...
@@ -1420,8 +1430,8 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
return
S_OK
;
}
static
HRESULT
create_writer
(
IUnknown
*
stream
,
IMalloc
*
imalloc
,
xml_encoding
encoding
,
IXmlWriterOutput
**
output
)
static
HRESULT
create_writer
_output
(
IUnknown
*
stream
,
IMalloc
*
imalloc
,
xml_encoding
encoding
,
const
WCHAR
*
encoding_name
,
IXmlWriterOutput
**
output
)
{
xmlwriteroutput
*
writeroutput
;
HRESULT
hr
;
...
...
@@ -1432,12 +1442,14 @@ static HRESULT create_writer(IUnknown *stream, IMalloc *imalloc, xml_encoding en
writeroutput
=
IMalloc_Alloc
(
imalloc
,
sizeof
(
*
writeroutput
));
else
writeroutput
=
heap_alloc
(
sizeof
(
*
writeroutput
));
if
(
!
writeroutput
)
return
E_OUTOFMEMORY
;
if
(
!
writeroutput
)
return
E_OUTOFMEMORY
;
writeroutput
->
IXmlWriterOutput_iface
.
lpVtbl
=
&
xmlwriteroutputvtbl
;
writeroutput
->
ref
=
1
;
writeroutput
->
imalloc
=
imalloc
;
if
(
imalloc
)
IMalloc_AddRef
(
imalloc
);
if
(
imalloc
)
IMalloc_AddRef
(
imalloc
);
writeroutput
->
encoding
=
encoding
;
writeroutput
->
stream
=
NULL
;
hr
=
init_output_buffer
(
writeroutput
);
...
...
@@ -1446,6 +1458,14 @@ static HRESULT create_writer(IUnknown *stream, IMalloc *imalloc, xml_encoding en
return
hr
;
}
if
(
encoding_name
)
{
unsigned
int
size
=
(
strlenW
(
encoding_name
)
+
1
)
*
sizeof
(
WCHAR
);
writeroutput
->
encoding_name
=
writeroutput_alloc
(
writeroutput
,
size
);
memcpy
(
writeroutput
->
encoding_name
,
encoding_name
,
size
);
}
else
writeroutput
->
encoding_name
=
NULL
;
IUnknown_QueryInterface
(
stream
,
&
IID_IUnknown
,
(
void
**
)
&
writeroutput
->
output
);
*
output
=
&
writeroutput
->
IXmlWriterOutput_iface
;
...
...
@@ -1468,7 +1488,7 @@ HRESULT WINAPI CreateXmlWriterOutputWithEncodingName(IUnknown *stream,
if
(
!
stream
||
!
output
)
return
E_INVALIDARG
;
xml_enc
=
parse_encoding_name
(
encoding
?
encoding
:
utf8W
,
-
1
);
return
create_writer
(
stream
,
imalloc
,
xml_enc
,
output
);
return
create_writer
_output
(
stream
,
imalloc
,
xml_enc
,
encoding
,
output
);
}
HRESULT
WINAPI
CreateXmlWriterOutputWithEncodingCodePage
(
IUnknown
*
stream
,
...
...
@@ -1483,5 +1503,5 @@ HRESULT WINAPI CreateXmlWriterOutputWithEncodingCodePage(IUnknown *stream,
if
(
!
stream
||
!
output
)
return
E_INVALIDARG
;
xml_enc
=
get_encoding_from_codepage
(
codepage
);
return
create_writer
(
stream
,
imalloc
,
xml_enc
,
output
);
return
create_writer
_output
(
stream
,
imalloc
,
xml_enc
,
NULL
,
output
);
}
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