2009-10-28 17:36:40 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
#include "pbd/locale_guard.h"
|
|
|
|
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
LocaleGuard::LocaleGuard (const char* str)
|
|
|
|
{
|
2010-03-30 11:18:43 -04:00
|
|
|
old = setlocale (LC_NUMERIC, NULL);
|
|
|
|
|
|
|
|
if (old) {
|
|
|
|
old = strdup (old);
|
|
|
|
if (strcmp (old, str)) {
|
|
|
|
setlocale (LC_NUMERIC, str);
|
|
|
|
}
|
|
|
|
}
|
2009-10-28 17:36:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
LocaleGuard::~LocaleGuard ()
|
|
|
|
{
|
|
|
|
setlocale (LC_NUMERIC, old);
|
2010-03-30 11:18:43 -04:00
|
|
|
|
|
|
|
if (old) {
|
|
|
|
free ((char*)old);
|
|
|
|
}
|
2009-10-28 17:36:40 -04:00
|
|
|
}
|
|
|
|
|