diff options
author | Stuart Cardall <developer@it-offshore.co.uk> | 2014-05-13 10:15:00 +0000 |
---|---|---|
committer | Stuart Cardall <developer@it-offshore.co.uk> | 2014-05-13 10:15:00 +0000 |
commit | 5248ff40997c64cc0fde7aaa67cf94dd38b14899 (patch) | |
tree | d40c2b2e3ab9d2406e8ddaa312ef6295af950485 | |
parent | bfae70aae686e4631090bd0064fa6ac6eeed17d2 (diff) |
SetupEnvironment() - clean commit
-rw-r--r-- | src/bitcoin-cli.cpp | 2 | ||||
-rw-r--r-- | src/bitcoind.cpp | 2 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 2 | ||||
-rw-r--r-- | src/util.cpp | 16 | ||||
-rw-r--r-- | src/util.h | 1 |
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 00e29446d5..2e8500eeae 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1404,3 +1404,19 @@ bool ParseInt32(const std::string& str, int32_t *out) n <= std::numeric_limits<int32_t>::max(); } +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 27a08716dd..b252295e76 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); |