mdk 2006 aspell quirks

This commit is contained in:
dockes 2006-11-21 13:05:16 +00:00
parent f70a552c3b
commit 5cf720e114
3 changed files with 870 additions and 432 deletions

View File

@ -1,6 +1,6 @@
#ifndef TEST_RCLASPELL #ifndef TEST_RCLASPELL
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclaspell.cpp,v 1.4 2006-10-11 16:09:45 dockes Exp $ (C) 2006 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclaspell.cpp,v 1.5 2006-11-21 13:05:16 dockes Exp $ (C) 2006 J.F.Dockes";
#endif #endif
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "autoconfig.h" #include "autoconfig.h"
@ -69,13 +69,20 @@ static AspellApi aapi;
badnames += #NM + string(" "); \ badnames += #NM + string(" "); \
} }
const char *aspell_progs[] = { static const char *aspell_progs[] = {
#ifdef ASPELL_PROG #ifdef ASPELL_PROG
ASPELL_PROG , ASPELL_PROG ,
#endif #endif
"/usr/local/bin/aspell", "/usr/local/bin/aspell",
"/usr/bin/aspell" "/usr/bin/aspell"
}; };
static const unsigned int naspellprogs = sizeof(aspell_progs) / sizeof(char*);
static const char *aspell_lib_suffixes[] = {
".so",
".so.15",
".so.16"
};
static const unsigned int nlibsuffs = sizeof(aspell_lib_suffixes) / sizeof(char *);
bool Aspell::init(string &reason) bool Aspell::init(string &reason)
{ {
@ -87,9 +94,9 @@ bool Aspell::init(string &reason)
if (!m_config->getConfParam("aspellLanguage", m_lang)) { if (!m_config->getConfParam("aspellLanguage", m_lang)) {
string lang = "en"; string lang = "en";
const char *cp; const char *cp;
if (cp = getenv("LC_ALL")) if ((cp = getenv("LC_ALL")))
lang = cp; lang = cp;
else if (cp = getenv("LANG")) else if ((cp = getenv("LANG")))
lang = cp; lang = cp;
if (!lang.compare("C")) if (!lang.compare("C"))
lang = "en"; lang = "en";
@ -102,7 +109,7 @@ bool Aspell::init(string &reason)
} }
m_data = new AspellData; m_data = new AspellData;
for (unsigned int i = 0; i < sizeof(aspell_progs) / sizeof(char*); i++) { for (unsigned int i = 0; i < naspellprogs; i++) {
if (access(aspell_progs[i], X_OK) == 0) { if (access(aspell_progs[i], X_OK) == 0) {
m_data->m_exec = aspell_progs[i]; m_data->m_exec = aspell_progs[i];
break; break;
@ -116,13 +123,23 @@ bool Aspell::init(string &reason)
// For now, the aspell library has to live under the same prefix as the // For now, the aspell library has to live under the same prefix as the
// aspell program. // aspell program.
string aspellPrefix = path_getfather(path_getfather(m_data->m_exec)); string aspellPrefix = path_getfather(path_getfather(m_data->m_exec));
string lib = path_cat(aspellPrefix, "lib"); string libbase = path_cat(aspellPrefix, "lib");
lib = path_cat(lib, "libaspell.so"); libbase = path_cat(libbase, "libaspell");
if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) == 0) { string lib;
reason = "Could not open shared library ["; reason = "Could not open shared library [";
reason += lib + "] : " + dlerror(); for (unsigned int i = 0; i < nlibsuffs; i++) {
return false; lib = libbase + aspell_lib_suffixes[i];
reason += lib + "]";
if ((m_data->m_handle = dlopen(lib.c_str(), RTLD_LAZY)) != 0) {
reason.erase();
break;
}
} }
if (m_data->m_handle == 0) {
reason += string(" : ") + dlerror();
return false;
}
string badnames; string badnames;
NMTOPTR(new_aspell_config, (struct AspellConfig *(*)())); NMTOPTR(new_aspell_config, (struct AspellConfig *(*)()));
NMTOPTR(aspell_config_replace, (int (*)(struct AspellConfig *, NMTOPTR(aspell_config_replace, (int (*)(struct AspellConfig *,

1248
src/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -32,19 +32,22 @@ case $withAspell in
aspellProg=$withAspell aspellProg=$withAspell
;; ;;
esac esac
# if echo withAspell = $withAspell
if test X$withAspell != Xno ; then if test X$withAspell != Xno ; then
AC_DEFINE(RCL_USE_ASPELL, 1, [Compile the aspell interface]) AC_DEFINE(RCL_USE_ASPELL, 1, [Compile the aspell interface])
if test X$aspellProg != X ; then if test X$aspellProg != X ; then
aspellBase=`dirname $aspellProg` aspellBase=`dirname $aspellProg`
aspellBase=`dirname $aspellBase` aspellBase=`dirname $aspellBase`
if test ! -f $aspellBase/include/aspell.h ; then
AC_MSG_ERROR([aspell.h not found in $aspellBase/include. Specify --with-aspell=no to disable aspell support])
fi
AC_DEFINE_UNQUOTED(ASPELL_PROG, "$aspellProg", AC_DEFINE_UNQUOTED(ASPELL_PROG, "$aspellProg",
[Path to the aspell program]) [Path to the aspell program])
AC_DEFINE_UNQUOTED(ASPELL_INCLUDE, "$aspellBase/include/aspell.h", if test -f $aspellBase/include/aspell.h ; then
[Path to the aspell api include file]) AC_DEFINE_UNQUOTED(ASPELL_INCLUDE, "$aspellBase/include/aspell.h",
[Path to the aspell api include file])
else
AC_MSG_NOTICE([aspell support enabled but aspell package not found. Compiling with internal aspell interface file])
AC_DEFINE(ASPELL_INCLUDE, ["aspell-local.h"])
fi
else else
# aspell support enabled but no aspell install yet # aspell support enabled but no aspell install yet
AC_MSG_NOTICE([aspell support enabled but aspell package not found. Compiling with internal aspell interface file]) AC_MSG_NOTICE([aspell support enabled but aspell package not found. Compiling with internal aspell interface file])