Merge pull request #253 from Dmitry-Me/getRidOfC4127InAssert

Suppress C4127 in asserts
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 5042e8d..42659f2 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -140,18 +140,18 @@
     if ( !p || !(*p) ) {

         return 0;

     }

+    if ( !XMLUtil::IsNameStartChar( *p ) ) {

+        return 0;

+    }

 

     char* const start = p;

-

-    while( *p && ( p == start ? XMLUtil::IsNameStartChar( *p ) : XMLUtil::IsNameChar( *p ) )) {

+    ++p;

+    while ( *p && XMLUtil::IsNameChar( *p ) ) {

         ++p;

     }

 

-    if ( p > start ) {

-        Set( start, p, 0 );

-        return p;

-    }

-    return 0;

+    Set( start, p, 0 );

+    return p;

 }

 

 

@@ -162,7 +162,7 @@
     // Trim leading space.

     _start = XMLUtil::SkipWhiteSpace( _start );

 

-    if ( _start && *_start ) {

+    if ( *_start ) {

         char* p = _start;	// the read pointer

         char* q = _start;	// the write pointer

 

@@ -277,6 +277,8 @@
 

 const char* XMLUtil::ReadBOM( const char* p, bool* bom )

 {

+    TIXMLASSERT( p );

+    TIXMLASSERT( bom );

     *bom = false;

     const unsigned char* pu = reinterpret_cast<const unsigned char*>(p);

     // Check for BOM:

@@ -286,6 +288,7 @@
         *bom = true;

         p += 3;

     }

+    TIXMLASSERT( p );

     return p;

 }

 

@@ -505,7 +508,7 @@
 {

     char* const start = p;

     p = XMLUtil::SkipWhiteSpace( p );

-    if( !p || !*p ) {

+    if( !*p ) {

         return p;

     }

 

@@ -634,6 +637,7 @@
 

 void XMLNode::Unlink( XMLNode* child )

 {

+    TIXMLASSERT( child );

     TIXMLASSERT( child->_document == _document );

     if ( child == _firstChild ) {

         _firstChild = _firstChild->_next;

@@ -654,6 +658,7 @@
 

 void XMLNode::DeleteChild( XMLNode* node )

 {

+    TIXMLASSERT( node );

     TIXMLASSERT( node->_document == _document );

     TIXMLASSERT( node->_parent == this );

     DeleteNode( node );

@@ -1125,7 +1130,7 @@
 

     // Skip white space before =

     p = XMLUtil::SkipWhiteSpace( p );

-    if ( !p || *p != '=' ) {

+    if ( *p != '=' ) {

         return 0;

     }

 

@@ -1461,7 +1466,7 @@
     // Read the attributes.

     while( p ) {

         p = XMLUtil::SkipWhiteSpace( p );

-        if ( !p || !(*p) ) {

+        if ( !(*p) ) {

             _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );

             return 0;

         }

@@ -1528,9 +1533,6 @@
 {

     // Read the element name.

     p = XMLUtil::SkipWhiteSpace( p );

-    if ( !p ) {

-        return 0;

-    }

 

     // The closing element is the </element> form. It is

     // parsed just like a regular element then deleted from

@@ -1821,7 +1823,7 @@
     const char* p = _charBuffer;

     p = XMLUtil::SkipWhiteSpace( p );

     p = XMLUtil::ReadBOM( p, &_writeBOM );

-    if ( !p || !*p ) {

+    if ( !*p ) {

         SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );

         return _errorID;

     }

@@ -1870,7 +1872,7 @@
     const char* start = p;

     p = XMLUtil::SkipWhiteSpace( p );

     p = XMLUtil::ReadBOM( p, &_writeBOM );

-    if ( !p || !*p ) {

+    if ( !*p ) {

         SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );

         return _errorID;

     }

diff --git a/tinyxml2.h b/tinyxml2.h
index 03fd7da..530160f 100755
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -534,9 +534,11 @@
 {

 public:

     static const char* SkipWhiteSpace( const char* p )	{

+        TIXMLASSERT( p );

         while( IsWhiteSpace(*p) ) {

             ++p;

         }

+        TIXMLASSERT( p );

         return p;

     }

     static char* SkipWhiteSpace( char* p )				{

diff --git a/xmltest.cpp b/xmltest.cpp
index 4170977..79ecf88 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -867,13 +867,21 @@
 

 	{

 		// Empty documents should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717

-		const char* str = "    ";

+		const char* str = "";

 		XMLDocument doc;

 		doc.Parse( str );

 		XMLTest( "Empty document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );

 	}

 

 	{

+		// Documents with all whitespaces should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717

+		const char* str = "    ";

+		XMLDocument doc;

+		doc.Parse( str );

+		XMLTest( "All whitespaces document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );

+	}

+

+	{

 		// Low entities

 		XMLDocument doc;

 		doc.Parse( "<test>&#x0e;</test>" );