mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-24 10:40:48 +00:00
Support new hunspell C++ ABI if LyX is built against hunspell >= 1.5
Fixes: #10547
This commit is contained in:
parent
d25762da35
commit
10335b93b4
2
3rdparty/hunspell/Makefile.am
vendored
2
3rdparty/hunspell/Makefile.am
vendored
@ -16,7 +16,7 @@ EXTRA_DIST = \
|
|||||||
1.6.2/src/hunspell/hunvisapi.h.in \
|
1.6.2/src/hunspell/hunvisapi.h.in \
|
||||||
1.6.2/src/hunspell/utf_info.cxx
|
1.6.2/src/hunspell/utf_info.cxx
|
||||||
|
|
||||||
AM_CPPFLAGS += -DHUNSPELL_STATIC
|
AM_CPPFLAGS += -DHUNSPELL_STATIC @STDLIB_DEBUG@
|
||||||
|
|
||||||
liblyxhunspell_a_SOURCES = \
|
liblyxhunspell_a_SOURCES = \
|
||||||
1.6.2/src/hunspell/affentry.cxx \
|
1.6.2/src/hunspell/affentry.cxx \
|
||||||
|
3
INSTALL
3
INSTALL
@ -227,6 +227,9 @@ The following options allow you to tweak the generated code more precisely (see
|
|||||||
--without-included-boost is specified). You may have to use
|
--without-included-boost is specified). You may have to use
|
||||||
--disable-stdlib-debug when linking development versions against
|
--disable-stdlib-debug when linking development versions against
|
||||||
your system's boost library.
|
your system's boost library.
|
||||||
|
The same problem applies to hunspell (as of hunspell 1.5). So either
|
||||||
|
compile --with-included-hunspell or --disable-stdlib-debug when
|
||||||
|
linking development versions against your system's hunspell library.
|
||||||
|
|
||||||
o --enable-monolithic-build[=boost,client,insets,mathed,core,tex2lyx,frontend-qt4]
|
o --enable-monolithic-build[=boost,client,insets,mathed,core,tex2lyx,frontend-qt4]
|
||||||
that enables monolithic build of the given parts of the source
|
that enables monolithic build of the given parts of the source
|
||||||
|
@ -420,6 +420,7 @@ if test x$GXX = xyes; then
|
|||||||
lyx_flags="$lyx_flags stdlib-debug"
|
lyx_flags="$lyx_flags stdlib-debug"
|
||||||
AC_DEFINE(_GLIBCXX_DEBUG, 1, [libstdc++ debug mode])
|
AC_DEFINE(_GLIBCXX_DEBUG, 1, [libstdc++ debug mode])
|
||||||
AC_DEFINE(_GLIBCXX_DEBUG_PEDANTIC, 1, [libstdc++ pedantic debug mode])
|
AC_DEFINE(_GLIBCXX_DEBUG_PEDANTIC, 1, [libstdc++ pedantic debug mode])
|
||||||
|
AC_SUBST(STDLIB_DEBUG, "-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
@ -43,6 +43,24 @@ AC_DEFUN([CHECK_WITH_ENCHANT],
|
|||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([LYX_HAVE_HUNSPELL_CXXABI],
|
||||||
|
[
|
||||||
|
AC_MSG_CHECKING([whether hunspell C++ (rather than C) ABI is provided])
|
||||||
|
save_CXXFLAGS=$CXXFLAGS
|
||||||
|
CXXFLAGS="$ENCHANT_CFLAGS $AM_CXXFLAGS $CXXFLAGS"
|
||||||
|
|
||||||
|
# in the C++ ABI, stem() returns a vector, in the C ABI, it returns an int
|
||||||
|
AC_TRY_COMPILE([#include <hunspell/hunspell.hxx>],
|
||||||
|
[Hunspell sp("foo", "bar");
|
||||||
|
int i = sp.stem("test").size();],
|
||||||
|
[AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(HAVE_HUNSPELL_CXXABI, 1, [Define to 1 if hunspell C++ (rather than C) ABI is detected])
|
||||||
|
have_hunspell_cxx_abi=yes
|
||||||
|
],
|
||||||
|
[AC_MSG_RESULT(no)])
|
||||||
|
CXXFLAGS=$save_CXXFLAGS
|
||||||
|
])
|
||||||
|
|
||||||
# Macro to add for using hunspell spellchecker libraries! -*- sh -*-
|
# Macro to add for using hunspell spellchecker libraries! -*- sh -*-
|
||||||
AC_DEFUN([CHECK_WITH_HUNSPELL],
|
AC_DEFUN([CHECK_WITH_HUNSPELL],
|
||||||
[
|
[
|
||||||
@ -66,6 +84,12 @@ AC_DEFUN([CHECK_WITH_HUNSPELL],
|
|||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
LYX_HAVE_HUNSPELL_CXXABI
|
||||||
|
if test $enable_stdlib_debug = "yes" -a -n "$have_hunspell_cxx_abi" ; then
|
||||||
|
LYX_WARNING([Compiling LyX with stdlib-debug and system hunspell libraries may lead to
|
||||||
|
crashes. Consider using --disable-stdlib-debug or --with-included-hunspell.])
|
||||||
|
fi
|
||||||
|
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl Usage: LYX_USE_INCLUDED_HUNSPELL : select if the included hunspell should
|
dnl Usage: LYX_USE_INCLUDED_HUNSPELL : select if the included hunspell should
|
||||||
@ -96,6 +120,7 @@ AC_DEFUN([LYX_CHECK_SPELL_ENGINES],
|
|||||||
dnl the user wanted to use the included hunspell, so do not check for external hunspell
|
dnl the user wanted to use the included hunspell, so do not check for external hunspell
|
||||||
lyx_use_hunspell=true
|
lyx_use_hunspell=true
|
||||||
AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
|
AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
|
||||||
|
AC_DEFINE(HAVE_HUNSPELL_CXXABI, 1, [Define to 1 if hunspell C++ (rather than C) ABI is detected])
|
||||||
lyx_flags="$lyx_flags use-hunspell"
|
lyx_flags="$lyx_flags use-hunspell"
|
||||||
else
|
else
|
||||||
CHECK_WITH_HUNSPELL
|
CHECK_WITH_HUNSPELL
|
||||||
|
@ -72,6 +72,36 @@ check_type_size("long long" HAVE_LONG_LONG)
|
|||||||
check_type_size(wchar_t HAVE_WCHAR_T)
|
check_type_size(wchar_t HAVE_WCHAR_T)
|
||||||
check_type_size(wint_t HAVE_WINT_T)
|
check_type_size(wint_t HAVE_WINT_T)
|
||||||
|
|
||||||
|
if(HUNSPELL_FOUND)
|
||||||
|
# check whether hunspell C++ (rather than C) ABI is provided
|
||||||
|
set(HunspellTestFile "${CMAKE_BINARY_DIR}/hunspelltest.cpp")
|
||||||
|
file(WRITE "${HunspellTestFile}"
|
||||||
|
"
|
||||||
|
#include <hunspell/hunspell.hxx>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Hunspell sp(\"foo\", \"bar\");
|
||||||
|
int i = sp.stem(\"test\").size();
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
"
|
||||||
|
)
|
||||||
|
|
||||||
|
try_compile(HAVE_HUNSPELL_CXXABI
|
||||||
|
"${CMAKE_BINARY_DIR}"
|
||||||
|
"${HunspellTestFile}"
|
||||||
|
CMAKE_FLAGS
|
||||||
|
"-DINCLUDE_DIRECTORIES:STRING=${HUNSPELL_INCLUDE_DIR}"
|
||||||
|
"-DCMAKE_CXX_LINK_EXECUTABLE='${CMAKE_COMMAD} echo not linking now...'"
|
||||||
|
OUTPUT_VARIABLE LOG2)
|
||||||
|
|
||||||
|
message(STATUS "HAVE_HUNSPELL_CXXABI = ${HAVE_HUNSPELL_CXXABI}")
|
||||||
|
#message(STATUS "LOG2 = ${LOG2}")
|
||||||
|
if(LYX_EXTERNAL_HUNSPELL AND LYX_STDLIB_DEBUG AND HAVE_HUNSPELL_CXXABI)
|
||||||
|
message(WARNING "Compiling LyX with stdlib-debug and system hunspell libraries may lead to crashes. Consider using -DLYX_STDLIB_DEBUG=OFF or -DLYX_EXTERNAL_HUNSPELL=OFF.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
#check_cxx_source_compiles(
|
#check_cxx_source_compiles(
|
||||||
# "
|
# "
|
||||||
|
@ -66,6 +66,9 @@
|
|||||||
#define HAVE_ALLOCA
|
#define HAVE_ALLOCA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* whether hunspell C++ (rather than C) ABI is provided */
|
||||||
|
#cmakedefine HAVE_HUNSPELL_CXXABI 1
|
||||||
|
|
||||||
#cmakedefine HAVE_ICONV_CONST 1
|
#cmakedefine HAVE_ICONV_CONST 1
|
||||||
#ifdef HAVE_ICONV_CONST
|
#ifdef HAVE_ICONV_CONST
|
||||||
#define ICONV_CONST const
|
#define ICONV_CONST const
|
||||||
|
@ -356,7 +356,11 @@ SpellChecker::Result HunspellChecker::check(WordLangTuple const & wl)
|
|||||||
|
|
||||||
LYXERR(Debug::GUI, "spellCheck: \"" <<
|
LYXERR(Debug::GUI, "spellCheck: \"" <<
|
||||||
wl.word() << "\", lang = " << wl.lang()->lang()) ;
|
wl.word() << "\", lang = " << wl.lang()->lang()) ;
|
||||||
|
#ifdef HAVE_HUNSPELL_CXXABI
|
||||||
|
if (h->spell(word_to_check, &info))
|
||||||
|
#else
|
||||||
if (h->spell(word_to_check.c_str(), &info))
|
if (h->spell(word_to_check.c_str(), &info))
|
||||||
|
#endif
|
||||||
return d->learned(wl) ? LEARNED_WORD : WORD_OK;
|
return d->learned(wl) ? LEARNED_WORD : WORD_OK;
|
||||||
|
|
||||||
if (info & SPELL_COMPOUND) {
|
if (info & SPELL_COMPOUND) {
|
||||||
@ -411,6 +415,11 @@ void HunspellChecker::suggest(WordLangTuple const & wl,
|
|||||||
return;
|
return;
|
||||||
string const encoding = h->get_dic_encoding();
|
string const encoding = h->get_dic_encoding();
|
||||||
string const word_to_check = to_iconv_encoding(wl.word(), encoding);
|
string const word_to_check = to_iconv_encoding(wl.word(), encoding);
|
||||||
|
#ifdef HAVE_HUNSPELL_CXXABI
|
||||||
|
vector<string> wlst = h->suggest(word_to_check);
|
||||||
|
for (auto const s : wlst)
|
||||||
|
suggestions.push_back(from_iconv_encoding(s, encoding));
|
||||||
|
#else
|
||||||
char ** suggestion_list;
|
char ** suggestion_list;
|
||||||
int const suggestion_number = h->suggest(&suggestion_list, word_to_check.c_str());
|
int const suggestion_number = h->suggest(&suggestion_list, word_to_check.c_str());
|
||||||
if (suggestion_number <= 0)
|
if (suggestion_number <= 0)
|
||||||
@ -418,6 +427,7 @@ void HunspellChecker::suggest(WordLangTuple const & wl,
|
|||||||
for (int i = 0; i != suggestion_number; ++i)
|
for (int i = 0; i != suggestion_number; ++i)
|
||||||
suggestions.push_back(from_iconv_encoding(suggestion_list[i], encoding));
|
suggestions.push_back(from_iconv_encoding(suggestion_list[i], encoding));
|
||||||
h->free_list(&suggestion_list, suggestion_number);
|
h->free_list(&suggestion_list, suggestion_number);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -430,6 +440,11 @@ void HunspellChecker::stem(WordLangTuple const & wl,
|
|||||||
return;
|
return;
|
||||||
string const encoding = h->get_dic_encoding();
|
string const encoding = h->get_dic_encoding();
|
||||||
string const word_to_check = to_iconv_encoding(wl.word(), encoding);
|
string const word_to_check = to_iconv_encoding(wl.word(), encoding);
|
||||||
|
#ifdef HAVE_HUNSPELL_CXXABI
|
||||||
|
vector<string> wlst = h->stem(word_to_check);
|
||||||
|
for (auto const s : wlst)
|
||||||
|
suggestions.push_back(from_iconv_encoding(s, encoding));
|
||||||
|
#else
|
||||||
char ** suggestion_list;
|
char ** suggestion_list;
|
||||||
int const suggestion_number = h->stem(&suggestion_list, word_to_check.c_str());
|
int const suggestion_number = h->stem(&suggestion_list, word_to_check.c_str());
|
||||||
if (suggestion_number <= 0)
|
if (suggestion_number <= 0)
|
||||||
@ -437,6 +452,7 @@ void HunspellChecker::stem(WordLangTuple const & wl,
|
|||||||
for (int i = 0; i != suggestion_number; ++i)
|
for (int i = 0; i != suggestion_number; ++i)
|
||||||
suggestions.push_back(from_iconv_encoding(suggestion_list[i], encoding));
|
suggestions.push_back(from_iconv_encoding(suggestion_list[i], encoding));
|
||||||
h->free_list(&suggestion_list, suggestion_number);
|
h->free_list(&suggestion_list, suggestion_number);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,6 +89,9 @@ What's new
|
|||||||
|
|
||||||
* BUILD/INSTALLATION
|
* BUILD/INSTALLATION
|
||||||
|
|
||||||
|
- Support new hunspell C++ ABI if LyX is built against hunspell >= 1.5
|
||||||
|
(bug 10547).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
** Bug fixes:
|
** Bug fixes:
|
||||||
|
Loading…
Reference in New Issue
Block a user