[Libreoffice-commits] core.git: config_host/config_libnumbertext.h.in configure.ac lingucomponent/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon May 7 09:54:43 UTC 2018
config_host/config_libnumbertext.h.in | 17 +++++++
configure.ac | 52 +++++++++++++++---------
lingucomponent/source/numbertext/numbertext.cxx | 11 ++---
3 files changed, 57 insertions(+), 23 deletions(-)
New commits:
commit 24d59c9e044dfc04013b5d364237245b314f62ed
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri May 4 10:56:58 2018 +0200
configure option to disable libnumbertext
Because we get a crash in CppunitTest_sw_odfexport when compiling with
clang >= 6.0.0
Also had to fix the ENABLE_LIBNUMBERTEXT being propogated, and the
way the code checked it.
Change-Id: I68e4a0078016d176f478ca4c1110fc296b6ca921
diff --git a/config_host/config_libnumbertext.h.in b/config_host/config_libnumbertext.h.in
new file mode 100644
index 000000000000..de757806a104
--- /dev/null
+++ b/config_host/config_libnumbertext.h.in
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_CONFIG_LIBNUMBERTEXT_H
+#define INCLUDED_CONFIG_LIBNUMBERTEXT_H
+
+#define ENABLE_LIBNUMBERTEXT 0
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configure.ac b/configure.ac
index cb9ac08c1c47..50e96287124f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1169,6 +1169,10 @@ libo_FUZZ_ARG_ENABLE(ooenv,
AS_HELP_STRING([--disable-ooenv],
[Disable ooenv for the instdir installation.]))
+libo_FUZZ_ARG_ENABLE(libnumbertext,
+ AS_HELP_STRING([--disable-libnumbertext],
+ [Disable use of numbertext external library.]))
+
AC_ARG_ENABLE(lto,
AS_HELP_STRING([--enable-lto],
[Enable link-time optimization. Suitable for (optimised) product builds. Building might take
@@ -9653,25 +9657,36 @@ AC_SUBST(SYSTEM_LIBEXTTEXTCAT_DATA)
dnl ===================================================================
dnl Checking for libnumbertext
dnl ===================================================================
-ENABLE_LIBNUMBERTEXT=TRUE
-libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.0])
-LIBNUMBERTEXT_CFLAGS="$LIBNUMBERTEXT_CFLAGS -DENABLE_LIBNUMBERTEXT"
-if test "$with_system_libnumbertext" = "yes"; then
- SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
- SYSTEM_LIBNUMBERTEXT=YES
+AC_MSG_CHECKING([whether to use libnumbertext])
+if test "$enable_libnumbertext" = "no"; then
+ AC_MSG_RESULT([no])
+ ENABLE_LIBNUMBERTEXT=
+ SYSTEM_LIBNUMBERTEXT=
else
- AC_LANG_PUSH([C++])
- save_CXXFLAGS=$CXXFLAGS
- CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
- AC_CHECK_HEADERS([codecvt regex])
- AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
- [ ENABLE_LIBNUMBERTEXT=''
- LIBNUMBERTEXT_CFLAGS=''
- AC_MSG_WARN([No system-provided libnumbertext or codecvt/regex C++11 headers (min. libstdc++ 4.9).
- Enable libnumbertext fallback (missing number to number name conversion).])
- ])
- CXXFLAGS=$save_CXXFLAGS
- AC_LANG_POP([C++])
+ AC_MSG_RESULT([yes])
+ ENABLE_LIBNUMBERTEXT=TRUE
+ libo_CHECK_SYSTEM_MODULE([libnumbertext],[LIBNUMBERTEXT],[libnumbertext >= 1.0.0])
+ if test "$with_system_libnumbertext" = "yes"; then
+ SYSTEM_LIBNUMBERTEXT_DATA=file://`$PKG_CONFIG --variable=pkgdatadir libnumbertext`
+ SYSTEM_LIBNUMBERTEXT=YES
+ else
+ SYSTEM_LIBNUMBERTEXT=
+ AC_LANG_PUSH([C++])
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+ AC_CHECK_HEADERS([codecvt regex])
+ AS_IF([test "x$ac_cv_header_codecvt" != xyes -o "x$ac_cv_header_regex" != xyes],
+ [ ENABLE_LIBNUMBERTEXT=''
+ LIBNUMBERTEXT_CFLAGS=''
+ AC_MSG_WARN([No system-provided libnumbertext or codecvt/regex C++11 headers (min. libstdc++ 4.9).
+ Enable libnumbertext fallback (missing number to number name conversion).])
+ ])
+ CXXFLAGS=$save_CXXFLAGS
+ AC_LANG_POP([C++])
+ fi
+ if test "$ENABLE_LIBNUMBERTEXT" = TRUE; then
+ AC_DEFINE(ENABLE_LIBNUMBERTEXT)
+ fi
fi
AC_SUBST(SYSTEM_LIBNUMBERTEXT)
AC_SUBST(SYSTEM_LIBNUMBERTEXT_DATA)
@@ -12732,6 +12747,7 @@ AC_CONFIG_HEADERS([config_host/config_langs.h])
AC_CONFIG_HEADERS([config_host/config_lgpl.h])
AC_CONFIG_HEADERS([config_host/config_libcxx.h])
AC_CONFIG_HEADERS([config_host/config_liblangtag.h])
+AC_CONFIG_HEADERS([config_host/config_libnumbertext.h])
AC_CONFIG_HEADERS([config_host/config_locales.h])
AC_CONFIG_HEADERS([config_host/config_mpl.h])
AC_CONFIG_HEADERS([config_host/config_kde4.h])
diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx
index ec841a4bcab2..ee3ecbab9818 100644
--- a/lingucomponent/source/numbertext/numbertext.cxx
+++ b/lingucomponent/source/numbertext/numbertext.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <config_libnumbertext.h>
#include <iostream>
#include <osl/file.hxx>
@@ -37,7 +38,7 @@
#include <sal/macros.h>
-#ifdef ENABLE_LIBNUMBERTEXT
+#if ENABLE_LIBNUMBERTEXT
#include <Numbertext.hxx>
#endif
@@ -67,7 +68,7 @@ static osl::Mutex& GetNumberTextMutex()
class NumberText_Impl : public ::cppu::WeakImplHelper<XNumberText, XServiceInfo>
{
-#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+#if ENABLE_LIBNUMBERTEXT
Numbertext m_aNumberText;
#endif
bool m_bInitialized;
@@ -114,7 +115,7 @@ void NumberText_Impl::EnsureInitialized()
#else
aPhysPath += "/";
#endif
-#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+#if ENABLE_LIBNUMBERTEXT
OString path = OUStringToOString(aPhysPath, osl_getThreadTextEncoding());
m_aNumberText.set_prefix(path.getStr());
#endif
@@ -122,7 +123,7 @@ void NumberText_Impl::EnsureInitialized()
}
OUString SAL_CALL NumberText_Impl::getNumberText(const OUString& rText, const Locale&
-#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+#if ENABLE_LIBNUMBERTEXT
rLocale)
#else
)
@@ -130,7 +131,7 @@ OUString SAL_CALL NumberText_Impl::getNumberText(const OUString& rText, const Lo
{
osl::MutexGuard aGuard(GetNumberTextMutex());
EnsureInitialized();
-#if defined(ENABLE_LIBNUMBERTEXT) || defined(SYSTEM_LIBNUMBERTEXT)
+#if ENABLE_LIBNUMBERTEXT
// libnumbertext supports Language + Country tags (separated by "_" or "-")
LanguageTag aLanguageTag(rLocale);
OUString aCode(aLanguageTag.getLanguage());
More information about the Libreoffice-commits
mailing list