Kaydet (Commit) 24d59c9e authored tarafından Noel Grandin's avatar Noel Grandin

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
üst 4d7867c3
/* -*- 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: */
......@@ -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])
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment