From 4e74b13e7a8f75be30e1fde54f041b5cd7640aab Mon Sep 17 00:00:00 2001 From: Reinhard Klambauer Date: Fri, 22 Nov 2013 14:01:58 +0100 Subject: [PATCH 01/14] Added a method to reset the memory buffer of the DynArray class. The the allocated memory will not be touched so the capacity keeps its current level. --- tinyxml2.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tinyxml2.h b/tinyxml2.h index ca3d90e..26179f9 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -216,6 +216,10 @@ public: } } + void Reset() { + _size = 0; + } + void Push( T t ) { EnsureCapacity( _size+1 ); _mem[_size++] = t; From 3bc3d4e24c35a4c5431be9c8d7610a1e5230bdd0 Mon Sep 17 00:00:00 2001 From: Reinhard Klambauer Date: Fri, 22 Nov 2013 14:05:21 +0100 Subject: [PATCH 02/14] Added a method to reset the memory buffer to the XMLPrinter class. This enables to reset the printer memory to start again from the beginning. --- tinyxml2.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tinyxml2.h b/tinyxml2.h index 26179f9..edfae82 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -1966,6 +1966,14 @@ public: int CStrSize() const { return _buffer.Size(); } + /** + If in print to memory mode, reset the buffer to the + beginning. + */ + void ResetBuffer() { + _buffer.Reset(); + _buffer.Push(0); + } protected: void SealElement(); From ce0510ba2db899c1e4157b6a35dd70710de6bfda Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Tue, 26 Nov 2013 21:29:37 -0800 Subject: [PATCH 03/14] rename Reset to Clear to be consistent with XMLDocument --- tinyxml2.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tinyxml2.h b/tinyxml2.h index edfae82..fa4eeb5 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -216,7 +216,7 @@ public: } } - void Reset() { + void Clear() { _size = 0; } @@ -1970,8 +1970,8 @@ public: If in print to memory mode, reset the buffer to the beginning. */ - void ResetBuffer() { - _buffer.Reset(); + void ClearBuffer() { + _buffer.Clear(); _buffer.Push(0); } From 61871d60a6e4f4aef8a58d6a1034a0521f545ff1 Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Thu, 5 Dec 2013 11:44:38 -0800 Subject: [PATCH 04/14] Fix up the readme, add attribution for the logo. --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 7644f41..8ecd536 100644 --- a/readme.md +++ b/readme.md @@ -51,11 +51,10 @@ What it doesn't do. 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 browsers or have more -complete XML needs, TinyXML-2 is not the parser for you. +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 +browsers or have more complete XML needs, TinyXML-2 is not the parser for you. TinyXML-1 vs. TinyXML-2 ----------------------- @@ -309,8 +308,9 @@ in shaping what is a very successful library. Extra thanks to Yves Berquin and Andrew Ellerton who were key contributors. TinyXML-2 grew from that effort. Lee Thomason is the original author -of TinyXML-2 (and TinyXML-1) but hopefully TinyXML-2 will be improved +of TinyXML-2 (and TinyXML-1) but TinyXML-2 has been and is being improved by many contributors. -Thanks to John Mackay for the TinyXML-2 logo. +Thanks to John Mackay at http://john.mackay.rosalilastudio.com for the TinyXML-2 logo! + From 3dacebf8eee7f1abed5379e8e4779c5fd7ab9e1d Mon Sep 17 00:00:00 2001 From: Leonid Onokhov Date: Thu, 12 Dec 2013 15:07:34 +0300 Subject: [PATCH 05/14] add TINYXML2_EXPORT define when building shared lib otherwise it exports no symbols and msvc does not create import .lib --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b58f9eb..aa2d860 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ if(BUILD_STATIC_LIBS) endif(BUILD_STATIC_LIBS) add_library(tinyxml2 SHARED tinyxml2.cpp tinyxml2.h) set_target_properties(tinyxml2 PROPERTIES + COMPILE_DEFINITIONS "TINYXML2_EXPORT" VERSION "${GENERIC_LIB_VERSION}" SOVERSION "${GENERIC_LIB_SOVERSION}") From ba4b328b3da8ad6d46aa1e78e5facf35b65b13e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 10 Jan 2014 21:37:27 +0100 Subject: [PATCH 06/14] Fixed issue 147 (XMLDocument::LoadFile() may crash on non-regular file) --- tinyxml2.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 7e4ff40..4574fb3 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1639,6 +1639,13 @@ XMLError XMLDocument::LoadFile( FILE* fp ) { Clear(); + fseek( fp, 0, SEEK_SET ); + fgetc( fp ); + if ( ferror( fp ) != 0 ) { + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + fseek( fp, 0, SEEK_END ); size_t size = ftell( fp ); fseek( fp, 0, SEEK_SET ); From c3708ccf0876d78e7ba96b69a90f3bfabcea85df Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Tue, 14 Jan 2014 12:30:03 -0800 Subject: [PATCH 07/14] implement a fix to floating point precision as proposed by schuellc. --- CMakeLists.txt | 4 +-- dox | 2 +- tinyxml2.cpp | 16 ++++----- tinyxml2.h | 11 ++++-- xmltest.cpp | 90 ++++++++++++++++++++++++++++++++++---------------- 5 files changed, 80 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b58f9eb..f0ae3dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ include(GNUInstallDirs) ################################ # set lib version here -set(GENERIC_LIB_VERSION "1.0.12") -set(GENERIC_LIB_SOVERSION "1") +set(GENERIC_LIB_VERSION "1.0.13") +set(GENERIC_LIB_SOVERSION "1") ################################ diff --git a/dox b/dox index 7ab99ff..2413b2e 100755 --- a/dox +++ b/dox @@ -32,7 +32,7 @@ PROJECT_NAME = "TinyXML-2" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.0.12 +PROJECT_NUMBER = 1.0.13 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 7e4ff40..50022f4 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -422,16 +422,19 @@ void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); } - +/* + ToStr() of a number is a very tricky topic. + https://github.com/leethomason/tinyxml2/issues/106 +*/ void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) { - TIXML_SNPRINTF( buffer, bufferSize, "%f", v ); + TIXML_SNPRINTF( buffer, bufferSize, "%.8g", v ); } void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) { - TIXML_SNPRINTF( buffer, bufferSize, "%f", v ); + TIXML_SNPRINTF( buffer, bufferSize, "%.17g", v ); } @@ -497,12 +500,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node ) } // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: