* libardour uses ARDOUR::nframes_t and ARDOUR::nframes64_t explicitly in headers
[ardour.git] / libs / pbd / locale_guard.cc
diff --git a/libs/pbd/locale_guard.cc b/libs/pbd/locale_guard.cc
new file mode 100644 (file)
index 0000000..7d6c070
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#include "pbd/locale_guard.h"
+
+using namespace PBD;
+
+LocaleGuard::LocaleGuard (const char* str)
+{
+       old = strdup (setlocale (LC_NUMERIC, NULL));
+       if (strcmp (old, str)) {
+               setlocale (LC_NUMERIC, str);
+       }
+}
+
+LocaleGuard::~LocaleGuard ()
+{
+       setlocale (LC_NUMERIC, old);
+       free ((char*)old);
+}
+