Merge pull request #743 from deduktionstheorem/master

Issue 742: allow intermittent calls of XMLPrinter::ClearBuffer
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 378b48a..9372762 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -121,8 +121,14 @@
   "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"

   INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}"

 )

+write_basic_package_version_file(

+  "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"

+  VERSION ${GENERIC_LIB_VERSION}

+  COMPATIBILITY SameMajorVersion

+)

 install(FILES

         ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake

+        ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake

         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})

 

 install(EXPORT ${CMAKE_PROJECT_NAME}Targets NAMESPACE tinyxml2::

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..85a6a36
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,18 @@
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
diff --git a/readme.md b/readme.md
index a519bfa..d9bf501 100644
--- a/readme.md
+++ b/readme.md
@@ -54,9 +54,8 @@
 
 TinyXML-2 doesn't parse or use DTDs (Document Type Definitions) or XSLs
 (eXtensible Stylesheet Language.) There are other parsers out there
-that are much more fully featured. But they are also much bigger,
-take longer to set up in your project, have a higher learning curve,
-and often have a more restrictive license. If you are working with
+that are much more fully featured. But they are generally bigger and
+more difficult to use. If you are working with
 browsers or have more complete XML needs, TinyXML-2 is not the parser for you.
 
 TinyXML-1 vs. TinyXML-2
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index fd27f78..1c74279 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -45,14 +45,14 @@
 	{

 		va_list va;

 		va_start( va, format );

-		int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );

+		const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );

 		va_end( va );

 		return result;

 	}

 

 	static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )

 	{

-		int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );

+		const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );

 		return result;

 	}

 

@@ -197,7 +197,7 @@
 	TIXMLASSERT(curLineNumPtr);

 

     char* start = p;

-    char  endChar = *endTag;

+    const char  endChar = *endTag;

     size_t length = strlen( endTag );

 

     // Inner loop of text parsing.

@@ -310,7 +310,7 @@
                         const int buflen = 10;

                         char buf[buflen] = { 0 };

                         int len = 0;

-                        char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );

+                        const char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );

                         if ( adjusted == 0 ) {

                             *q = *p;

                             ++p;

@@ -1017,7 +1017,7 @@
             break;

         }

 

-        int initialLineNum = node->_parseLineNum;

+       const int initialLineNum = node->_parseLineNum;

 

         StrPair endTag;

         p = node->ParseDeep( p, &endTag, curLineNumPtr );

@@ -1029,7 +1029,7 @@
             break;

         }

 

-        XMLDeclaration* decl = node->ToDeclaration();

+        const XMLDeclaration* const decl = node->ToDeclaration();

         if ( decl ) {

             // Declarations are only allowed at document level

             //

@@ -1038,7 +1038,7 @@
             //

             // Optimized due to a security test case. If the first node is 

             // a declaration, and the last node is a declaration, then only 

-            // declarations have so far been addded.

+            // declarations have so far been added.

             bool wellLocated = false;

 

             if (ToDocument()) {

@@ -1373,7 +1373,7 @@
         return 0;

     }

 

-    char endTag[2] = { *p, 0 };

+    const char endTag[2] = { *p, 0 };

     ++p;	// move past opening quote

 

     p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES, curLineNumPtr );

@@ -1830,7 +1830,7 @@
             TIXMLASSERT( attrib );

             attrib->_parseLineNum = _document->_parseCurLineNum;

 

-            int attrLineNum = attrib->_parseLineNum;

+            const int attrLineNum = attrib->_parseLineNum;

 

             p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );

             if ( !p || Attribute( attrib->Name() ) ) {

@@ -2136,7 +2136,7 @@
     TIXMLASSERT( mode );

 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)

     FILE* fp = 0;

-    errno_t err = fopen_s( &fp, filepath, mode );

+    const errno_t err = fopen_s( &fp, filepath, mode );

     if ( err ) {

         return 0;

     }

@@ -2239,7 +2239,7 @@
     const size_t size = filelength;

     TIXMLASSERT( _charBuffer == 0 );

     _charBuffer = new char[size+1];

-    size_t read = fread( _charBuffer, 1, size, fp );

+    const size_t read = fread( _charBuffer, 1, size, fp );

     if ( read != size ) {

         SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );

         return _errorID;

@@ -2332,7 +2332,7 @@
     _errorLineNum = lineNum;

 	_errorStr.Reset();

 

-    size_t BUFFER_SIZE = 1000;

+    const size_t BUFFER_SIZE = 1000;

     char* buffer = new char[BUFFER_SIZE];

 

     TIXMLASSERT(sizeof(error) <= sizeof(int));

diff --git a/tinyxml2.h b/tinyxml2.h
index 7ba7ca0..f0f6510 100755
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -303,7 +303,7 @@
         TIXMLASSERT( cap > 0 );

         if ( cap > _allocated ) {

             TIXMLASSERT( cap <= INT_MAX / 2 );

-            int newAllocated = cap * 2;

+            const int newAllocated = cap * 2;

             T* newMem = new T[newAllocated];

             TIXMLASSERT( newAllocated >= _size );

             memcpy( newMem, _mem, sizeof(T)*_size );	// warning: not using constructors, only works for PODs