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* 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;
|
||||
}
|
||||
|
@ -479,8 +479,7 @@ bool XMLUtil::ToDouble( const char* str, double* value )
|
|||
|
||||
char* XMLDocument::Identify( char* p, XMLNode** node )
|
||||
{
|
||||
XMLNode* returnNode = 0;
|
||||
char* start = p;
|
||||
char* const start = p;
|
||||
p = XMLUtil::SkipWhiteSpace( p );
|
||||
if( !p || !*p ) {
|
||||
return p;
|
||||
|
@ -509,6 +508,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node )
|
|||
#if defined(_MSC_VER)
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
XMLNode* returnNode = 0;
|
||||
if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
|
||||
returnNode = new (_commentPool.Alloc()) XMLDeclaration( this );
|
||||
returnNode->_memPool = &_commentPool;
|
||||
|
@ -693,7 +693,7 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
|
|||
addThis->_next = 0;
|
||||
}
|
||||
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.
|
||||
if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
|
||||
if ( parentEnd ) {
|
||||
*parentEnd = static_cast<XMLElement*>(node)->_value;
|
||||
*parentEnd = ele->_value;
|
||||
}
|
||||
node->_memPool->SetTracked(); // created and then immediately deleted.
|
||||
DeleteNode( node );
|
||||
|
@ -833,20 +833,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 );
|
||||
|
|
Loading…
Reference in New Issue