diff base/RealTimeSV.cpp @ 1298:a1af054d8f75 3.0-integration

Avoid being locale-specific in XSD parse
author Chris Cannam
date Fri, 25 Nov 2016 14:26:24 +0000
parents b7b84ae5f0a7
children 622d193a00dc
line wrap: on
line diff
--- a/base/RealTimeSV.cpp	Fri Nov 25 11:37:06 2016 +0000
+++ b/base/RealTimeSV.cpp	Fri Nov 25 14:26:24 2016 +0000
@@ -85,6 +85,9 @@
     int year = 0, month = 0, day = 0, hour = 0, minute = 0;
     double second = 0.0;
 
+    char *loc = setlocale(LC_NUMERIC, 0);
+    (void)setlocale(LC_NUMERIC, "C"); // avoid strtod expecting ,-separator in DE
+
     int i = 0;
 
     const char *s = xsdd.c_str();
@@ -151,6 +154,8 @@
 
     t = t + fromSeconds(second);
 
+    setlocale(LC_NUMERIC, loc);
+    
     if (negative) {
         return -t;
     } else {