Merge branch 'dinghao188-dev' of https://github.com/dinghao188/tinyxml2 into dinghao188-dinghao188-dev

This commit is contained in:
Lee Thomason
2023-01-14 17:41:42 -08:00
2 changed files with 9 additions and 3 deletions

View File

@@ -1084,7 +1084,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
StrPair endTag; StrPair endTag;
p = node->ParseDeep( p, &endTag, curLineNumPtr ); p = node->ParseDeep( p, &endTag, curLineNumPtr );
if ( !p ) { if ( !p ) {
DeleteNode( node ); _document->DeleteNode( node );
if ( !_document->Error() ) { if ( !_document->Error() ) {
_document->SetError( XML_ERROR_PARSING, initialLineNum, 0); _document->SetError( XML_ERROR_PARSING, initialLineNum, 0);
} }
@@ -1117,7 +1117,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
} }
if ( !wellLocated ) { if ( !wellLocated ) {
_document->SetError( XML_ERROR_PARSING_DECLARATION, initialLineNum, "XMLDeclaration value=%s", decl->Value()); _document->SetError( XML_ERROR_PARSING_DECLARATION, initialLineNum, "XMLDeclaration value=%s", decl->Value());
DeleteNode( node ); _document->DeleteNode( node );
break; break;
} }
} }
@@ -1152,7 +1152,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
} }
if ( mismatch ) { if ( mismatch ) {
_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, initialLineNum, "XMLElement name=%s", ele->Name()); _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, initialLineNum, "XMLElement name=%s", ele->Name());
DeleteNode( node ); _document->DeleteNode( node );
break; break;
} }
} }

View File

@@ -2149,6 +2149,12 @@ int main( int argc, const char ** argv )
XMLTest( "Should be no error initially", false, doc.Error() ); XMLTest( "Should be no error initially", false, doc.Error() );
doc.LoadFile( "resources/no-such-file.xml" ); doc.LoadFile( "resources/no-such-file.xml" );
XMLTest( "No such file - should fail", true, doc.Error() ); XMLTest( "No such file - should fail", true, doc.Error() );
doc.LoadFile( "resources/xmltest-5330.xml" );
XMLTest( "parse errors occur - should fail", true, doc.Error() );
doc.LoadFile( "resources/dream.xml" );
XMLTest( "Error should be cleared", false, doc.Error() );
doc.LoadFile( "resources/dream.xml" ); doc.LoadFile( "resources/dream.xml" );
XMLTest( "Error should be cleared", false, doc.Error() ); XMLTest( "Error should be cleared", false, doc.Error() );