From 50797a803db9c72867be7fb3aac37a692a5b744b Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 3 Feb 2016 15:43:45 +0100 Subject: [PATCH] webservices: Support more writer states in WsWriteText. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/writer.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c index dafeb2415a3..95f565d664a 100644 --- a/dlls/webservices/writer.c +++ b/dlls/webservices/writer.c @@ -794,27 +794,32 @@ static inline void write_set_attribute_value( struct writer *writer, WS_XML_TEXT HRESULT WINAPI WsWriteText( WS_XML_WRITER *handle, const WS_XML_TEXT *text, WS_ERROR *error ) { struct writer *writer = (struct writer *)handle; - WS_XML_UTF8_TEXT *src, *dst; + WS_XML_UTF8_TEXT *dst, *src = (WS_XML_UTF8_TEXT *)text; + HRESULT hr; TRACE( "%p %p %p\n", handle, text, error ); if (!writer || !text) return E_INVALIDARG; - if (writer->state != WRITER_STATE_STARTATTRIBUTE) - { - FIXME( "can't handle writer state %u\n", writer->state ); - return E_NOTIMPL; - } if (text->textType != WS_XML_TEXT_TYPE_UTF8) { FIXME( "text type %u not supported\n", text->textType ); return E_NOTIMPL; } - src = (WS_XML_UTF8_TEXT *)text; - if (!(dst = alloc_utf8_text( src->value.bytes, src->value.length ))) - return E_OUTOFMEMORY; - write_set_attribute_value( writer, &dst->text ); + if (writer->state == WRITER_STATE_STARTATTRIBUTE) + { + if (!(dst = alloc_utf8_text( src->value.bytes, src->value.length ))) + return E_OUTOFMEMORY; + + write_set_attribute_value( writer, &dst->text ); + } + else + { + if ((hr = write_grow_buffer( writer, src->value.length )) != S_OK) return hr; + write_bytes( writer, src->value.bytes, src->value.length ); + } + return S_OK; }