Permalink
Browse files

Closes #56: Set C locale during file parsing, reset old one afterwards.

[ ] May break build
[ ] May break existing applications (see CHANGES.txt)
[x] Bugfix
[ ] New Feature
[ ] Cleanup
[ ] Optimization
[ ] Documentation
  • Loading branch information...
1 parent 21a5059 commit dcb579538217631171933632b7c0fce6e2b3a49b @eile eile committed Nov 17, 2011
Showing with 18 additions and 15 deletions.
  1. +1 −0 libs/eq/server/loader.h
  2. +17 −15 libs/eq/server/loader.y
View
@@ -109,6 +109,7 @@ namespace server
private:
void _parseString( const char* config );
+ void _parse();
};
}
}
View
@@ -43,7 +43,10 @@
#include <eq/fabric/paths.h>
#include <co/base/os.h>
#include <co/base/file.h>
+
+#include <locale.h>
#include <string>
+
#pragma warning(disable: 4065)
namespace eq
@@ -1333,30 +1336,20 @@ namespace server
//---------------------------------------------------------------------------
ServerPtr Loader::loadFile( const std::string& filename )
{
- EQASSERTINFO( !eq::loader::loader, "Config file loader is not reentrant" );
- eq::loader::loader = this;
-
yyin = fopen( filename.c_str(), "r" );
yyinString = 0;
if( !yyin )
{
EQERROR << "Can't open config file " << filename << std::endl;
- eq::loader::loader = 0;
return 0;
}
loader::filename = filename;
- loader::server = 0;
- config = 0;
- const bool error = ( eqLoader_parse() != 0 );
-
- fclose( yyin );
- eq::loader::loader = 0;
+ _parse();
loader::filename.clear();
- if( error )
- loader::server = 0;
+ fclose( yyin );
eq::server::ServerPtr server = loader::server;
loader::server = 0;
@@ -1365,15 +1358,24 @@ ServerPtr Loader::loadFile( const std::string& filename )
void Loader::_parseString( const char* data )
{
- EQASSERTINFO( !eq::loader::loader, "Config file loader is not reentrant" );
- eq::loader::loader = this;
-
yyin = 0;
yyinString = data;
+ _parse();
+}
+
+void Loader::_parse()
+{
+ EQASSERTINFO( !eq::loader::loader, "Config file loader is not reentrant" );
+ eq::loader::loader = this;
loader::server = 0;
config = 0;
+
+ const std::string oldLocale = setlocale( LC_NUMERIC, "C" );
+ setlocale( LC_NUMERIC, "C" );
const bool error = ( eqLoader_parse() != 0 );
+ setlocale( LC_NUMERIC, oldLocale.c_str( ));
+
if( error )
loader::server = 0;

0 comments on commit dcb5795

Please sign in to comment.