Commit d7057a34 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite/reader: For elements without a prefix return same string for both local…

xmllite/reader: For elements without a prefix return same string for both local and qualified names. Signed-off-by: 's avatarNikolay Sivov <nsivov@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 1e015f1e
...@@ -490,6 +490,7 @@ static void reader_clear_elements(xmlreader *reader) ...@@ -490,6 +490,7 @@ static void reader_clear_elements(xmlreader *reader)
} }
list_init(&reader->elements); list_init(&reader->elements);
reader_free_strvalued(reader, &reader->empty_element.localname); reader_free_strvalued(reader, &reader->empty_element.localname);
reader_free_strvalued(reader, &reader->empty_element.qname);
reader->is_empty_element = FALSE; reader->is_empty_element = FALSE;
} }
...@@ -2227,10 +2228,11 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca ...@@ -2227,10 +2228,11 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca
/* skip '/>' */ /* skip '/>' */
reader_skipn(reader, 2); reader_skipn(reader, 2);
reader_free_strvalued(reader, &element->qname);
reader_free_strvalued(reader, &element->localname); reader_free_strvalued(reader, &element->localname);
element->prefix = *prefix; element->prefix = *prefix;
element->qname = *qname; reader_strvaldup(reader, qname, &element->qname);
reader_strvaldup(reader, local, &element->localname); reader_strvaldup(reader, local, &element->localname);
element->position = position; element->position = position;
reader_mark_ns_nodes(reader, element); reader_mark_ns_nodes(reader, element);
...@@ -2980,6 +2982,7 @@ static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface) ...@@ -2980,6 +2982,7 @@ static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *name, UINT *len) static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *name, UINT *len)
{ {
xmlreader *This = impl_from_IXmlReader(iface); xmlreader *This = impl_from_IXmlReader(iface);
struct element *element;
UINT length; UINT length;
TRACE("(%p)->(%p %p)\n", This, name, len); TRACE("(%p)->(%p %p)\n", This, name, len);
...@@ -2998,14 +3001,18 @@ static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *nam ...@@ -2998,14 +3001,18 @@ static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *nam
break; break;
case XmlNodeType_Element: case XmlNodeType_Element:
case XmlNodeType_EndElement: case XmlNodeType_EndElement:
if (!This->is_empty_element) element = reader_get_element(This);
if (element->prefix.len)
{ {
struct element *element = reader_get_element(This);
*name = element->qname.str; *name = element->qname.str;
*len = element->qname.len; *len = element->qname.len;
break;
} }
/* fallthrough */ else
{
*name = element->localname.str;
*len = element->localname.len;
}
break;
default: default:
*name = This->strvalues[StringValue_QualifiedName].str; *name = This->strvalues[StringValue_QualifiedName].str;
*len = This->strvalues[StringValue_QualifiedName].len; *len = This->strvalues[StringValue_QualifiedName].len;
......
...@@ -1494,6 +1494,8 @@ static void test_read_element(void) ...@@ -1494,6 +1494,8 @@ static void test_read_element(void)
i = 0; i = 0;
while (IXmlReader_Read(reader, &type) == S_OK) while (IXmlReader_Read(reader, &type) == S_OK)
{ {
UINT count;
ok(type == XmlNodeType_Element || type == XmlNodeType_EndElement || ok(type == XmlNodeType_Element || type == XmlNodeType_EndElement ||
type == XmlNodeType_Text, "Unexpected node type %d\n", type); type == XmlNodeType_Text, "Unexpected node type %d\n", type);
...@@ -1502,10 +1504,44 @@ static void test_read_element(void) ...@@ -1502,10 +1504,44 @@ static void test_read_element(void)
ok(hr == S_OK, "got %08x\n", hr); ok(hr == S_OK, "got %08x\n", hr);
ok(depth == depths[i], "%u: got depth %u, expected %u\n", i, depth, depths[i]); ok(depth == depths[i], "%u: got depth %u, expected %u\n", i, depth, depths[i]);
if (type == XmlNodeType_Element) if (type == XmlNodeType_Element || type == XmlNodeType_EndElement)
{
const WCHAR *prefix;
prefix = NULL;
hr = IXmlReader_GetPrefix(reader, &prefix, NULL);
ok(hr == S_OK, "got %08x\n", hr);
ok(prefix != NULL, "got %p\n", prefix);
if (!*prefix)
{
const WCHAR *local, *qname;
local = NULL;
hr = IXmlReader_GetLocalName(reader, &local, NULL);
ok(hr == S_OK, "got %08x\n", hr);
ok(local != NULL, "got %p\n", local);
qname = NULL;
hr = IXmlReader_GetQualifiedName(reader, &qname, NULL);
ok(hr == S_OK, "got %08x\n", hr);
ok(qname != NULL, "got %p\n", qname);
ok(local == qname, "expected same pointer\n");
}
}
if (type == XmlNodeType_EndElement)
{ {
UINT count = 0; count = 1;
hr = IXmlReader_GetAttributeCount(reader, &count);
ok(hr == S_OK, "got %08x\n", hr);
ok(count == 0, "got %u\n", count);
}
if (type == XmlNodeType_Element)
{
count = 0;
hr = IXmlReader_GetAttributeCount(reader, &count); hr = IXmlReader_GetAttributeCount(reader, &count);
ok(hr == S_OK, "got %08x\n", hr); ok(hr == S_OK, "got %08x\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment