From 0989562eba02c87afe70cde2a65270b29e43c0be Mon Sep 17 00:00:00 2001
From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Tue, 25 May 2010 14:08:45 +0000
Subject: [PATCH] PDBWriter, fix locale bug

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2277 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/io/src/mol/pdb_writer.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/modules/io/src/mol/pdb_writer.cc b/modules/io/src/mol/pdb_writer.cc
index dc9fbe702..7b89e1f09 100644
--- a/modules/io/src/mol/pdb_writer.cc
+++ b/modules/io/src/mol/pdb_writer.cc
@@ -19,8 +19,10 @@
 /*
   Author: Marco Biasini
  */
+#include <locale>
 #include <boost/format.hpp>
 #include <string.h>
+
 #include <ost/io/io_exception.hh>
 
 #include "pdb_writer.hh"
@@ -257,6 +259,17 @@ private:
   std::map<long,int>& atom_indices_;
 };
 
+struct ForcePOSIX {
+  std::locale old_locale;
+  ForcePOSIX(){
+    old_locale=std::locale();
+    setlocale(LC_NUMERIC, "POSIX");
+  }
+  ~ForcePOSIX(){
+    setlocale(LC_NUMERIC, old_locale.name().c_str());
+  }
+};
+
 }
 
 PDBWriter::PDBWriter(std::ostream& stream):
@@ -295,6 +308,7 @@ void PDBWriter::WriteModelTrailer()
 template <typename H>
 void PDBWriter::WriteModel(H ent)
 {
+  ForcePOSIX posix = ForcePOSIX();
   this->WriteModelLeader();
   PDBWriterImpl writer(outstream_,line_, atom_indices_);
   if (PDB::Flags() & PDB::PQR_FORMAT) {
@@ -318,6 +332,7 @@ void PDBWriter::Write(const mol::EntityHandle& ent)
 
 void PDBWriter::Write(const mol::AtomHandleList& atoms)
 {
+  ForcePOSIX posix = ForcePOSIX();
   this->WriteModelLeader();
   int counter=1;
   mol::ChainHandle last_chain;
-- 
GitLab