From ef92bcbc5a975e4254cc69c5f7897aded1b508f8 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 18 Oct 2014 11:17:29 +0200 Subject: [PATCH] Updated tinyxml to d211bb13512cf4edb408e2c4badbcf4100ce0fd0 --- externals/tinyxml/tinyxml2.cpp | 54 ++++++++++++++++++---------------- externals/tinyxml/tinyxml2.h | 9 ++---- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/externals/tinyxml/tinyxml2.cpp b/externals/tinyxml/tinyxml2.cpp index 53d78bd2f..2893a2798 100644 --- a/externals/tinyxml/tinyxml2.cpp +++ b/externals/tinyxml/tinyxml2.cpp @@ -114,12 +114,12 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) char* StrPair::ParseName( char* p ) { - char* start = p; - - if ( !start || !(*start) ) { + if ( !p || !(*p) ) { return 0; } + char* const start = p; + while( *p && ( p == start ? XMLUtil::IsNameStartChar( *p ) : XMLUtil::IsNameChar( *p ) )) { ++p; } @@ -212,12 +212,13 @@ const char* StrPair::GetStr() else { int i=0; for(; i_memPool = &_commentPool; @@ -693,7 +694,7 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) addThis->_next = 0; } addThis->_parent = this; - return addThis; + return addThis; } @@ -823,7 +824,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd ) // We read the end tag. Return it to the parent. if ( ele && ele->ClosingType() == XMLElement::CLOSING ) { if ( parentEnd ) { - *parentEnd = static_cast(node)->_value; + *parentEnd = ele->_value; } node->_memPool->SetTracked(); // created and then immediately deleted. DeleteNode( node ); @@ -833,20 +834,22 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd ) // Handle an end tag returned to this level. // And handle a bunch of annoying errors. if ( ele ) { + bool mismatch = false; if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); - p = 0; + mismatch = true; } else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); - p = 0; + mismatch = true; } else if ( !endTag.Empty() ) { if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) { - _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); - p = 0; + mismatch = true; } } + if ( mismatch ) { + _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); + p = 0; + } } if ( p == 0 ) { DeleteNode( node ); @@ -911,7 +914,8 @@ XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const bool XMLText::ShallowEqual( const XMLNode* compare ) const { - return ( compare->ToText() && XMLUtil::StringEqual( compare->ToText()->Value(), Value() )); + const XMLText* text = compare->ToText(); + return ( text && XMLUtil::StringEqual( text->Value(), Value() ) ); } @@ -1254,7 +1258,7 @@ const char* XMLElement::Attribute( const char* name, const char* value ) const const char* XMLElement::GetText() const { if ( FirstChild() && FirstChild()->ToText() ) { - return FirstChild()->ToText()->Value(); + return FirstChild()->Value(); } return 0; } @@ -1314,7 +1318,7 @@ void XMLElement::SetText( double v ) XMLError XMLElement::QueryIntText( int* ival ) const { if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->ToText()->Value(); + const char* t = FirstChild()->Value(); if ( XMLUtil::ToInt( t, ival ) ) { return XML_SUCCESS; } @@ -1327,7 +1331,7 @@ XMLError XMLElement::QueryIntText( int* ival ) const XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const { if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->ToText()->Value(); + const char* t = FirstChild()->Value(); if ( XMLUtil::ToUnsigned( t, uval ) ) { return XML_SUCCESS; } @@ -1340,7 +1344,7 @@ XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const XMLError XMLElement::QueryBoolText( bool* bval ) const { if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->ToText()->Value(); + const char* t = FirstChild()->Value(); if ( XMLUtil::ToBool( t, bval ) ) { return XML_SUCCESS; } @@ -1353,7 +1357,7 @@ XMLError XMLElement::QueryBoolText( bool* bval ) const XMLError XMLElement::QueryDoubleText( double* dval ) const { if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->ToText()->Value(); + const char* t = FirstChild()->Value(); if ( XMLUtil::ToDouble( t, dval ) ) { return XML_SUCCESS; } @@ -1366,7 +1370,7 @@ XMLError XMLElement::QueryDoubleText( double* dval ) const XMLError XMLElement::QueryFloatText( float* fval ) const { if ( FirstChild() && FirstChild()->ToText() ) { - const char* t = FirstChild()->ToText()->Value(); + const char* t = FirstChild()->Value(); if ( XMLUtil::ToFloat( t, fval ) ) { return XML_SUCCESS; } diff --git a/externals/tinyxml/tinyxml2.h b/externals/tinyxml/tinyxml2.h index 1fdc928b0..4dfb01505 100644 --- a/externals/tinyxml/tinyxml2.h +++ b/externals/tinyxml/tinyxml2.h @@ -523,10 +523,7 @@ public: return p; } static char* SkipWhiteSpace( char* p ) { - while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { - ++p; - } - return p; + return const_cast( SkipWhiteSpace( const_cast(p) ) ); } static bool IsWhiteSpace( char p ) { return !IsUTF8Continuation(p) && isspace( static_cast(p) ); @@ -561,8 +558,8 @@ public: return false; } - inline static int IsUTF8Continuation( const char p ) { - return p & 0x80; + inline static bool IsUTF8Continuation( const char p ) { + return ( p & 0x80 ) != 0; } static const char* ReadBOM( const char* p, bool* hasBOM );