Update TinyXML to v2.6.2

This commit is contained in:
thecelloman 2013-03-13 04:00:12 -04:00
parent 17c750b19a
commit 512f0f10e7
93 changed files with 8970 additions and 5996 deletions

View file

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
Original code by Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -40,7 +40,7 @@ distribution.
// Note tha "PutString" hardcodes the same list. This
// is less flexible than it appears. Changing the entries
// or order will break putstring.
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] =
{
{ "&", 5, '&' },
{ "&lt;", 4, '<' },
@ -174,7 +174,7 @@ class TiXmlParsingData
public:
void Stamp( const char* now, TiXmlEncoding encoding );
const TiXmlCursor& Cursor() { return cursor; }
const TiXmlCursor& Cursor() const { return cursor; }
private:
// Only used by the document!
@ -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,9 +631,9 @@ const char* TiXmlBase::ReadText( const char* p,
}
}
}
if ( p )
if ( p && *p )
p += strlen( endTag );
return p;
return ( p && *p ) ? p : 0;
}
#ifdef TIXML_USE_STL
@ -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;
}
@ -1121,18 +1115,20 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
}
// 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 ) )
{
// Handle whitespace between end tag name and '>' character
p += endTag.length();
p = SkipWhiteSpace( p, encoding );
if (*p == '>')
return ++p;
else
{
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
if ( p && *p && *p == '>' ) {
++p;
return p;
}
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
}
else
{
@ -1146,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;
}
@ -1169,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;
}
@ -1198,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() )
@ -1304,9 +1298,10 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
if ( !p )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
if ( document )
document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
}
if ( *p == '>' )
if ( p && *p == '>' )
return p+1;
return p;
}
@ -1356,7 +1351,8 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
if ( !StringEqual( p, startTag, false, encoding ) )
{
document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
if ( document )
document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
return 0;
}
p += strlen( startTag );
@ -1386,7 +1382,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
value.append( p, 1 );
++p;
}
if ( p )
if ( p && *p )
p += strlen( endTag );
return p;
@ -1398,10 +1394,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 );
@ -1453,7 +1445,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 ) {
@ -1522,7 +1514,8 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
if ( !StringEqual( p, startTag, false, encoding ) )
{
document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding );
if ( document )
document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding );
return 0;
}
p += strlen( startTag );
@ -1546,7 +1539,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi
const char* end = "<";
p = ReadText( p, &value, ignoreWhite, end, false, encoding );
if ( p )
if ( p && *p )
return p-1; // don't truncate the '<'
return 0;
}