aboutsummaryrefslogtreecommitdiffstats
path: root/community/supertux/5f8f6e909b42367c677590e2d0464400dff375fd.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/supertux/5f8f6e909b42367c677590e2d0464400dff375fd.patch')
-rw-r--r--community/supertux/5f8f6e909b42367c677590e2d0464400dff375fd.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/community/supertux/5f8f6e909b42367c677590e2d0464400dff375fd.patch b/community/supertux/5f8f6e909b42367c677590e2d0464400dff375fd.patch
new file mode 100644
index 0000000000..9541cb941d
--- /dev/null
+++ b/community/supertux/5f8f6e909b42367c677590e2d0464400dff375fd.patch
@@ -0,0 +1,49 @@
+From 5f8f6e909b42367c677590e2d0464400dff375fd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=89rico=20Rolim?= <erico.erc@gmail.com>
+Date: Wed, 9 Dec 2020 16:22:22 -0300
+Subject: [PATCH] supertux/main: add try-catch block around locale
+ initialization.
+
+Unfortunately, libstdc++'s locale implementation is platform specific
+(unlike libcxx, which has a single universal implementation), and its
+"generic" implementation, from 2003, claims to support only the "C"
+locale, and raises an exception if one tries to use a locale other than
+"C". We catch that exception and allow the application to proceed on
+such systems, even though it is very much not ideal.
+
+Also leave note for future code changes.
+
+Fixes #1564.
+---
+ src/supertux/main.cpp | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp
+index ad5e3fde69..efd655855b 100644
+--- a/src/supertux/main.cpp
++++ b/src/supertux/main.cpp
+@@ -563,10 +563,20 @@ Main::run(int argc, char** argv)
+ _wfreopen(w_errpath.c_str(), L"a", stderr);
+ #endif
+
+- // Create and install global locale
+- std::locale::global(boost::locale::generator().generate(""));
+- // Make boost.filesystem use it
+- boost::filesystem::path::imbue(std::locale());
++ // Create and install global locale - this can fail on some situations:
++ // - with bad values for env vars (LANG, LC_ALL, ...)
++ // - targets where libstdc++ uses its generic locales code (https://gcc.gnu.org/legacy-ml/libstdc++/2003-02/msg00345.html)
++ // NOTE: when moving to C++ >= 17, keep the try-catch block, but use std::locale:global(std::locale(""));
++ try
++ {
++ std::locale::global(boost::locale::generator().generate(""));
++ // Make boost.filesystem use it
++ boost::filesystem::path::imbue(std::locale());
++ }
++ catch(const std::runtime_error& err)
++ {
++ std::cout << "Warning: " << err.what() << std::endl;
++ }
+
+ int result = 0;
+