summaryrefslogtreecommitdiffstats
path: root/external/libnumbertext
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /external/libnumbertext
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'external/libnumbertext')
-rw-r--r--external/libnumbertext/ExternalPackage_numbertext.mk66
-rw-r--r--external/libnumbertext/ExternalProject_libnumbertext.mk41
-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.mk23
-rw-r--r--external/libnumbertext/WinUnicodePath.patch120
9 files changed, 279 insertions, 0 deletions
diff --git a/external/libnumbertext/ExternalPackage_numbertext.mk b/external/libnumbertext/ExternalPackage_numbertext.mk
new file mode 100644
index 000000000..0116627b8
--- /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 000000000..bd96b162d
--- /dev/null
+++ b/external/libnumbertext/ExternalProject_libnumbertext.mk
@@ -0,0 +1,41 @@
+# -*- 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 $(filter AIX,$(OS)),CFLAGS="-D_LINUX_SOURCE_COMPAT") \
+ $(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 000000000..8ced22165
--- /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 000000000..e4968cf85
--- /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 000000000..a48583e43
--- /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 000000000..922f19df1
--- /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 000000000..78b384a55
--- /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 000000000..48cd2a9a2
--- /dev/null
+++ b/external/libnumbertext/UnpackedTarball_libnumbertext.mk
@@ -0,0 +1,23 @@
+# -*- 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))
+
+$(eval $(call gb_UnpackedTarball_add_patches,libnumbertext, \
+ external/libnumbertext/MSVCNonBMPBug.patch1 \
+ external/libnumbertext/WinUnicodePath.patch1 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/external/libnumbertext/WinUnicodePath.patch1 b/external/libnumbertext/WinUnicodePath.patch1
new file mode 100644
index 000000000..24a0bd580
--- /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;