aboutsummaryrefslogtreecommitdiffstats
path: root/community/namecoin/31-set-default-env-function.patch
blob: 9af0446cfd2ffc5b1b941b679b196ac26357c9a6 (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-nc*/src/init.cpp
+++ namecoin-nc*/src/init.cpp
@@ -99,6 +99,10 @@
 #ifndef GUI
 int main(int argc, char* argv[])
 {
+    #ifndef WIN32
+    	SetupEnvironment();
+    #endif
+
     bool fRet = false;
     fRet = AppInit(argc, argv);
 
--- namecoin-nc*/src/qt/bitcoin.cpp
+++ namecoin-nc*/src/qt/bitcoin.cpp
@@ -124,6 +124,10 @@
 #ifndef BITCOIN_QT_TEST
 int main(int argc, char *argv[])
 {
+    #ifndef WIN32
+	SetupEnvironment();
+    #endif
+
     // Command-line options take precedence:
     ParseParameters(argc, argv);
 
--- namecoin-nc*/src/util.cpp
+++ namecoin-nc*/src/util.cpp
@@ -1114,3 +1114,20 @@
     }
     return true;
 }
+
+#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-nc0.3.76/src/util.h
+++ namecoin-nc0.3.76/src.new/util.h
@@ -211,6 +211,7 @@
 
 void RandAddSeed();
 void RandAddSeedPerfmon();
+void SetupEnvironment();
 int OutputDebugStringF(const char* pszFormat, ...);
 int my_snprintf(char* buffer, size_t limit, const char* format, ...);