diff --git a/CMakeLists.txt b/CMakeLists.txt index ec2e58f..e9b44d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ IF(BIICODE) ENDIF(BIICODE) cmake_minimum_required(VERSION 2.6 FATAL_ERROR) cmake_policy(VERSION 2.6) +if(POLICY CMP0063) + cmake_policy(SET CMP0063 OLD) +endif() project(tinyxml2) include(GNUInstallDirs) diff --git a/readme.md b/readme.md index 82c6ce9..63f98fe 100644 --- a/readme.md +++ b/readme.md @@ -111,7 +111,7 @@ by the Document. When the Document is deleted, so are all the nodes it contains. Microsoft has an excellent article on white space: http://msdn.microsoft.com/en-us/library/ms256097.aspx -By default, TinyXML-2 preserves white space in a (hopefully) sane way that is almost complient with the +By default, TinyXML-2 preserves white space in a (hopefully) sane way that is almost compliant with the spec. (TinyXML-1 used a completely different model, much more similar to 'collapse', below.) As a first step, all newlines / carriage-returns / line-feeds are normalized to a diff --git a/tinyxml2.cpp b/tinyxml2.cpp index f8983a1..e958cfc 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -191,6 +191,7 @@ void StrPair::SetStr( const char* str, int flags ) char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) { + TIXMLASSERT( p ); TIXMLASSERT( endTag && *endTag ); char* start = p; @@ -204,6 +205,7 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) return p + length; } ++p; + TIXMLASSERT( p ); } return 0; } @@ -281,7 +283,8 @@ const char* StrPair::GetStr() else { ++p; } - *q++ = LF; + *q = LF; + ++q; } else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { if ( *(p+1) == CR ) { @@ -290,7 +293,8 @@ const char* StrPair::GetStr() else { ++p; } - *q++ = LF; + *q = LF; + ++q; } else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { // Entities handled by tinyXML2: @@ -2261,7 +2265,8 @@ XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) : } for( int i=0; i(entityValue) && entityValue < ENTITY_RANGE ); _entityFlag[ (unsigned char)entityValue ] = true; } _restrictedEntityFlag[(unsigned char)'&'] = true; diff --git a/tinyxml2.h b/tinyxml2.h index 9f5dbf7..4b06cc8 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -211,7 +211,8 @@ public: void Push( T t ) { TIXMLASSERT( _size < INT_MAX ); EnsureCapacity( _size+1 ); - _mem[_size++] = t; + _mem[_size] = t; + ++_size; } T* PushArr( int count ) { @@ -225,7 +226,8 @@ public: T Pop() { TIXMLASSERT( _size > 0 ); - return _mem[--_size]; + --_size; + return _mem[_size]; } void PopArr( int count ) { @@ -568,6 +570,9 @@ public: if ( p == q ) { return true; } + TIXMLASSERT( p ); + TIXMLASSERT( q ); + TIXMLASSERT( nChar >= 0 ); return strncmp( p, q, nChar ) == 0; } @@ -1127,7 +1132,7 @@ public: } /** QueryIntValue interprets the attribute as an integer, and returns the value - in the provided parameter. The function will return XML_NO_ERROR on success, + in the provided parameter. The function will return XML_SUCCESS on success, and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. */ XMLError QueryIntValue( int* value ) const; @@ -1244,7 +1249,7 @@ public: float FloatAttribute(const char* name, float defaultValue = 0) const; /** Given an attribute name, QueryIntAttribute() returns - XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion can't be performed, or XML_NO_ATTRIBUTE if the attribute doesn't exist. If successful, the result of the conversion will be written to 'value'. If not successful, nothing will @@ -1309,7 +1314,7 @@ public: /** Given an attribute name, QueryAttribute() returns - XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion can't be performed, or XML_NO_ATTRIBUTE if the attribute doesn't exist. It is overloaded for the primitive types, and is a generally more convenient replacement of @@ -1596,7 +1601,7 @@ public: /** Parse an XML file from a character string. - Returns XML_NO_ERROR (0) on success, or + Returns XML_SUCCESS (0) on success, or an errorID. You may optionally pass in the 'nBytes', which is @@ -1608,7 +1613,7 @@ public: /** Load an XML file from disk. - Returns XML_NO_ERROR (0) on success, or + Returns XML_SUCCESS (0) on success, or an errorID. */ XMLError LoadFile( const char* filename ); @@ -1621,14 +1626,14 @@ public: not text in order for TinyXML-2 to correctly do newline normalization. - Returns XML_NO_ERROR (0) on success, or + Returns XML_SUCCESS (0) on success, or an errorID. */ XMLError LoadFile( FILE* ); /** Save the XML file to disk. - Returns XML_NO_ERROR (0) on success, or + Returns XML_SUCCESS (0) on success, or an errorID. */ XMLError SaveFile( const char* filename, bool compact = false ); @@ -1637,7 +1642,7 @@ public: Save the XML file to disk. You are responsible for providing and closing the FILE*. - Returns XML_NO_ERROR (0) on success, or + Returns XML_SUCCESS (0) on success, or an errorID. */ XMLError SaveFile( FILE* fp, bool compact = false );