void-packages/srcpkgs/supertux2/patches/locale.patch

37 lines
1.2 KiB
Diff

commit 4380f504fbd51aa9ef7eb222b0bced481402fa7d
Author: Érico Rolim <erico.erc@gmail.com>
Date: Wed Dec 9 16:22:22 2020 -0300
supertux/main: add try-catch for locale initialization.
Fixes #1564.
diff --git src/supertux/main.cpp src/supertux/main.cpp
index ad5e3fde6..c33627e18 100644
--- src/supertux/main.cpp
+++ src/supertux/main.cpp
@@ -563,10 +563,19 @@ 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 setups:
+ // - with bad LANG values
+ // - targets where libstdc++ uses its generic locales code (https://gcc.gnu.org/legacy-ml/libstdc++/2003-02/msg00345.html)
+ 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;