# HG changeset patch # User Chris Cannam # Date 1191590807 0 # Node ID 15b47d30c085a1cdc00a69064ebc0312fd9ffb34 # Parent 726b32522e3f9c33c2f785da7155c4560a14ec72 * Ensure locale from environment is retained after plugin load, not just C locale diff -r 726b32522e3f -r 15b47d30c085 plugin/RealTimePluginFactory.cpp --- a/plugin/RealTimePluginFactory.cpp Thu Oct 04 16:34:11 2007 +0000 +++ b/plugin/RealTimePluginFactory.cpp Fri Oct 05 13:26:47 2007 +0000 @@ -25,6 +25,8 @@ #include "LADSPAPluginFactory.h" #include "DSSIPluginFactory.h" +#include "system/System.h" + #include int RealTimePluginFactory::m_sampleRate = 48000; @@ -98,7 +100,8 @@ } // Plugins can change the locale, revert it to default. - setlocale(LC_ALL, "C"); + RestoreStartupLocale(); + return rv; } diff -r 726b32522e3f -r 15b47d30c085 system/System.cpp --- 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)); } diff -r 726b32522e3f -r 15b47d30c085 system/System.h --- a/system/System.h Thu Oct 04 16:34:11 2007 +0000 +++ b/system/System.h Fri Oct 05 13:26:47 2007 +0000 @@ -105,6 +105,9 @@ // on the partition containing the given path. Return -1 if unknown. extern int GetDiscSpaceMBAvailable(const char *path); +extern void StoreStartupLocale(); +extern void RestoreStartupLocale(); + #include extern double mod(double x, double y);