Skip to content

Commit

Permalink
SetupEnvironment() - clean commit
Browse files Browse the repository at this point in the history
  • Loading branch information
itoffshore committed May 13, 2014
1 parent bfae70a commit 5248ff4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bitcoin-cli.cpp
Expand Up @@ -58,6 +58,8 @@ static bool AppInitRPC(int argc, char* argv[])

int main(int argc, char* argv[])
{
SetupEnvironment();

try
{
if(!AppInitRPC(argc, argv))
Expand Down
2 changes: 2 additions & 0 deletions src/bitcoind.cpp
Expand Up @@ -172,6 +172,8 @@ bool AppInit(int argc, char* argv[])

int main(int argc, char* argv[])
{
SetupEnvironment();

bool fRet = false;

// Connect bitcoind signal handlers
Expand Down
2 changes: 2 additions & 0 deletions src/qt/bitcoin.cpp
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/util.cpp
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions src/util.h
Expand Up @@ -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);
Expand Down

0 comments on commit 5248ff4

Please sign in to comment.