Support libenchant-2

This commit is contained in:
Zane U. Ji 2022-10-08 23:12:01 +08:00
parent f80b966b21
commit 4440c13adf
5 changed files with 203 additions and 16 deletions

View File

@ -1,6 +1,7 @@
# Version number followed by the release date
1.3.1.0
+ Support libenchant-2
* Fix a DDE error on Windows (Bug #236)
* gdk_x11_get_server_time crashes when an invalid window is passed
* Migrate to PCRE2 (Miriam Ruiz)

View File

@ -158,7 +158,7 @@ am__define_uniq_tagged_files = \
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in AUTHORS COPYING ChangeLog \
INSTALL NEWS README.md TODO compile config.guess config.rpath \
config.sub install-sh ltmain.sh missing
config.sub depcomp install-sh ltmain.sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)

188
configure vendored
View File

@ -1563,10 +1563,6 @@ Some influential environment variables:
PCRE2_CFLAGS
C compiler flags for PCRE2, overriding pkg-config
PCRE2_LIBS linker flags for PCRE2, overriding pkg-config
ENCHANT_CFLAGS
C compiler flags for ENCHANT, overriding pkg-config
ENCHANT_LIBS
linker flags for ENCHANT, overriding pkg-config
GTK_CFLAGS C compiler flags for GTK, overriding pkg-config
GTK_LIBS linker flags for GTK, overriding pkg-config
@ -17973,7 +17969,71 @@ else $as_nop
fi
# Check enchant is available
# Check enchant-2
pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for enchant-2" >&5
printf %s "checking for enchant-2... " >&6; }
if test -n "$ENCHANT_CFLAGS"; then
pkg_cv_ENCHANT_CFLAGS="$ENCHANT_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"enchant-2\""; } >&5
($PKG_CONFIG --exists --print-errors "enchant-2") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ENCHANT_CFLAGS=`$PKG_CONFIG --cflags "enchant-2" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$ENCHANT_LIBS"; then
pkg_cv_ENCHANT_LIBS="$ENCHANT_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"enchant-2\""; } >&5
($PKG_CONFIG --exists --print-errors "enchant-2") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ENCHANT_LIBS=`$PKG_CONFIG --libs "enchant-2" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
ENCHANT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "enchant-2" 2>&1`
else
ENCHANT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "enchant-2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$ENCHANT_PKG_ERRORS" >&5
# Check enchant
ENCHANT_CFLAGS
C compiler flags for ENCHANT, overriding pkg-config
ENCHANT_LIBS
linker flags for ENCHANT, overriding pkg-config
pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for enchant" >&5
@ -18034,7 +18094,7 @@ fi
echo "$ENCHANT_PKG_ERRORS" >&5
# otherwise Check ASPELL is available
ac_fn_cxx_check_header_compile "$LINENO" "aspell.h" "ac_cv_header_aspell_h" "$ac_includes_default"
ac_fn_cxx_check_header_compile "$LINENO" "aspell.h" "ac_cv_header_aspell_h" "$ac_includes_default"
if test "x$ac_cv_header_aspell_h" = xyes
then :
ASPELL_LIBS="-laspell"
@ -18047,7 +18107,7 @@ elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
# otherwise Check ASPELL is available
ac_fn_cxx_check_header_compile "$LINENO" "aspell.h" "ac_cv_header_aspell_h" "$ac_includes_default"
ac_fn_cxx_check_header_compile "$LINENO" "aspell.h" "ac_cv_header_aspell_h" "$ac_includes_default"
if test "x$ac_cv_header_aspell_h" = xyes
then :
ASPELL_LIBS="-laspell"
@ -18061,7 +18121,119 @@ else
ENCHANT_LIBS=$pkg_cv_ENCHANT_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
CXXFLAGS="$CXXFLAGS -DUSE_ENCHANT"
printf "%s\n" "#define USE_ENCHANT 1" >>confdefs.h
fi
elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
# Check enchant
ENCHANT_CFLAGS
C compiler flags for ENCHANT, overriding pkg-config
ENCHANT_LIBS
linker flags for ENCHANT, overriding pkg-config
pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for enchant" >&5
printf %s "checking for enchant... " >&6; }
if test -n "$ENCHANT_CFLAGS"; then
pkg_cv_ENCHANT_CFLAGS="$ENCHANT_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"enchant\""; } >&5
($PKG_CONFIG --exists --print-errors "enchant") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ENCHANT_CFLAGS=`$PKG_CONFIG --cflags "enchant" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$ENCHANT_LIBS"; then
pkg_cv_ENCHANT_LIBS="$ENCHANT_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"enchant\""; } >&5
($PKG_CONFIG --exists --print-errors "enchant") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ENCHANT_LIBS=`$PKG_CONFIG --libs "enchant" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
ENCHANT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "enchant" 2>&1`
else
ENCHANT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "enchant" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$ENCHANT_PKG_ERRORS" >&5
# otherwise Check ASPELL is available
ac_fn_cxx_check_header_compile "$LINENO" "aspell.h" "ac_cv_header_aspell_h" "$ac_includes_default"
if test "x$ac_cv_header_aspell_h" = xyes
then :
ASPELL_LIBS="-laspell"
else $as_nop
as_fn_error $? "Aspell headers not found" "$LINENO" 5
fi
elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
# otherwise Check ASPELL is available
ac_fn_cxx_check_header_compile "$LINENO" "aspell.h" "ac_cv_header_aspell_h" "$ac_includes_default"
if test "x$ac_cv_header_aspell_h" = xyes
then :
ASPELL_LIBS="-laspell"
else $as_nop
as_fn_error $? "Aspell headers not found" "$LINENO" 5
fi
else
ENCHANT_CFLAGS=$pkg_cv_ENCHANT_CFLAGS
ENCHANT_LIBS=$pkg_cv_ENCHANT_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
printf "%s\n" "#define USE_ENCHANT 1" >>confdefs.h
fi
else
ENCHANT_CFLAGS=$pkg_cv_ENCHANT_CFLAGS
ENCHANT_LIBS=$pkg_cv_ENCHANT_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
printf "%s\n" "#define USE_ENCHANT 1" >>confdefs.h
,
printf "%s\n" "#define HAVE_LIBENCHANT_2 1" >>confdefs.h
fi

View File

@ -104,11 +104,18 @@ AC_LANG(C++)
AC_CHECK_HEADER(expat.h, ,
AC_MSG_ERROR([Expat headers not found]))
# Check enchant is available
PKG_CHECK_MODULES(ENCHANT, [enchant], [CXXFLAGS="$CXXFLAGS -DUSE_ENCHANT"],
# otherwise Check ASPELL is available
[AC_CHECK_HEADER(aspell.h, [ASPELL_LIBS="-laspell"],
AC_MSG_ERROR([Aspell headers not found]))]
# Check enchant-2
PKG_CHECK_MODULES(ENCHANT, [enchant-2],
[AC_DEFINE([USE_ENCHANT]),
AC_DEFINE([HAVE_LIBENCHANT_2])
],
# Check enchant
PKG_CHECK_MODULES(ENCHANT, [enchant],
[AC_DEFINE([USE_ENCHANT])],
# otherwise Check ASPELL is available
[AC_CHECK_HEADER(aspell.h, [ASPELL_LIBS="-laspell"],
AC_MSG_ERROR([Aspell headers not found]))]
)
)
AC_SUBST(ASPELL_LIBS)

View File

@ -40,9 +40,13 @@ WrapAspell::WrapAspell (
)
{
#ifdef USE_ENCHANT
#ifdef HAVE_LIBENCHANT_2
spell_broker = new enchant::Broker();
#else // HAVE_LIBENCHANT_2
spell_broker = enchant::Broker::instance();
#endif // HAVE_LIBENCHANT_2
spell_checker = spell_broker->request_dict( std::string ( lang.mb_str() ) );
#else
#else // HAVE_LIBENCHANT
spell_config = new_aspell_config();
#ifdef __WXMSW__
@ -68,7 +72,10 @@ WrapAspell::~WrapAspell()
{
#ifdef USE_ENCHANT
delete spell_checker;
#else
#ifdef HAVE_LIBENCHANT_2
delete spell_broker;
#endif
#else // USE_ENCHANT
delete_aspell_speller ( spell_checker );
delete_aspell_config ( spell_config );
#endif