Refactor contents=0 behavior
Also change the error code to status_io_error
This commit is contained in:
parent
57ca94f897
commit
9749920c82
@ -4316,12 +4316,7 @@ PUGI__NS_BEGIN
|
|||||||
PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct* doc, xml_node_struct* root, void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t** out_buffer)
|
PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct* doc, xml_node_struct* root, void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t** out_buffer)
|
||||||
{
|
{
|
||||||
// check input buffer
|
// check input buffer
|
||||||
if ((contents==NULL) && (size!=0)) {
|
if (!contents && size) return make_parse_result(status_io_error);
|
||||||
xml_parse_result result;
|
|
||||||
result.status = status_no_document_element;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// get actual encoding
|
// get actual encoding
|
||||||
xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
|
xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size);
|
||||||
|
|||||||
@ -872,14 +872,16 @@ TEST(parse_load_buffer_null)
|
|||||||
{
|
{
|
||||||
xml_document doc;
|
xml_document doc;
|
||||||
|
|
||||||
CHECK(doc.load_buffer(0, 12).status == status_no_document_element && !doc.first_child());
|
CHECK(doc.load_buffer(0, 12).status == status_io_error && !doc.first_child());
|
||||||
|
CHECK(doc.load_buffer(0, 12, parse_fragment).status == status_io_error && !doc.first_child());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(parse_load_buffer_empty)
|
TEST(parse_load_buffer_empty)
|
||||||
{
|
{
|
||||||
xml_document doc;
|
xml_document doc;
|
||||||
|
|
||||||
CHECK(doc.load_buffer("foo", 0).status == status_no_document_element);
|
CHECK(doc.load_buffer("foo", 0).status == status_no_document_element && !doc.first_child());
|
||||||
|
CHECK(doc.load_buffer("foo", 0, parse_fragment) && !doc.first_child());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(parse_out_of_memory)
|
TEST(parse_out_of_memory)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user