[rkward] /: Unify the bad-numeric-locale-setting-protection across platforms.
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Oct 29 13:43:33 UTC 2015
Git commit 499882a9a8a2da6cac3cc91ca9e21a6fc77deb91 by Thomas Friedrichsmeier.
Committed on 29/10/2015 at 13:40.
Pushed by tfry into branch 'master'.
Unify the bad-numeric-locale-setting-protection across platforms.
Apparently, our old way on Linux is now causing problems (preventing
language switching) on at least Ubuntu 15.04.
M +1 -0 ChangeLog
M +2 -4 rkward/rbackend/rkrbackend.cpp
M +0 -13 rkward/rkward_startup_wrapper.cpp
http://commits.kde.org/rkward/499882a9a8a2da6cac3cc91ca9e21a6fc77deb91
diff --git a/ChangeLog b/ChangeLog
index 5c93600..f1690f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Try harder to honor system locale settings
- Remove obsolete "Export tabular data" plugin (superceded by "Export Table / CSV")
- Some usability refinements to "Import CVS" plugin
- Disabled the "Import Data"-dialog, as it was considered too confusing. The individual importers are still available from the menu, separately.
diff --git a/rkward/rbackend/rkrbackend.cpp b/rkward/rbackend/rkrbackend.cpp
index a7ee840..cac7bb9 100644
--- a/rkward/rbackend/rkrbackend.cpp
+++ b/rkward/rbackend/rkrbackend.cpp
@@ -20,7 +20,6 @@
#ifdef Q_WS_WIN
# include <winsock2.h>
# include <windows.h>
-# include <locale.h>
# undef ERROR // clashes with R
# define Win32 // needed for R includes
#else
@@ -54,6 +53,7 @@ void* RKRBackend::default_global_context = 0;
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#include <locale.h>
extern "C" {
#define R_INTERFACE_PTRS 1
@@ -1014,9 +1014,7 @@ bool RKRBackend::startR () {
R_Interactive = (Rboolean) TRUE;
#endif
-#ifdef Q_WS_WIN
- setlocale (LC_NUMERIC, "C"); // something appears to mess with the locale on Windows. R will not work correctly without LC_NUMERIC=C
-#endif
+ setlocale (LC_NUMERIC, "C"); // Under some conditions something appears to mess with the locale. R will not work correctly without LC_NUMERIC=C
RBackendRequest req (false, RBackendRequest::SetParamsFromBackend);
req.params["na_real"] = NA_REAL; // may not be initialized before setup_Rmainloop!
diff --git a/rkward/rkward_startup_wrapper.cpp b/rkward/rkward_startup_wrapper.cpp
index fe6413f..6c14e32 100644
--- a/rkward/rkward_startup_wrapper.cpp
+++ b/rkward/rkward_startup_wrapper.cpp
@@ -230,19 +230,6 @@ int main (int argc, char *argv[]) {
kdeinit4_exe = findExeAtPath ("kdeinit4", QFileInfo (rkward_frontend_exe).absolutePath ());
}
if (!kdeinit4_exe.isNull ()) QProcess::execute (kdeinit4_exe, QStringList ());
-#else
-// Apparently on some systems an embedded R gets outsmarted somehow, and LC_NUMERIC is set to some dangerous value for the whole app (via SCIM)
-// To prevent this, set it here, explicitly. R does not work with wrong settings of LC_NUMERIC.
-
-// First, however, need to unset LC_ALL, if set. Instead we set LANG, so the default will be the same, where not overridden
- QString lcall = qgetenv ("LC_ALL");
- if (!lcall.isEmpty ()) {
- qputenv ("LANG", lcall.toLocal8Bit ());
- qputenv ("LC_ALL", "");
- qDebug ("Warning: Unsetting LC_ALL");
- }
-
- qputenv ("LC_NUMERIC", "C");
#endif
// Look for R:
More information about the rkward-tracker
mailing list