From d5255f51b2e0fe5e7e7fb0c4c520ccd5ee65b0af Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 2 Mar 2016 14:06:26 +0100 Subject: [PATCH] webservices: Move the reader to EOF at end of data in WsReadEndElement. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/reader.c | 10 ++++ dlls/webservices/tests/reader.c | 84 +++++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index db68733d5d1..7abbf3cb796 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -1194,6 +1194,16 @@ static HRESULT read_endelement( struct reader *reader ) WS_XML_STRING *prefix, *localname; HRESULT hr; + if (reader->state == READER_STATE_EOF) return WS_E_INVALID_FORMAT; + + if (read_end_of_data( reader )) + { + struct list *eof = list_tail( &reader->root->children ); + reader->current = LIST_ENTRY( eof, struct node, entry ); + reader->state = READER_STATE_EOF; + return S_OK; + } + if (read_cmp( reader, "nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType ); hr = WsReadEndElement( reader, NULL ); ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); @@ -904,6 +904,7 @@ static void test_WsReadEndElement(void) HRESULT hr; WS_XML_READER *reader; const WS_XML_NODE *node; + int found; hr = WsCreateReader( NULL, 0, &reader, NULL ) ; ok( hr == S_OK, "got %08x\n", hr ); @@ -976,11 +977,11 @@ static void test_WsReadEndElement(void) /* WsReadEndElement advances reader to EOF */ hr = WsReadEndElement( reader, NULL ); - todo_wine ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08x\n", hr ); hr = WsGetReaderNode( reader, &node, NULL ); ok( hr == S_OK, "got %08x\n", hr ); - todo_wine if (node) ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType ); hr = WsReadEndElement( reader, NULL ); ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); @@ -1009,6 +1010,79 @@ static void test_WsReadEndElement(void) hr = WsReadEndElement( reader, NULL ); ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + + hr = set_input( reader, "", sizeof("") - 1 ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsFillReader( reader, sizeof("") - 1, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + found = -1; + hr = WsReadToStartElement( reader, NULL, NULL, &found, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( found == TRUE, "got %d\n", found ); + + hr = WsGetReaderNode( reader, &node, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_ELEMENT, "got %u\n", node->nodeType ); + + hr = WsReadEndElement( reader, NULL ); + ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + + hr = set_input( reader, "", sizeof("") - 1 ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsFillReader( reader, sizeof("") - 1, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + found = -1; + hr = WsReadToStartElement( reader, NULL, NULL, &found, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( found == TRUE, "got %d\n", found ); + + hr = WsGetReaderNode( reader, &node, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_ELEMENT, "got %u\n", node->nodeType ); + + hr = WsReadStartElement( reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsGetReaderNode( reader, &node, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_END_ELEMENT, "got %u\n", node->nodeType ); + + hr = WsReadEndElement( reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsGetReaderNode( reader, &node, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_EOF, "got %u\n", node->nodeType ); + + hr = set_input( reader, "", sizeof("") - 1 ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsFillReader( reader, sizeof("") - 1, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + found = -1; + hr = WsReadToStartElement( reader, NULL, NULL, &found, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( found == TRUE, "got %d\n", found ); + + hr = WsGetReaderNode( reader, &node, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_ELEMENT, "got %u\n", node->nodeType ); + + hr = WsReadStartElement( reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsGetReaderNode( reader, &node, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + if (node) ok( node->nodeType == WS_XML_NODE_TYPE_END_ELEMENT, "got %u\n", node->nodeType ); + + hr = WsReadEndElement( reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + WsFreeReader( reader ); } @@ -2134,7 +2208,7 @@ static void test_WsGetNamespaceFromPrefix(void) hr = WsReadStartElement( reader, NULL ); ok( hr == S_OK, "got %08x\n", hr ); hr = WsReadEndElement( reader, NULL ); - todo_wine ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08x\n", hr ); hr = WsGetNamespaceFromPrefix( reader, &prefix, TRUE, &ns, NULL ); todo_wine ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );