Skip to content

Commit c26acfc

Browse files
committed
Merge pull request #4174
5248ff4 SetupEnvironment() - clean commit (Stuart Cardall)
2 parents a99f9be + 5248ff4 commit c26acfc

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

src/bitcoin-cli.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static bool AppInitRPC(int argc, char* argv[])
5858

5959
int main(int argc, char* argv[])
6060
{
61+
SetupEnvironment();
62+
6163
try
6264
{
6365
if(!AppInitRPC(argc, argv))

src/bitcoind.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ bool AppInit(int argc, char* argv[])
172172

173173
int main(int argc, char* argv[])
174174
{
175+
SetupEnvironment();
176+
175177
bool fRet = false;
176178

177179
// Connect bitcoind signal handlers

src/qt/bitcoin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ WId BitcoinApplication::getMainWinId() const
459459
#ifndef BITCOIN_QT_TEST
460460
int main(int argc, char *argv[])
461461
{
462+
SetupEnvironment();
463+
462464
/// 1. Parse command-line options. These take precedence over anything else.
463465
// Command-line options take precedence:
464466
ParseParameters(argc, argv);

src/util.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,3 +1384,19 @@ bool ParseInt32(const std::string& str, int32_t *out)
13841384
n <= std::numeric_limits<int32_t>::max();
13851385
}
13861386

1387+
void SetupEnvironment()
1388+
{
1389+
#ifndef WIN32
1390+
try
1391+
{
1392+
#if BOOST_FILESYSTEM_VERSION == 3
1393+
boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid
1394+
#else // boost filesystem v2
1395+
std::locale(); // Raises runtime error if current locale is invalid
1396+
#endif
1397+
} catch(std::runtime_error &e)
1398+
{
1399+
setenv("LC_ALL", "C", 1); // Force C locale
1400+
}
1401+
#endif
1402+
}

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ extern volatile bool fReopenDebugLog;
106106

107107
void RandAddSeed();
108108
void RandAddSeedPerfmon();
109+
void SetupEnvironment();
109110

110111
/* Return true if log accepts specified category */
111112
bool LogAcceptCategory(const char* category);

0 commit comments

Comments
 (0)