diff system/System.cpp @ 303:15b47d30c085

* Ensure locale from environment is retained after plugin load, not just C locale
author Chris Cannam
date Fri, 05 Oct 2007 13:26:47 +0000
parents 7033e188b2b2
children 65311fb86166
line wrap: on
line diff
--- a/system/System.cpp	Thu Oct 04 16:34:11 2007 +0000
+++ b/system/System.cpp	Fri Oct 05 13:26:47 2007 +0000
@@ -265,7 +265,27 @@
     }
 #endif
 }
-    
+
+static char *startupLocale = 0;
+
+void
+StoreStartupLocale()
+{
+    char *loc = setlocale(LC_ALL, 0);
+    if (!loc) return;
+    if (startupLocale) free(startupLocale);
+    startupLocale = strdup(loc);
+}
+
+void
+RestoreStartupLocale()
+{
+    if (!startupLocale) {
+        setlocale(LC_ALL, "");
+    } else {
+        setlocale(LC_ALL, startupLocale);
+    }
+}
 
 double mod(double x, double y) { return x - (y * floor(x / y)); }
 float modf(float x, float y) { return x - (y * floorf(x / y)); }