xmllite/reader: Return local element names from the stack, instead of input buffer.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3697bd9acf
commit
3ae1043fc1
|
@ -2260,7 +2260,7 @@ static HRESULT reader_parse_element(xmlreader *reader)
|
|||
static HRESULT reader_parse_endtag(xmlreader *reader)
|
||||
{
|
||||
strval prefix, local, qname;
|
||||
struct element *elem;
|
||||
struct element *element;
|
||||
HRESULT hr;
|
||||
|
||||
/* skip '</' */
|
||||
|
@ -2278,12 +2278,12 @@ static HRESULT reader_parse_endtag(xmlreader *reader)
|
|||
|
||||
/* Element stack should never be empty at this point, cause we shouldn't get to
|
||||
content parsing if it's empty. */
|
||||
elem = LIST_ENTRY(list_head(&reader->elements), struct element, entry);
|
||||
if (!strval_eq(reader, &elem->qname, &qname)) return WC_E_ELEMENTMATCH;
|
||||
element = LIST_ENTRY(list_head(&reader->elements), struct element, entry);
|
||||
if (!strval_eq(reader, &element->qname, &qname)) return WC_E_ELEMENTMATCH;
|
||||
|
||||
reader->nodetype = XmlNodeType_EndElement;
|
||||
reader->is_empty_element = FALSE;
|
||||
reader_set_strvalue(reader, StringValue_Prefix, &prefix);
|
||||
reader_set_strvalue(reader, StringValue_LocalName, &local);
|
||||
reader_set_strvalue(reader, StringValue_QualifiedName, &qname);
|
||||
|
||||
return S_OK;
|
||||
|
@ -3031,10 +3031,35 @@ static HRESULT WINAPI xmlreader_GetNamespaceUri(IXmlReader* iface, const WCHAR *
|
|||
static HRESULT WINAPI xmlreader_GetLocalName(IXmlReader* iface, LPCWSTR *name, UINT *len)
|
||||
{
|
||||
xmlreader *This = impl_from_IXmlReader(iface);
|
||||
XmlNodeType nodetype;
|
||||
UINT length;
|
||||
|
||||
TRACE("(%p)->(%p %p)\n", This, name, len);
|
||||
*name = This->strvalues[StringValue_LocalName].str;
|
||||
if (len) *len = This->strvalues[StringValue_LocalName].len;
|
||||
|
||||
if (!len)
|
||||
len = &length;
|
||||
|
||||
switch ((nodetype = reader_get_nodetype(This)))
|
||||
{
|
||||
case XmlNodeType_Element:
|
||||
case XmlNodeType_EndElement:
|
||||
/* empty elements are not added to the stack */
|
||||
if (!This->is_empty_element)
|
||||
{
|
||||
struct element *element;
|
||||
|
||||
element = LIST_ENTRY(list_head(&This->elements), struct element, entry);
|
||||
*name = element->localname.str;
|
||||
*len = element->localname.len;
|
||||
break;
|
||||
}
|
||||
/* fallthrough */
|
||||
default:
|
||||
*name = This->strvalues[StringValue_LocalName].str;
|
||||
*len = This->strvalues[StringValue_LocalName].len;
|
||||
break;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -2148,6 +2148,7 @@ static void test_namespaceuri(void)
|
|||
while (IXmlReader_Read(reader, &type) == S_OK) {
|
||||
const WCHAR *uri, *local;
|
||||
WCHAR *uriW;
|
||||
UINT length;
|
||||
|
||||
ok(type == XmlNodeType_Element ||
|
||||
type == XmlNodeType_Text ||
|
||||
|
@ -2158,8 +2159,17 @@ static void test_namespaceuri(void)
|
|||
type == XmlNodeType_EndElement ||
|
||||
type == XmlNodeType_XmlDeclaration, "Unexpected node type %d.\n", type);
|
||||
|
||||
hr = IXmlReader_GetLocalName(reader, &local, NULL);
|
||||
local = NULL;
|
||||
length = 0;
|
||||
hr = IXmlReader_GetLocalName(reader, &local, &length);
|
||||
ok(hr == S_OK, "S_OK, got %08x\n", hr);
|
||||
ok(local != NULL, "Unexpected NULL local name pointer\n");
|
||||
|
||||
if (type == XmlNodeType_Element || type == XmlNodeType_EndElement)
|
||||
{
|
||||
ok(*local != 0, "Unexpected empty local name\n");
|
||||
ok(length > 0, "Unexpected local name length\n");
|
||||
}
|
||||
|
||||
uri = NULL;
|
||||
hr = IXmlReader_GetNamespaceUri(reader, &uri, NULL);
|
||||
|
|
Loading…
Reference in New Issue