From 31a9cefa5734d92883789b44f6a504a19c19a71d Mon Sep 17 00:00:00 2001 From: Greg Zharun Date: Thu, 8 Jan 2015 15:39:58 +0200 Subject: [PATCH] [Summary] This part of code worker incorrectly on Windows: atof() on Windows expects "," (comma) as float delimeter and ignores "." (dot). So on windows atof("0.1") would return 0. Unlike MAC. Proposed fix should work on all platforms. --- libs/canvas/xml_ui.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/canvas/xml_ui.cc b/libs/canvas/xml_ui.cc index 15a2003fa5..7a3a458950 100644 --- a/libs/canvas/xml_ui.cc +++ b/libs/canvas/xml_ui.cc @@ -49,7 +49,15 @@ xml_property (const XMLNode &node, const char *prop_name, const XMLNodeMap& styl if (property.empty()) { return default_value; } - return atof(property.c_str()); + + // get float value from string + double value; + std::istringstream ss (property); + // set classic locale with "." float delimeter as default + ss.imbue(std::locale("C")); + ss >> value; + + return value; } double