From 7aedffce9a1fded8ca22dc070b6a35b68fd3f3eb Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 2 Aug 2014 11:18:24 +0200 Subject: [PATCH] Changed: #172 XML floating point serialization not using neutral culture (for VC++ 2005 and up) --- code/nel/include/nel/misc/o_xml.h | 3 +++ code/nel/src/misc/o_xml.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/code/nel/include/nel/misc/o_xml.h b/code/nel/include/nel/misc/o_xml.h index 5933b7ebc..a532f0342 100644 --- a/code/nel/include/nel/misc/o_xml.h +++ b/code/nel/include/nel/misc/o_xml.h @@ -178,6 +178,9 @@ private: // Error message std::string _ErrorString; + + // System dependant structure for locale + void* _Locale; }; diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index 005ef8000..0fbe3dade 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -23,6 +23,11 @@ // Include from libxml2 #include +#if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 80 +#define USE_LOCALE_SPRINTF +#include +#endif + using namespace std; #ifdef DEBUG_NEW @@ -38,11 +43,22 @@ const char SEPARATOR = ' '; // *************************************************************************** +#ifdef USE_LOCALE_SPRINTF + +#define writenumber(src,format,digits) \ + char number_as_cstring [digits+1]; \ + _sprintf_l( number_as_cstring, format, (_locale_t)_Locale, src ); \ + serialSeparatedBufferOut( number_as_cstring ); + +#else + #define writenumber(src,format,digits) \ char number_as_cstring [digits+1]; \ sprintf( number_as_cstring, format, src ); \ serialSeparatedBufferOut( number_as_cstring ); +#endif + // *************************************************************************** // XML callbacks // *************************************************************************** @@ -133,6 +149,13 @@ COXml::COXml () : IStream (false /* Output mode */) // Push begin _PushBegin = false; + +#ifdef USE_LOCALE_SPRINTF + // create C numeric locale + _Locale = _create_locale(LC_NUMERIC, "C"); +#else + _Locale = NULL; +#endif } // *************************************************************************** @@ -192,6 +215,10 @@ COXml::~COXml () { // Flush document to the internal stream flush (); + +#ifdef USE_LOCALE_SPRINTF + if (_Locale) _free_locale((_locale_t)_Locale); +#endif } // ***************************************************************************