From 337459b96b4fb270db0a65b7ce12341891ae218a Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Tue, 13 May 2014 10:15:00 +0000 Subject: SetupEnvironment() - clean commit Rebased-By: Wladimir J. van der Laan Rebased-From: 5248ff4 --- src/bitcoin-cli.cpp | 2 ++ src/bitcoind.cpp | 2 ++ src/qt/bitcoin.cpp | 2 ++ src/util.cpp | 16 ++++++++++++++++ src/util.h | 1 + 5 files changed, 23 insertions(+) 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); -- cgit v1.2.3