aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Cardall <developer@it-offshore.co.uk>2014-05-13 10:15:00 +0000
committerWladimir J. van der Laan <laanwj@gmail.com>2014-05-19 15:16:33 +0200
commit337459b96b4fb270db0a65b7ce12341891ae218a (patch)
treec453fee5f6c582f585757917e3562e6dbc5a6df3
parent4b8a3ab877ceef0751839deafa401b01c492f7b1 (diff)
SetupEnvironment() - clean commit
Rebased-By: Wladimir J. van der Laan <laanwj@gmail.com> Rebased-From: 5248ff4
-rw-r--r--src/bitcoin-cli.cpp2
-rw-r--r--src/bitcoind.cpp2
-rw-r--r--src/qt/bitcoin.cpp2
-rw-r--r--src/util.cpp16
-rw-r--r--src/util.h1
5 files changed, 23 insertions, 0 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index ca6950a162..ce9e7a4027 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -58,6 +58,8 @@ static bool AppInitRPC(int argc, char* argv[])
int main(int argc, char* argv[])
{
+ SetupEnvironment();
+
try
{
if(!AppInitRPC(argc, argv))
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 17aa0c9d4b..78c8b2ba0e 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -172,6 +172,8 @@ bool AppInit(int argc, char* argv[])
int main(int argc, char* argv[])
{
+ SetupEnvironment();
+
bool fRet = false;
// Connect bitcoind signal handlers
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 31716ab825..45d7a52889 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -459,6 +459,8 @@ WId BitcoinApplication::getMainWinId() const
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
+ SetupEnvironment();
+
/// 1. Parse command-line options. These take precedence over anything else.
// Command-line options take precedence:
ParseParameters(argc, argv);
diff --git a/src/util.cpp b/src/util.cpp
index a919b4b854..521d54191f 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -1427,3 +1427,19 @@ void RenameThread(const char* name)
#endif
}
+void SetupEnvironment()
+{
+ #ifndef WIN32
+ try
+ {
+ #if BOOST_FILESYSTEM_VERSION == 3
+ boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid
+ #else // boost filesystem v2
+ std::locale(); // Raises runtime error if current locale is invalid
+ #endif
+ } catch(std::runtime_error &e)
+ {
+ setenv("LC_ALL", "C", 1); // Force C locale
+ }
+ #endif
+}
diff --git a/src/util.h b/src/util.h
index 55d9308ab6..031dbd9011 100644
--- a/src/util.h
+++ b/src/util.h
@@ -106,6 +106,7 @@ extern volatile bool fReopenDebugLog;
void RandAddSeed();
void RandAddSeedPerfmon();
+void SetupEnvironment();
/* Return true if log accepts specified category */
bool LogAcceptCategory(const char* category);