13
0
livetrax/libs/pbd/locale_guard.cc
Paul Davis 760ccbabfb add -Wpointer-arith -Wcast-qual -Wcast-align and others to compile flags, and fix const cast warnings generated by new flags
git-svn-id: svn://localhost/ardour2/branches/3.0@13124 d708f5d6-7413-0410-9779-e7cbd77b26cf
2012-08-10 15:57:09 +00:00

30 lines
518 B
C++

#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include "pbd/locale_guard.h"
using namespace PBD;
LocaleGuard::LocaleGuard (const char* str)
{
old = setlocale (LC_NUMERIC, NULL);
if (old) {
old = strdup (old);
if (strcmp (old, str)) {
setlocale (LC_NUMERIC, str);
}
}
}
LocaleGuard::~LocaleGuard ()
{
setlocale (LC_NUMERIC, old);
if (old) {
free (const_cast<char*>(old));
}
}