summaryrefslogtreecommitdiff
path: root/libs/pbd/locale_guard.cc
blob: 30fdeadebae5ee8a9ee44f9f90a55dcec3d78b52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#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 ((char*)old);
        }
}