Updating tinyxml to 2.6.1 (fixes small xml issues).

This commit is contained in:
lotodore
2010-10-11 16:09:14 +00:00
parent 972f678730
commit 845bf979dc
7 changed files with 410 additions and 359 deletions
+51 -22
View File
@@ -346,7 +346,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
continue;
}
if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space.
if ( IsWhiteSpace( *p ) ) // Still using old rules for white space.
++p;
else
break;
@@ -354,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
}
else
{
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
while ( *p && IsWhiteSpace( *p ) )
++p;
}
@@ -631,7 +631,7 @@ const char* TiXmlBase::ReadText( const char* p,
}
}
}
if ( p )
if ( p && *p )
p += strlen( endTag );
return p;
}
@@ -825,7 +825,6 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
return 0;
}
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
@@ -896,11 +895,6 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
// Set the parent, so it can report errors
returnNode->parent = this;
}
else
{
if ( doc )
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
}
return returnNode;
}
@@ -1083,7 +1077,6 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
TIXML_STRING endTag ("</");
endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty
// tag or an end tag.
@@ -1114,14 +1107,28 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
// elements -- read the end tag, and return.
++p;
p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
if ( !p || !*p )
if ( !p || !*p ) {
// We were looking for the end tag, but found nothing.
// Fix for [ 1663758 ] Failure to report error on bad XML
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
}
// We should find the end tag now
// note that:
// </foo > and
// </foo>
// are both valid end tags.
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
{
p += endTag.length();
return p;
p = SkipWhiteSpace( p, encoding );
if ( p && *p && *p == '>' ) {
++p;
return p;
}
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
}
else
{
@@ -1135,7 +1142,6 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
TiXmlAttribute* attrib = new TiXmlAttribute();
if ( !attrib )
{
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
return 0;
}
@@ -1158,7 +1164,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
#endif
if ( node )
{
node->SetValue( attrib->Value() );
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
delete attrib;
return 0;
}
@@ -1187,8 +1193,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
if ( !textNode )
{
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
return 0;
return 0;
}
if ( TiXmlBase::IsWhiteSpaceCondensed() )
@@ -1349,7 +1354,35 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
return 0;
}
p += strlen( startTag );
p = ReadText( p, &value, false, endTag, false, encoding );
// [ 1475201 ] TinyXML parses entities in comments
// Oops - ReadText doesn't work, because we don't want to parse the entities.
// p = ReadText( p, &value, false, endTag, false, encoding );
//
// from the XML spec:
/*
[Definition: Comments may appear anywhere in a document outside other markup; in addition,
they may appear within the document type declaration at places allowed by the grammar.
They are not part of the document's character data; an XML processor MAY, but need not,
make it possible for an application to retrieve the text of comments. For compatibility,
the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
references MUST NOT be recognized within comments.
An example of a comment:
<!-- declarations for <head> & <body> -->
*/
value = "";
// Keep all the white space.
while ( p && *p && !StringEqual( p, endTag, false, encoding ) )
{
value.append( p, 1 );
++p;
}
if ( p && *p )
p += strlen( endTag );
return p;
}
@@ -1359,10 +1392,6 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p ) return 0;
// int tabsize = 4;
// if ( document )
// tabsize = document->TabSize();
if ( data )
{
data->Stamp( p, encoding );
@@ -1414,7 +1443,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
// its best, even without them.
value = "";
while ( p && *p // existence
&& !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
&& !IsWhiteSpace( *p ) // whitespace
&& *p != '/' && *p != '>' ) // tag end
{
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {