summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-10-31 21:01:04 +0100
committerStephan Bergmann <sbergman@redhat.com>2018-11-01 08:19:26 +0100
commitcfdcb1bb0cf3a9fa2b342109cd581d3211e965bf (patch)
tree4b94f223aca547197fbae6c352038d40e112211e /external
parente49c42d17f50c8b0cac9db08dedc375dd5aa8a98 (diff)
external/libnumbertext: Don't depend on en_US.UTF-8 locale
Change-Id: I1c8db3d16547d8891835d0e8e849a1f53335dbf1 Reviewed-on: https://gerrit.libreoffice.org/62711 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'external')
-rw-r--r--external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch55
-rw-r--r--external/libnumbertext/UnpackedTarball_libnumbertext.mk8
2 files changed, 63 insertions, 0 deletions
diff --git a/external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch b/external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch
new file mode 100644
index 000000000000..4a454a098007
--- /dev/null
+++ b/external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch
@@ -0,0 +1,55 @@
+From 59a04cb70b261ad77baf671d5059a836ba339bbd Mon Sep 17 00:00:00 2001
+From: Stephan Bergmann <sbergman@redhat.com>
+Date: Tue, 30 Oct 2018 13:51:02 +0100
+Subject: [PATCH] Don't depend on en_US.UTF-8 locale
+
+Instead, create locale with codecvt_utf8 facet on all platforms (even if
+codecvt_utf8 is deprecated since C++17). There is no guarantee that
+"en_US.UTF-8" is a supported locale name, so the locale constructor might throw
+a runtime_error. (See the discussion in the comments to
+<https://gerrit.libreoffice.org/#/c/62508/> "Add check for en_US.utf8 locale"
+for a real-live example of issues caused by that.)
+
+(And the <codecvt> and <locale> headers apparently need to be included always,
+regardless of NUMBERTEXT_BOOST.)
+---
+ src/Numbertext.cxx | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx
+index 8cf5198..5f05b48 100644
+--- a/src/Numbertext.cxx
++++ b/src/Numbertext.cxx
+@@ -2,6 +2,8 @@
+ * 2018 (c) László Németh
+ * License: LGPL/BSD dual license */
+
++#include <codecvt>
++#include <locale>
+ #include <sstream>
+ #include <fstream>
+
+@@ -11,8 +13,6 @@
+ #include <boost/locale/encoding_utf.hpp>
+ using namespace boost;
+ #else
+- #include <codecvt>
+- #include <locale>
+ using namespace std;
+ #endif
+
+@@ -25,11 +25,7 @@ bool readfile(const std::string& filename, std::wstring& result)
+ std::wifstream wif(filename);
+ if (wif.fail())
+ return false;
+-#ifdef _MSC_VER
+ wif.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t>));
+-#else
+- wif.imbue(std::locale("en_US.UTF-8"));
+-#endif
+ std::wstringstream wss;
+ wss << wif.rdbuf();
+ result = wss.str();
+--
+2.19.1
+
diff --git a/external/libnumbertext/UnpackedTarball_libnumbertext.mk b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
index ac2a14133205..67b147393e31 100644
--- a/external/libnumbertext/UnpackedTarball_libnumbertext.mk
+++ b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
@@ -13,4 +13,12 @@ $(eval $(call gb_UnpackedTarball_set_tarball,libnumbertext,$(LIBNUMBERTEXT_TARBA
$(eval $(call gb_UnpackedTarball_update_autoconf_configs,libnumbertext))
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libnumbertext,1))
+
+# external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch is upstream at
+# <https://github.com/Numbertext/libnumbertext/pull/43>:
+$(eval $(call gb_UnpackedTarball_add_patches,libnumbertext, \
+ external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch \
+))
+
# vim: set noet sw=4 ts=4: