2009-10-28 21:36:40 +00: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 15:18:43 +00:00
|
|
|
old = setlocale (LC_NUMERIC, NULL);
|
|
|
|
|
|
|
|
|
|
if (old) {
|
|
|
|
|
old = strdup (old);
|
|
|
|
|
if (strcmp (old, str)) {
|
|
|
|
|
setlocale (LC_NUMERIC, str);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-28 21:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocaleGuard::~LocaleGuard ()
|
|
|
|
|
{
|
|
|
|
|
setlocale (LC_NUMERIC, old);
|
2010-03-30 15:18:43 +00:00
|
|
|
|
|
|
|
|
if (old) {
|
2012-08-10 15:57:09 +00:00
|
|
|
free (const_cast<char*>(old));
|
2010-03-30 15:18:43 +00:00
|
|
|
}
|
2009-10-28 21:36:40 +00:00
|
|
|
}
|
|
|
|
|
|