[XMLLITE] Sync with Wine Staging 2.9. CORE-13362

707ab55 xmllite/writer: Fix IID argument handling in CreateXmlWriter().
d1e1457 xmllite/reader: Fix IID argument handling in CreateXmlReader().
a68e51c xmllite/writer: Preserve original encoding name spelling in writer output.
ef023c3 xmllite: Recognize us-ascii encoding.
9506e7d xmllite: Return local name stored in namespace for prefixed namespace attribute values.
1b9b791 xmllite: Allocate value in reader_add_attr.
daf0504 xmllite: Allow reading from allocated strings in ReadValueChunk.
f862222 xmllite: Store allocated copy of local name in attribute struct and use that instead of StringValue_LocalName.
004d615 xmllite: Don't use StringValue_LocalName for element nodes.
6917e2a xmllite: Clear all parser values in SetInput.
291ffdd xmllite: Don't fail in readerinput_detectencoding if input buffer has 3 bytes.
536ed3f xmllite: Return empty value for end element and none nodes.
48fff1b xmllite: Replace crln in input buffer with nl.
2b5203b xmllite: Fixed ReadValueChunk implementation.
a3d7806 xmllite: Fixed buffer handling in reader_parse_reference.
68aeee4 xmllite: Return WC_E_SYNTAX if there is unexpected data in the end of the stream.
253f233 xmllite/reader: Return same string for local and qualified names for attributes when appropriate.
d7057a3 xmllite/reader: For elements without a prefix return same string for both local and qualified names.
1e015f1 xmllite/reader: Always return local name from element structure.
876de4a xmllite/reader: Reset reader nesting depth on error.
ec9e05c xmllite/reader: Enter error state on parsing error.
b115e96 xmllite/reader: Improve returned position for whitespace text nodes.
9685fec xmllite/reader: Improve line number updating when switching to the next line.
79a6567 xmllite/reader: Fix position methods return values in closed reader state.
62a41d0 xmllite/reader: Return correct error for multiple colons in qualified name.
3b83a44 xmllite/reader: Explicitly return empty string as qualified name for some node types.
52f9193 xmllite/reader: Explicitly return empty static string as local name for nodes without names.
1ccc1f2 xmllite/reader: Return static empty string as xml declaration node value.
65e62c3 xmllite/reader: Fix reader position returned for xml declaration node.
6cf9524 xmllite/reader: Improve returned reader position for elements and attributes.
e1c31e1 xmllite/reader: Remove redundant parameter.
d3319f6 xmllite/reader: Return prefixes from namespace stack.
b57589a xmllite/reader: Return qualified element names from the stack, instead of input buffer.
3ae1043 xmllite/reader: Return local element names from the stack, instead of input buffer.
3697bd9 xmllite/reader: Return empty string for namespace uri for some nodes.
63c489f xmllite/reader: Fix GetValue() for comments.
71a0733 xmllite/reader: Enforce maximum element depth limit.
ce84b20 xmllite/reader: Return qualified names for attributes.
3fe5f25 xmllite/reader: Fix prefix returned after moving back to element.
70028b7 xmllite/reader: Return empty value for elements.
7c44c65 xmllite/reader: Return proper name for xml declaration PI.
8f0c235 xmllite/reader: Improve the way nesting level returned by GetDepth() is updated.
073c43a xmllite/reader: Implement IsEOF().
b188079 xmllite/reader: Reset node type to XmlNodeType_None on EOF.
0cbd938 xmllite/reader: Always return node type from Read().
80cf883 xmllite/reader: Improve input stream encoding detection.
5b78cc9 xmllite/writer: Fix Release() trace.
9c988e7 xmllite/writer: Implement WriteString().
107615d xmllite/reader: Fix writing back resolved character reference value.
05956e6 xmllite: Fix CreateXmlReaderInputWithEncodingName spec file entry.
d369857c xmllite: Add __WINE_ALLOC_SIZE attributes to heap_xxx() functions.

svn path=/trunk/; revision=74872
This commit is contained in:
Amine Khaldi 2017-06-04 01:49:43 +00:00
parent 6f73f34dab
commit 17e927e7e5
5 changed files with 698 additions and 304 deletions

File diff suppressed because it is too large Load diff

View file

@ -63,6 +63,7 @@ typedef struct
ISequentialStream *stream;
IMalloc *imalloc;
xml_encoding encoding;
WCHAR *encoding_name; /* exactly as specified on output creation */
struct output_buffer buffer;
} xmlwriteroutput;
@ -363,6 +364,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','"'};
@ -377,7 +386,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)
@ -439,11 +448,17 @@ static HRESULT WINAPI xmlwriter_QueryInterface(IXmlWriter *iface, REFIID riid, v
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IXmlWriter))
if (IsEqualGUID(riid, &IID_IXmlWriter) ||
IsEqualGUID(riid, &IID_IUnknown))
{
*ppvObject = iface;
}
else
{
FIXME("interface %s is not supported\n", debugstr_guid(riid));
*ppvObject = NULL;
return E_NOINTERFACE;
}
IXmlWriter_AddRef(iface);
@ -463,7 +478,7 @@ static ULONG WINAPI xmlwriter_Release(IXmlWriter *iface)
xmlwriter *This = impl_from_IXmlWriter(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->>(%u)\n", This, ref);
TRACE("(%p)->(%u)\n", This, ref);
if (ref == 0) {
struct element *element, *element2;
@ -1193,16 +1208,49 @@ static HRESULT WINAPI xmlwriter_WriteStartElement(IXmlWriter *iface, LPCWSTR pre
return S_OK;
}
static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, LPCWSTR pwszText)
static void write_escaped_string(xmlwriter *writer, const WCHAR *string)
{
static const WCHAR ampW[] = {'&','a','m','p',';'};
static const WCHAR ltW[] = {'&','l','t',';'};
static const WCHAR gtW[] = {'&','g','t',';'};
while (*string)
{
switch (*string)
{
case '<':
write_output_buffer(writer->output, ltW, ARRAY_SIZE(ltW));
break;
case '&':
write_output_buffer(writer->output, ampW, ARRAY_SIZE(ampW));
break;
case '>':
write_output_buffer(writer->output, gtW, ARRAY_SIZE(gtW));
break;
default:
write_output_buffer(writer->output, string, 1);
}
string++;
}
}
static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, const WCHAR *string)
{
xmlwriter *This = impl_from_IXmlWriter(iface);
FIXME("%p %s\n", This, wine_dbgstr_w(pwszText));
TRACE("%p %s\n", This, debugstr_w(string));
if (!string)
return S_OK;
switch (This->state)
{
case XmlWriterState_Initial:
return E_UNEXPECTED;
case XmlWriterState_ElemStarted:
writer_close_starttag(This);
break;
case XmlWriterState_Ready:
case XmlWriterState_DocClosed:
This->state = XmlWriterState_DocClosed;
@ -1211,7 +1259,8 @@ static HRESULT WINAPI xmlwriter_WriteString(IXmlWriter *iface, LPCWSTR pwszText)
;
}
return E_NOTIMPL;
write_escaped_string(This, string);
return S_OK;
}
static HRESULT WINAPI xmlwriter_WriteSurrogateCharEntity(IXmlWriter *iface, WCHAR wchLow, WCHAR wchHigh)
@ -1322,6 +1371,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);
}
@ -1339,15 +1389,10 @@ static const struct IUnknownVtbl xmlwriteroutputvtbl =
HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
{
xmlwriter *writer;
HRESULT hr;
TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc);
if (!IsEqualGUID(riid, &IID_IXmlWriter))
{
ERR("Unexpected IID requested -> (%s)\n", wine_dbgstr_guid(riid));
return E_FAIL;
}
if (imalloc)
writer = IMalloc_Alloc(imalloc, sizeof(*writer));
else
@ -1369,15 +1414,16 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
writer->starttagopen = FALSE;
list_init(&writer->elements);
*obj = &writer->IXmlWriter_iface;
hr = IXmlWriter_QueryInterface(&writer->IXmlWriter_iface, riid, obj);
IXmlWriter_Release(&writer->IXmlWriter_iface);
TRACE("returning iface %p\n", *obj);
TRACE("returning iface %p, hr %#x\n", *obj, hr);
return S_OK;
return hr;
}
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;
@ -1388,12 +1434,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);
@ -1402,6 +1450,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;
@ -1424,7 +1480,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,
@ -1439,5 +1495,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);
}

View file

@ -1,6 +1,6 @@
@ stdcall CreateXmlReader(ptr ptr ptr)
@ stub CreateXmlReaderInputWithEncodingCodePage
@ stdcall CreateXmlReaderInputWithEncodingName(ptr ptr ptr long ptr ptr)
@ stdcall CreateXmlReaderInputWithEncodingName(ptr ptr wstr long wstr ptr)
@ stdcall CreateXmlWriter(ptr ptr ptr)
@ stdcall CreateXmlWriterOutputWithEncodingCodePage(ptr ptr long ptr)
@ stdcall CreateXmlWriterOutputWithEncodingName(ptr ptr wstr ptr)

View file

@ -40,14 +40,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(xmllite);
/* memory allocation functions */
static inline void *heap_alloc(size_t len)
static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
{
return HeapAlloc(GetProcessHeap(), 0, len);
return HeapAlloc(GetProcessHeap(), 0, size);
}
static inline void *heap_realloc(void *mem, size_t len)
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
return HeapReAlloc(GetProcessHeap(), 0, mem, size);
}
static inline BOOL heap_free(void *mem)
@ -81,6 +82,7 @@ static inline void m_free(IMalloc *imalloc, void *mem)
typedef enum
{
XmlEncoding_USASCII,
XmlEncoding_UTF16,
XmlEncoding_UTF8,
XmlEncoding_Unknown

View file

@ -218,7 +218,7 @@ reactos/dll/win32/xinput1_1 # Synced to WineStaging-1.9.11
reactos/dll/win32/xinput1_2 # Synced to WineStaging-1.9.11
reactos/dll/win32/xinput1_3 # Synced to WineStaging-2.2
reactos/dll/win32/xinput9_1_0 # Synced to WineStaging-1.9.11
reactos/dll/win32/xmllite # Synced to WineStaging-2.2
reactos/dll/win32/xmllite # Synced to WineStaging-2.9
reactos/dll/cpl/inetcpl # Synced to WineStaging-1.9.11