Closed itoffshore closed 1 year ago
This issue can be fixed with the following patch:
see https://github.com/namecoin/namecoin/issues/72#issuecomment-42764353
Looks good to me. I've had similar issues (with a different project, though), which could be fixed in the same way, already. But please everyone on different systems (@phelix, for instance) make sure that this doesn't introduce compilation problems.
init.cpp: In function 'int main(int, char**)': init.cpp:102:28: error: 'setenv' was not declared in this scope Should maybe use #ifndef WIN32 or something.
This revised patch works on Linux
see https://github.com/namecoin/namecoin/issues/72#issuecomment-42764353
Compiles on Windows. ACK
After a bit more investigation the error was caused by my ~/,profile setting $LANG (with no language files existing) - the bitcoin developers may be adding some code to ignore unknown locales. https://github.com/bitcoin/bitcoin/issues/4147#issuecomment-42518271
Revised patch - the fix is now moved into SetUnixEnvironment()
--- namecoin-vQ.3.72/src/init.cpp
+++ namecoin-vQ.3.72/src.new/init.cpp
@@ -16,6 +16,8 @@
void rescanfornames();
+void SetUnixEnvironment();
+
CWallet* pwalletMain;
//////////////////////////////////////////////////////////////////////////////
@@ -98,6 +100,10 @@
#ifndef GUI
int main(int argc, char* argv[])
{
+ #ifndef WIN32
+ SetUnixEnvironment();
+ #endif
+
bool fRet = false;
fRet = AppInit(argc, argv);
--- namecoin-vQ.3.72/src/qt/bitcoin.cpp
+++ namecoin-vQ.3.72/src.new/qt/bitcoin.cpp
@@ -38,6 +38,8 @@
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif
+void SetUnixEnvironment();
+
// Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*)
@@ -122,6 +124,10 @@
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
+ #ifndef WIN32
+ SetUnixEnvironment();
+ #endif
+
// Command-line options take precedence:
ParseParameters(argc, argv);
--- namecoin-vQ.3.72/src/util.cpp
+++ namecoin-vQ.3.72/src.new/util.cpp
@@ -1101,3 +1101,14 @@
else
return SoftSetArg(strArg, std::string("0"));
}
+
+void SetUnixEnvironment()
+{
+ try
+ {
+ boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid
+ } catch(std::runtime_error &e)
+ {
+ setenv("LC_ALL", "C", 1); // Force C locale
+ }
+}
Am going through automated testing on Bitcoin - will send a pull request for Namecoin once the function is ready.
Any news?
Created Pull Request https://github.com/namecoin/namecoin/pull/176
Namecoin should catch the following error in init.cpp when locales are unknown:
rfc1123Time() in bitcoinrpc.cpp sets a default C environment but this can be overridden by misconfigured or unknown locales.
Namecoin should default to a C / POSIX environment if the locales are unknown / do not exist (e.g Busybox / Embedded).