From cfdcb1bb0cf3a9fa2b342109cd581d3211e965bf Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 31 Oct 2018 21:01:04 +0100 Subject: 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 --- .../0001-Don-t-depend-on-en_US.UTF-8-locale.patch | 55 ++++++++++++++++++++++ .../libnumbertext/UnpackedTarball_libnumbertext.mk | 8 ++++ 2 files changed, 63 insertions(+) create mode 100644 external/libnumbertext/0001-Don-t-depend-on-en_US.UTF-8-locale.patch (limited to 'external/libnumbertext') 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 +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 + "Add check for en_US.utf8 locale" +for a real-live example of issues caused by that.) + +(And the and 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 ++#include + #include + #include + +@@ -11,8 +13,6 @@ + #include + using namespace boost; + #else +- #include +- #include + 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)); +-#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 +# : +$(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: -- cgit