summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-20 20:45:32 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-20 20:45:32 +0100
commitf20cd70a9afc28f785ef4a50c875ccf6c3729462 (patch)
tree1d8e81f8b75e8ac070c6ecb5f4b9af28fc97f6cc /src/lib/util.cc
parent2c1533e4e5568a8bb4f538cfb845d07b0637380c (diff)
Import Ardour's LocaleGuard to fix problems with saving decimals to metadata (#119).
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 557e9a34b..e43b598ab 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -1018,3 +1018,22 @@ FrameRateConversion::FrameRateConversion (float source, int dcp)
}
}
}
+
+LocaleGuard::LocaleGuard ()
+ : _old (0)
+{
+ char const * old = setlocale (LC_NUMERIC, 0);
+
+ if (old) {
+ _old = strdup (old);
+ if (strcmp (_old, "POSIX")) {
+ setlocale (LC_NUMERIC, "POSIX");
+ }
+ }
+}
+
+LocaleGuard::~LocaleGuard ()
+{
+ setlocale (LC_NUMERIC, _old);
+ free (_old);
+}