mirror of https://github.com/AxioDL/tinyxml2.git
Merge pull request #210 from Dmitry-Me/removeUnneededCast
Remove unneeded cast, reduce duplication, move declarations to their fir...
This commit is contained in:
commit
b0776aeead
28
tinyxml2.cpp
28
tinyxml2.cpp
|
@ -114,12 +114,12 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags )
|
||||||
|
|
||||||
char* StrPair::ParseName( char* p )
|
char* StrPair::ParseName( char* p )
|
||||||
{
|
{
|
||||||
char* start = p;
|
if ( !p || !(*p) ) {
|
||||||
|
|
||||||
if ( !start || !(*start) ) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* const start = p;
|
||||||
|
|
||||||
while( *p && ( p == start ? XMLUtil::IsNameStartChar( *p ) : XMLUtil::IsNameChar( *p ) )) {
|
while( *p && ( p == start ? XMLUtil::IsNameStartChar( *p ) : XMLUtil::IsNameChar( *p ) )) {
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
@ -479,8 +479,7 @@ bool XMLUtil::ToDouble( const char* str, double* value )
|
||||||
|
|
||||||
char* XMLDocument::Identify( char* p, XMLNode** node )
|
char* XMLDocument::Identify( char* p, XMLNode** node )
|
||||||
{
|
{
|
||||||
XMLNode* returnNode = 0;
|
char* const start = p;
|
||||||
char* start = p;
|
|
||||||
p = XMLUtil::SkipWhiteSpace( p );
|
p = XMLUtil::SkipWhiteSpace( p );
|
||||||
if( !p || !*p ) {
|
if( !p || !*p ) {
|
||||||
return p;
|
return p;
|
||||||
|
@ -509,6 +508,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node )
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
XMLNode* returnNode = 0;
|
||||||
if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
|
if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
|
||||||
returnNode = new (_commentPool.Alloc()) XMLDeclaration( this );
|
returnNode = new (_commentPool.Alloc()) XMLDeclaration( this );
|
||||||
returnNode->_memPool = &_commentPool;
|
returnNode->_memPool = &_commentPool;
|
||||||
|
@ -693,7 +693,7 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
|
||||||
addThis->_next = 0;
|
addThis->_next = 0;
|
||||||
}
|
}
|
||||||
addThis->_parent = this;
|
addThis->_parent = this;
|
||||||
return addThis;
|
return addThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
|
||||||
// We read the end tag. Return it to the parent.
|
// We read the end tag. Return it to the parent.
|
||||||
if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
|
if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
|
||||||
if ( parentEnd ) {
|
if ( parentEnd ) {
|
||||||
*parentEnd = static_cast<XMLElement*>(node)->_value;
|
*parentEnd = ele->_value;
|
||||||
}
|
}
|
||||||
node->_memPool->SetTracked(); // created and then immediately deleted.
|
node->_memPool->SetTracked(); // created and then immediately deleted.
|
||||||
DeleteNode( node );
|
DeleteNode( node );
|
||||||
|
@ -833,20 +833,22 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
|
||||||
// Handle an end tag returned to this level.
|
// Handle an end tag returned to this level.
|
||||||
// And handle a bunch of annoying errors.
|
// And handle a bunch of annoying errors.
|
||||||
if ( ele ) {
|
if ( ele ) {
|
||||||
|
bool mismatch = false;
|
||||||
if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
|
if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
|
||||||
_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
|
mismatch = true;
|
||||||
p = 0;
|
|
||||||
}
|
}
|
||||||
else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
|
else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
|
||||||
_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
|
mismatch = true;
|
||||||
p = 0;
|
|
||||||
}
|
}
|
||||||
else if ( !endTag.Empty() ) {
|
else if ( !endTag.Empty() ) {
|
||||||
if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
|
if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
|
||||||
_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
|
mismatch = true;
|
||||||
p = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( mismatch ) {
|
||||||
|
_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
|
||||||
|
p = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( p == 0 ) {
|
if ( p == 0 ) {
|
||||||
DeleteNode( node );
|
DeleteNode( node );
|
||||||
|
|
Loading…
Reference in New Issue