Commit 619ceae9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Support resuming and value reporting for whitespace nodes in Misc.

parent 146ff491
...@@ -68,7 +68,8 @@ typedef enum ...@@ -68,7 +68,8 @@ typedef enum
XmlReadResumeState_CDATA, XmlReadResumeState_CDATA,
XmlReadResumeState_Comment, XmlReadResumeState_Comment,
XmlReadResumeState_STag, XmlReadResumeState_STag,
XmlReadResumeState_CharData XmlReadResumeState_CharData,
XmlReadResumeState_Whitespace
} XmlReaderResumeState; } XmlReaderResumeState;
/* saved pointer index to resume from particular input position */ /* saved pointer index to resume from particular input position */
...@@ -962,11 +963,11 @@ static inline BOOL is_wchar_space(WCHAR ch) ...@@ -962,11 +963,11 @@ static inline BOOL is_wchar_space(WCHAR ch)
static int reader_skipspaces(xmlreader *reader) static int reader_skipspaces(xmlreader *reader)
{ {
encoded_buffer *buffer = &reader->input->buffer->utf16; encoded_buffer *buffer = &reader->input->buffer->utf16;
const WCHAR *ptr = reader_get_ptr(reader), *start = ptr; const WCHAR *ptr = reader_get_ptr(reader);
UINT start = reader_get_cur(reader);
while (is_wchar_space(*ptr)) while (is_wchar_space(*ptr))
{ {
buffer->cur++;
if (*ptr == '\r') if (*ptr == '\r')
reader->pos = 0; reader->pos = 0;
else if (*ptr == '\n') else if (*ptr == '\n')
...@@ -976,10 +977,12 @@ static int reader_skipspaces(xmlreader *reader) ...@@ -976,10 +977,12 @@ static int reader_skipspaces(xmlreader *reader)
} }
else else
reader->pos++; reader->pos++;
ptr++;
buffer->cur++;
ptr = reader_get_ptr(reader);
} }
return ptr - start; return reader_get_cur(reader) - start;
} }
/* [26] VersionNum ::= '1.' [0-9]+ */ /* [26] VersionNum ::= '1.' [0-9]+ */
...@@ -1488,19 +1491,34 @@ static HRESULT reader_parse_pi(xmlreader *reader) ...@@ -1488,19 +1491,34 @@ static HRESULT reader_parse_pi(xmlreader *reader)
/* This one is used to parse significant whitespace nodes, like in Misc production */ /* This one is used to parse significant whitespace nodes, like in Misc production */
static HRESULT reader_parse_whitespace(xmlreader *reader) static HRESULT reader_parse_whitespace(xmlreader *reader)
{ {
WCHAR *start, *ptr; switch (reader->resumestate)
{
case XmlReadResumeState_Initial:
reader_shrink(reader);
reader->resumestate = XmlReadResumeState_Whitespace;
reader->resume[XmlReadResume_Body] = reader_get_cur(reader);
reader->nodetype = XmlNodeType_Whitespace;
reader_set_strvalue(reader, StringValue_LocalName, &strval_empty);
reader_set_strvalue(reader, StringValue_QualifiedName, &strval_empty);
reader_set_strvalue(reader, StringValue_Value, &strval_empty);
case XmlReadResumeState_Whitespace:
{
strval value;
UINT start;
reader_shrink(reader); reader_skipspaces(reader);
start = reader_get_ptr(reader); if (is_reader_pending(reader)) return S_OK;
reader_skipspaces(reader); start = reader->resume[XmlReadResume_Body];
ptr = reader_get_ptr(reader); reader_init_strvalue(start, reader_get_cur(reader)-start, &value);
TRACE("%s\n", debugstr_wn(start, ptr-start)); reader_set_strvalue(reader, StringValue_Value, &value);
TRACE("%s\n", debug_strval(reader, &value));
reader->resumestate = XmlReadResumeState_Initial;
}
default:
;
}
reader->nodetype = XmlNodeType_Whitespace;
reader_set_strvalue(reader, StringValue_LocalName, &strval_empty);
reader_set_strvalue(reader, StringValue_QualifiedName, &strval_empty);
reader_set_strvalue(reader, StringValue_Value, &strval_empty);
return S_OK; return S_OK;
} }
...@@ -1522,6 +1540,8 @@ static HRESULT reader_parse_misc(xmlreader *reader) ...@@ -1522,6 +1540,8 @@ static HRESULT reader_parse_misc(xmlreader *reader)
return reader_parse_pi(reader); return reader_parse_pi(reader);
case XmlReadResumeState_Comment: case XmlReadResumeState_Comment:
return reader_parse_comment(reader); return reader_parse_comment(reader);
case XmlReadResumeState_Whitespace:
return reader_parse_whitespace(reader);
default: default:
ERR("unknown resume state %d\n", reader->resumestate); ERR("unknown resume state %d\n", reader->resumestate);
} }
......
...@@ -1000,6 +1000,15 @@ static void test_read_full(void) ...@@ -1000,6 +1000,15 @@ static void test_read_full(void)
ok(test->types[i] != XmlNodeType_None, "%d: unexpected end of test data\n", i); ok(test->types[i] != XmlNodeType_None, "%d: unexpected end of test data\n", i);
if (test->types[i] == XmlNodeType_None) break; if (test->types[i] == XmlNodeType_None) break;
ok(type == test->types[i], "%d: got wrong type %d, expected %d\n", i, type, test->types[i]); ok(type == test->types[i], "%d: got wrong type %d, expected %d\n", i, type, test->types[i]);
if (type == XmlNodeType_Whitespace)
{
const WCHAR *ptr;
UINT len = 0;
hr = IXmlReader_GetValue(reader, &ptr, &len);
ok(hr == S_OK, "%d: GetValue failed 0x%08x\n", i, hr);
ok(len > 0, "%d: wrong value length %d\n", i, len);
}
hr = IXmlReader_Read(reader, &type); hr = IXmlReader_Read(reader, &type);
i++; i++;
} }
......
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