aboutsummaryrefslogtreecommitdiffstats
path: root/testing/namecoin/31-set-default-env-function.patch
blob: 6615ffb3bbbc8f648afe9923632a6e6426357c7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--- namecoin-vQ.3.72/src/init.cpp
+++ namecoin-vQ.3.72/src/init.cpp
@@ -98,6 +98,10 @@
 #ifndef GUI
 int main(int argc, char* argv[])
 {
+    #ifndef WIN32
+	SetupEnvironment();
+    #endif
+
     bool fRet = false;
     fRet = AppInit(argc, argv);

--- namecoin-vQ.3.72/src/qt/bitcoin.cpp
+++ namecoin-vQ.3.72/src/qt/bitcoin.cpp
@@ -122,6 +122,10 @@
 #ifndef BITCOIN_QT_TEST
 int main(int argc, char *argv[])
 {
+    #ifndef WIN32
+	SetupEnvironment();
+    #endif
+
     // Command-line options take precedence:
     ParseParameters(argc, argv);

--- namecoin-vQ.3.72/src/util.cpp
+++ namecoin-vQ.3.72/src/util.cpp
@@ -1101,3 +1101,20 @@
     else
         return SoftSetArg(strArg, std::string("0"));
 }
+
+#ifndef WIN32
+void SetupEnvironment()
+{
+    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
--- namecoin-vQ.3.72/src/util.h
+++ namecoin-vQ.3.72/src/util.h
@@ -198,6 +198,8 @@

 void RandAddSeed();
 void RandAddSeedPerfmon();
+void SetupEnvironment();
+
 int OutputDebugStringF(const char* pszFormat, ...);
 int my_snprintf(char* buffer, size_t limit, const char* format, ...);