aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-11-21 13:08:39 +0200
committerRiccardo Spagni <ric@spagni.net>2015-11-21 13:08:42 +0200
commit9276233b9ea58a19a5c1490b70cbec90ebcc3147 (patch)
tree8eb1cef8eadd62c4bebb4ee026eba0ab0f58fd49 /src/common/util.cpp
parentMerge pull request #492 (diff)
parentFix startup crash when using a locale boost does not like (diff)
downloadmonero-9276233b9ea58a19a5c1490b70cbec90ebcc3147.tar.xz
Merge pull request #493
f3724ae Fix startup crash when using a locale boost does not like (moneromooo-monero) 0c1dae3 i18n: allow language to be passed as a parameter (moneromooo-monero)
Diffstat (limited to 'src/common/util.cpp')
-rw-r--r--src/common/util.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 7d39bc4f4..4c1b44004 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -43,6 +43,7 @@ using namespace epee;
#else
#include <sys/utsname.h>
#endif
+#include <boost/filesystem.hpp>
namespace tools
@@ -389,4 +390,22 @@ std::string get_nix_version_display_string()
#endif
return std::error_code(code, std::system_category());
}
+
+ bool sanitize_locale()
+ {
+ // boost::filesystem throws for "invalid" locales, such as en_US.UTF-8, or kjsdkfs,
+ // so reset it here before any calls to it
+ try
+ {
+ boost::filesystem::path p {std::string("test")};
+ p /= std::string("test");
+ }
+ catch (...)
+ {
+ setenv("LC_ALL", "C", 1);
+ setenv("LANG", "C", 1);
+ return true;
+ }
+ return false;
+ }
}