summaryrefslogtreecommitdiff
path: root/libs/pbd/locale_guard.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-05-07 12:15:12 +0200
committerRobin Gareus <robin@gareus.org>2016-05-07 12:15:12 +0200
commitf445ba8bdcc74943926817a8627741d1fc8dcb3f (patch)
treec2bff13985cac945389f7de17839c9244a1b7b53 /libs/pbd/locale_guard.cc
parent3d7cbe9d942e6dd37c68be6869b31e3de46ef39f (diff)
locale debugging
Diffstat (limited to 'libs/pbd/locale_guard.cc')
-rw-r--r--libs/pbd/locale_guard.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/libs/pbd/locale_guard.cc b/libs/pbd/locale_guard.cc
index 6e95ea9dcd..b4225d3875 100644
--- a/libs/pbd/locale_guard.cc
+++ b/libs/pbd/locale_guard.cc
@@ -22,8 +22,10 @@
#include <assert.h>
#include <locale.h>
-#include "pbd/locale_guard.h"
+#include "pbd/compose.h"
+#include "pbd/debug.h"
#include "pbd/error.h"
+#include "pbd/locale_guard.h"
using namespace PBD;
@@ -39,17 +41,17 @@ LocaleGuard::LocaleGuard ()
{
char* actual = setlocale (LC_NUMERIC, NULL);
if (strcmp ("C", actual)) {
+ DEBUG_TRACE (DEBUG::Locale, string_compose ("LG: change locale from '%1' to 'C'\n", actual));
/* purpose of LocaleGuard is to make sure we're using "C" for
the numeric locale during its lifetime, so make it so.
*/
old_c = strdup (actual);
- /* this changes both C++ and C locale (according to specs) */
+ /* this changes both C++ and C locale */
std::locale::global (std::locale (std::locale::classic(), "C", std::locale::numeric));
- /* ..but maybe not.. */
- setlocale (LC_NUMERIC, "C");
}
if (old_cpp != std::locale::classic ()) {
PBD::error << "LocaleGuard: initial C++ locale is not 'C'. Expect non-portable session files.\n";
+ DEBUG_TRACE (DEBUG::Locale, "LG: initial C++ locale is not 'C'. Expect non-portable session files.\n");
}
}
@@ -67,11 +69,14 @@ LocaleGuard::~LocaleGuard ()
*/
if (old_cpp != std::locale::classic ()) {
PBD::error << "LocaleGuard: someone (a plugin) changed the C++ locale, expect non-portable session files.\n";
+ DEBUG_TRACE (DEBUG::Locale, "LG: someone (a plugin) changed the C++ locale, expect non-portable session files.\n");
}
std::locale::global (old_cpp);
+ DEBUG_TRACE (DEBUG::Locale, string_compose ("LG: restore C++ locale: '%1'\n", old_cpp.name ()));
}
if (old_c && strcmp (old_c, actual)) {
setlocale (LC_NUMERIC, old_c);
+ DEBUG_TRACE (DEBUG::Locale, string_compose ("LG: restore C locale: '%1'\n", old_c));
}
free (old_c);
}