From d7121b4b7adc1c65220a34b964559057e14dee72 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:07:52 +0100 Subject: [PATCH] Changed: Don't need to use Windows functions with locale because the bug also occurs under Linux and OS X --HG-- branch : develop --- code/nel/include/nel/misc/i_xml.h | 3 -- code/nel/include/nel/misc/o_xml.h | 3 -- code/nel/src/misc/i_xml.cpp | 63 ++++++------------------------- code/nel/src/misc/o_xml.cpp | 22 ----------- 4 files changed, 12 insertions(+), 79 deletions(-) diff --git a/code/nel/include/nel/misc/i_xml.h b/code/nel/include/nel/misc/i_xml.h index 20ee8a7e0..b078eb7ee 100644 --- a/code/nel/include/nel/misc/i_xml.h +++ b/code/nel/include/nel/misc/i_xml.h @@ -236,9 +236,6 @@ private: // If not NULL, binary mode detected, use this stream in serials IStream *_BinaryStream; - - // System dependant structure for locale - void* _Locale; }; diff --git a/code/nel/include/nel/misc/o_xml.h b/code/nel/include/nel/misc/o_xml.h index 8346a6884..5bafacd60 100644 --- a/code/nel/include/nel/misc/o_xml.h +++ b/code/nel/include/nel/misc/o_xml.h @@ -181,9 +181,6 @@ private: // Error message std::string _ErrorString; - - // System dependant structure for locale - void* _Locale; }; diff --git a/code/nel/src/misc/i_xml.cpp b/code/nel/src/misc/i_xml.cpp index e722f3eee..fbd8f5d9f 100644 --- a/code/nel/src/misc/i_xml.cpp +++ b/code/nel/src/misc/i_xml.cpp @@ -24,11 +24,6 @@ // Include from libxml2 #include -#if defined(NL_OS_WINDOWS) && defined(NL_COMP_VC_VERSION) && NL_COMP_VC_VERSION >= 80 -#define USE_LOCALE_ATOF -#include -#endif - using namespace std; #define NLMISC_READ_BUFFER_SIZE 1024 @@ -46,26 +41,10 @@ const char SEPARATOR = ' '; // *************************************************************************** -#define readnumber(dest,thetype,digits,convfunc) \ +#define readnumber(dest,digits) \ string number_as_string; \ serialSeparatedBufferIn( number_as_string ); \ - dest = (thetype)convfunc( number_as_string.c_str() ); - -#ifdef USE_LOCALE_ATOF - -#define readnumberlocale(dest,thetype,digits,convfunc) \ - string number_as_string; \ - serialSeparatedBufferIn( number_as_string ); \ - dest = (thetype)convfunc( number_as_string.c_str(), (_locale_t)_Locale ); - -#define nl_atof _atof_l - -#else - -#define readnumberlocale(dest,thetype,digits,convfunc) readnumber(dest,thetype,digits,convfunc) -#define nl_atof atof - -#endif + NLMISC::fromString(number_as_string, dest); // *************************************************************************** @@ -91,13 +70,6 @@ CIXml::CIXml () : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = false; _BinaryStream = NULL; - -#ifdef USE_LOCALE_ATOF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -113,13 +85,6 @@ CIXml::CIXml (bool tryBinaryMode) : IStream (true /* Input mode */) _ErrorString = ""; _TryBinaryMode = tryBinaryMode; _BinaryStream = NULL; - -#ifdef USE_LOCALE_ATOF - // create C numeric locale - _Locale = _create_locale(LC_NUMERIC, "C"); -#else - _Locale = NULL; -#endif } // *************************************************************************** @@ -128,10 +93,6 @@ CIXml::~CIXml () { // Release release (); - -#ifdef USE_LOCALE_ATOF - if (_Locale) _free_locale((_locale_t)_Locale); -#endif } // *************************************************************************** @@ -468,7 +429,7 @@ void CIXml::serial(uint8 &b) else { // Read the number - readnumber( b, uint8, 3, atoi ); + readnumber( b, 3 ); } } @@ -482,7 +443,7 @@ void CIXml::serial(sint8 &b) } else { - readnumber( b, sint8, 4, atoi ); + readnumber( b, 4 ); } } @@ -496,7 +457,7 @@ void CIXml::serial(uint16 &b) } else { - readnumber( b, uint16, 5, atoi ); + readnumber( b, 5 ); } } @@ -510,7 +471,7 @@ void CIXml::serial(sint16 &b) } else { - readnumber( b, sint16, 6, atoi ); + readnumber( b, 6 ); } } @@ -529,7 +490,7 @@ void CIXml::serial(uint32 &b) } else { - readnumber( b, uint32, 10, atoui ); + readnumber( b, 10 ); } } @@ -543,7 +504,7 @@ void CIXml::serial(sint32 &b) } else { - readnumber( b, sint32, 11, atoi ); + readnumber( b, 11 ); } } @@ -557,7 +518,7 @@ void CIXml::serial(uint64 &b) } else { - readnumber( b, uint64, 20, atoiInt64 ); + readnumber( b, 20 ); } } @@ -571,7 +532,7 @@ void CIXml::serial(sint64 &b) } else { - readnumber( b, sint64, 20, atoiInt64 ); + readnumber( b, 20 ); } } @@ -585,7 +546,7 @@ void CIXml::serial(float &b) } else { - readnumberlocale( b, float, 128, nl_atof ); + readnumber( b, 128 ); } } @@ -599,7 +560,7 @@ void CIXml::serial(double &b) } else { - readnumberlocale( b, double, 128, nl_atof ); + readnumber( b, 128 ); } } diff --git a/code/nel/src/misc/o_xml.cpp b/code/nel/src/misc/o_xml.cpp index d07362904..6df48ef80 100644 --- a/code/nel/src/misc/o_xml.cpp +++ b/code/nel/src/misc/o_xml.cpp @@ -43,22 +43,11 @@ 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 // *************************************************************************** @@ -149,13 +138,6 @@ 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 } // *************************************************************************** @@ -215,10 +197,6 @@ COXml::~COXml () { // Flush document to the internal stream flush (); - -#ifdef USE_LOCALE_SPRINTF - if (_Locale) _free_locale((_locale_t)_Locale); -#endif } // ***************************************************************************