summaryrefslogtreecommitdiffstats
path: root/external/libnumbertext
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--external/libnumbertext/ExternalPackage_numbertext.mk66
-rw-r--r--external/libnumbertext/ExternalProject_libnumbertext.mk40
-rw-r--r--external/libnumbertext/MSVCNonBMPBug.patch169
-rw-r--r--external/libnumbertext/Makefile7
-rw-r--r--external/libnumbertext/Module_libnumbertext.mk28
-rw-r--r--external/libnumbertext/README3
-rw-r--r--external/libnumbertext/StaticLibrary_libnumbertext.mk22
-rw-r--r--external/libnumbertext/UnpackedTarball_libnumbertext.mk27
-rw-r--r--external/libnumbertext/WinUnicodePath.patch120
-rw-r--r--external/libnumbertext/deprecated.patch.043
10 files changed, 325 insertions, 0 deletions
diff --git a/external/libnumbertext/ExternalPackage_numbertext.mk b/external/libnumbertext/ExternalPackage_numbertext.mk
new file mode 100644
index 0000000000..0116627b87
--- /dev/null
+++ b/external/libnumbertext/ExternalPackage_numbertext.mk
@@ -0,0 +1,66 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalPackage_ExternalPackage,libnumbertext_numbertext,libnumbertext))
+
+$(eval $(call gb_ExternalPackage_add_unpacked_files,libnumbertext_numbertext,$(LIBO_SHARE_FOLDER)/numbertext,\
+ data/af.sor \
+ data/bg.sor \
+ data/ca.sor \
+ data/cs.sor \
+ data/da.sor \
+ data/de.sor \
+ data/el.sor \
+ data/en.sor \
+ data/eo.sor \
+ data/es.sor \
+ data/et.sor \
+ data/fa.sor \
+ data/fi.sor \
+ data/fr.sor \
+ data/fr.sor \
+ data/ga.sor \
+ data/gl.sor \
+ data/he.sor \
+ data/hr.sor \
+ data/hu.sor \
+ data/hu_Hung.sor \
+ data/id.sor \
+ data/is.sor \
+ data/it.sor \
+ data/ja.sor \
+ data/ko.sor \
+ data/lb.sor \
+ data/lg.sor \
+ data/lt.sor \
+ data/lv.sor \
+ data/mr.sor \
+ data/ms.sor \
+ data/mt.sor \
+ data/no.sor \
+ data/nl.sor \
+ data/pl.sor \
+ data/pt.sor \
+ data/Roman.sor \
+ data/ro.sor \
+ data/ru.sor \
+ data/sh.sor \
+ data/sl.sor \
+ data/sq.sor \
+ data/sr.sor \
+ data/Suzhou.sor \
+ data/sv.sor \
+ data/th.sor \
+ data/tr.sor \
+ data/uk.sor \
+ data/vi.sor \
+ data/zh.sor \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/ExternalProject_libnumbertext.mk b/external/libnumbertext/ExternalProject_libnumbertext.mk
new file mode 100644
index 0000000000..71376be45d
--- /dev/null
+++ b/external/libnumbertext/ExternalProject_libnumbertext.mk
@@ -0,0 +1,40 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_ExternalProject_ExternalProject,libnumbertext))
+
+$(eval $(call gb_ExternalProject_use_externals,libnumbertext, \
+))
+
+$(eval $(call gb_ExternalProject_register_targets,libnumbertext,\
+ build \
+))
+
+libnumbertext_CXXFLAGS=$(CXXFLAGS) $(CXXFLAGS_CXX11) $(gb_EMSCRIPTEN_CXXFLAGS)
+
+libnumbertext_CPPFLAGS+=$(gb_COMPILERDEFS_STDLIB_DEBUG) $(gb_EMSCRIPTEN_CPPFLAGS)
+
+$(call gb_ExternalProject_get_state_target,libnumbertext,build):
+ $(call gb_Trace_StartRange,libnumbertext,EXTERNAL)
+ $(call gb_ExternalProject_run,build,\
+ LIBS="$(gb_STDLIBS) $(LIBS)" \
+ $(SHELL) $(gb_RUN_CONFIGURE) ./configure --disable-shared --with-pic \
+ $(if $(verbose),--disable-silent-rules,--enable-silent-rules) \
+ $(if $(ENABLE_WERROR),--enable-werror,--disable-werror) \
+ $(gb_CONFIGURE_PLATFORMS) \
+ $(if $(libnumbertext_CPPFLAGS),CPPFLAGS='$(libnumbertext_CPPFLAGS)') \
+ CXXFLAGS="$(libnumbertext_CXXFLAGS) \
+ $(call gb_ExternalProject_get_build_flags,libnumbertext) \
+ $(gb_VISIBILITY_FLAGS) $(gb_VISIBILITY_FLAGS_CXX)" \
+ LDFLAGS="$(call gb_ExternalProject_get_link_flags,libnumbertext)" \
+ && cd src && $(MAKE) \
+ )
+ $(call gb_Trace_EndRange,libnumbertext,EXTERNAL)
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/MSVCNonBMPBug.patch1 b/external/libnumbertext/MSVCNonBMPBug.patch1
new file mode 100644
index 0000000000..8ced22165b
--- /dev/null
+++ b/external/libnumbertext/MSVCNonBMPBug.patch1
@@ -0,0 +1,69 @@
+MSVC's std::codecvt_utf8 has a bug converting non-BMP codepoints like U+10CFA.
+Use MultiByteToWideChar/WideCharToMultiByte instead on Windows.
+
+diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx
+index 5f05b48579af..eb83e59f366f 100755
+--- a/src/Numbertext.cxx
++++ b/src/Numbertext.cxx
+@@ -7,6 +7,10 @@
+ #include <sstream>
+ #include <fstream>
+
++#ifdef _WIN32
++#include <Windows.h>
++#endif
++
+ #include "Numbertext.hxx"
+
+ #ifdef NUMBERTEXT_BOOST
+@@ -22,6 +26,14 @@
+
+ bool readfile(const std::string& filename, std::wstring& result)
+ {
++#ifdef _WIN32
++ std::ifstream ifs(filename);
++ if (ifs.fail())
++ return false;
++ std::stringstream ss;
++ ss << ifs.rdbuf();
++ result = Numbertext::string2wstring(ss.str());
++#else
+ std::wifstream wif(filename);
+ if (wif.fail())
+ return false;
+@@ -29,6 +44,7 @@ bool readfile(const std::string& filename, std::wstring& result)
+ std::wstringstream wss;
+ wss << wif.rdbuf();
+ result = wss.str();
++#endif
+ return true;
+ }
+
+@@ -99,7 +112,12 @@
+
+ std::wstring Numbertext::string2wstring(const std::string& s)
+ {
+-#ifndef NUMBERTEXT_BOOST
++#ifdef _WIN32
++ int nSize = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, nullptr, 0);
++ std::unique_ptr<wchar_t[]> wstr(new wchar_t[nSize]);
++ MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, wstr.get(), nSize);
++ return wstr.get();
++#elif !defined NUMBERTEXT_BOOST
+ typedef std::codecvt_utf8<wchar_t> convert_type;
+ std::wstring_convert<convert_type, wchar_t> converter;
+ return converter.from_bytes( s );
+@@ -110,7 +128,12 @@
+
+ std::string Numbertext::wstring2string(const std::wstring& s)
+ {
+-#ifndef NUMBERTEXT_BOOST
++#ifdef _WIN32
++ int nSize = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, nullptr, 0, nullptr, nullptr);
++ std::unique_ptr<char[]> str(new char[nSize]);
++ WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, str.get(), nSize, nullptr, nullptr);
++ return str.get();
++#elif !defined NUMBERTEXT_BOOST
+ typedef std::codecvt_utf8<wchar_t> convert_type;
+ std::wstring_convert<convert_type, wchar_t> converter;
+ return converter.to_bytes( s );
diff --git a/external/libnumbertext/Makefile b/external/libnumbertext/Makefile
new file mode 100644
index 0000000000..e4968cf85f
--- /dev/null
+++ b/external/libnumbertext/Makefile
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/Module_libnumbertext.mk b/external/libnumbertext/Module_libnumbertext.mk
new file mode 100644
index 0000000000..a48583e439
--- /dev/null
+++ b/external/libnumbertext/Module_libnumbertext.mk
@@ -0,0 +1,28 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Module_Module,libnumbertext))
+
+$(eval $(call gb_Module_add_targets,libnumbertext,\
+ ExternalPackage_numbertext \
+ UnpackedTarball_libnumbertext \
+))
+ifeq ($(COM),MSC)
+$(eval $(call gb_Module_add_targets,libnumbertext,\
+ StaticLibrary_libnumbertext \
+))
+else
+
+$(eval $(call gb_Module_add_targets,libnumbertext,\
+ ExternalProject_libnumbertext \
+))
+
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/README b/external/libnumbertext/README
new file mode 100644
index 0000000000..922f19df1d
--- /dev/null
+++ b/external/libnumbertext/README
@@ -0,0 +1,3 @@
+Number to Number Name Conversion Library
+
+It is hosted at: [https://github.com/Numbertext/libnumbertext]
diff --git a/external/libnumbertext/StaticLibrary_libnumbertext.mk b/external/libnumbertext/StaticLibrary_libnumbertext.mk
new file mode 100644
index 0000000000..78b384a55d
--- /dev/null
+++ b/external/libnumbertext/StaticLibrary_libnumbertext.mk
@@ -0,0 +1,22 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_StaticLibrary_StaticLibrary,libnumbertext))
+
+$(eval $(call gb_StaticLibrary_use_unpacked,libnumbertext,libnumbertext))
+
+$(eval $(call gb_StaticLibrary_set_warnings_disabled,libnumbertext))
+
+$(eval $(call gb_StaticLibrary_add_generated_exception_objects,libnumbertext,\
+ UnpackedTarball/libnumbertext/src/Soros \
+ UnpackedTarball/libnumbertext/src/Numbertext \
+))
+
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/UnpackedTarball_libnumbertext.mk b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
new file mode 100644
index 0000000000..162fafdb6a
--- /dev/null
+++ b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
@@ -0,0 +1,27 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_UnpackedTarball_UnpackedTarball,libnumbertext))
+
+$(eval $(call gb_UnpackedTarball_set_tarball,libnumbertext,$(LIBNUMBERTEXT_TARBALL)))
+
+$(eval $(call gb_UnpackedTarball_update_autoconf_configs,libnumbertext))
+
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libnumbertext,1))
+
+# EmptyString.patch1 submitted as
+# https://github.com/Numbertext/libnumbertext/pull/95
+
+$(eval $(call gb_UnpackedTarball_add_patches,libnumbertext, \
+ external/libnumbertext/MSVCNonBMPBug.patch1 \
+ external/libnumbertext/WinUnicodePath.patch1 \
+ external/libnumbertext/deprecated.patch.0 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/WinUnicodePath.patch1 b/external/libnumbertext/WinUnicodePath.patch1
new file mode 100644
index 0000000000..24a0bd5800
--- /dev/null
+++ b/external/libnumbertext/WinUnicodePath.patch1
@@ -0,0 +1,20 @@
+To allow opening files on Unicode paths on Windpws, expect passed 8-bit
+strings to be UTF-8-encoded, and convert them to wchar_t. Fallback to
+ACP strings for backward compatibility.
+
+diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx
+--- a/src/Numbertext.cxx
++++ b/src/Numbertext.cxx
+@@ -27,7 +27,11 @@
+ bool readfile(const std::string& filename, std::wstring& result)
+ {
+ #ifdef _WIN32
+- std::ifstream ifs(filename);
++ // First try to convert from UTF-8
++ std::ifstream ifs(Numbertext::string2wstring(filename));
++ // Fallback to ACP string for backward compatibility
++ if (ifs.fail())
++ ifs.open(filename);
+ if (ifs.fail())
+ return false;
+ std::stringstream ss;
diff --git a/external/libnumbertext/deprecated.patch.0 b/external/libnumbertext/deprecated.patch.0
new file mode 100644
index 0000000000..8ee86ac135
--- /dev/null
+++ b/external/libnumbertext/deprecated.patch.0
@@ -0,0 +1,43 @@
+--- src/Numbertext.cxx
++++ src/Numbertext.cxx
+@@ -41,7 +41,14 @@
+ std::wifstream wif(filename);
+ if (wif.fail())
+ return false;
++#if defined __GNUC__
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
++#endif
+ wif.imbue(std::locale(std::locale(), new std::codecvt_utf8<wchar_t>));
++#if defined __GNUC__
++#pragma GCC diagnostic pop
++#endif
+ std::wstringstream wss;
+ wss << wif.rdbuf();
+ result = wss.str();
+@@ -122,8 +129,15 @@
+ MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, wstr.get(), nSize);
+ return wstr.get();
+ #elif !defined NUMBERTEXT_BOOST
++#if defined __GNUC__
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
++#endif
+ typedef std::codecvt_utf8<wchar_t> convert_type;
+ std::wstring_convert<convert_type, wchar_t> converter;
++#if defined __GNUC__
++#pragma GCC diagnostic pop
++#endif
+ return converter.from_bytes( s );
+ #else
+ return ::locale::conv::utf_to_utf<wchar_t>(s.c_str(), s.c_str() + s.size());
+@@ -138,6 +152,9 @@
+ WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, str.get(), nSize, nullptr, nullptr);
+ return str.get();
+ #elif !defined NUMBERTEXT_BOOST
++#if defined __GNUC__
++#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
++#endif
+ typedef std::codecvt_utf8<wchar_t> convert_type;
+ std::wstring_convert<convert_type, wchar_t> converter;
+ return converter.to_bytes( s );