diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-05-19 15:08:28 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-05-19 15:08:48 +0200 |
commit | c26acfc308482bac901ab3c7368c951514f13429 (patch) | |
tree | 2d5b257643abc48899eb9b4a315a3de375cadc99 /src | |
parent | a99f9be0ebd4062fd73648d525b2c7961f845580 (diff) | |
parent | 5248ff40997c64cc0fde7aaa67cf94dd38b14899 (diff) |
Merge pull request #4174
5248ff4 SetupEnvironment() - clean commit (Stuart Cardall)
Diffstat (limited to 'src')
-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 205af738d5..aa3adf89ec 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1384,3 +1384,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 52ca6e579b..97185073e0 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); |