Skip to content
Commits on Source (23)
2.3.1 (August 9, 2021)
----------------------
Hunspell: fix enchant_dict_get_extra_word_characters API so it always
returns UTF-8. Use the same limit on word length as Hunspell uses (it is
different for UTF-8). Drop support for Hunspell 1.4.
Ignore hidden files when loading provider modules.
In a slight update to a change introduced in 2.3.0, in the default
enchant.ordering file, do not prefer aspell for all “en” locales, only for
the specific “en” locales that it supports.
2.3.0 (June 14, 2021)
---------------------
Add -p flag to enchant.
Allow personal wordlist APIs (enchant_pwl_*) to take -1 as the length of the
word, as the enchant_dict_* APIs already allowed.
Add documentation to enchant_provider.h.
Make Aspell the default backend for English locales it supports, as it is
much quicker than Hunspell in this case and achieves slightly better
results.
Require nuspell version 4.1.0 or later.
2.2.15 (December 22, 2020)
--------------------------
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for enchant 2.2.15.
# Generated by GNU Autoconf 2.69 for enchant 2.3.1.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='enchant'
PACKAGE_TARNAME='enchant'
PACKAGE_VERSION='2.2.15'
PACKAGE_STRING='enchant 2.2.15'
PACKAGE_VERSION='2.3.1'
PACKAGE_STRING='enchant 2.3.1'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
 
......@@ -1787,7 +1787,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures enchant 2.2.15 to adapt to many kinds of systems.
\`configure' configures enchant 2.3.1 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
......@@ -1858,7 +1858,7 @@ fi
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of enchant 2.2.15:";;
short | recursive ) echo "Configuration of enchant 2.3.1:";;
esac
cat <<\_ACEOF
 
......@@ -2025,7 +2025,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
enchant configure 2.2.15
enchant configure 2.3.1
generated by GNU Autoconf 2.69
 
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2881,7 +2881,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
 
It was created by enchant $as_me 2.2.15, which was
It was created by enchant $as_me 2.3.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
 
$ $0 $@
......@@ -3752,7 +3752,7 @@ fi
 
# Define the identity of the package.
PACKAGE='enchant'
VERSION='2.2.15'
VERSION='2.3.1'
 
 
cat >>confdefs.h <<_ACEOF
......@@ -25265,7 +25265,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by enchant $as_me 2.2.15, which was
This file was extended by enchant $as_me 2.3.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
......@@ -25331,7 +25331,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
enchant config.status 2.2.15
enchant config.status 2.3.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
 
......
AC_INIT([enchant],[2.2.15])
AC_INIT([enchant],[2.3.1])
AC_CONFIG_SRCDIR(src/enchant.h)
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([subdir-objects])
......
/* enchant
* Copyright (C) 2003-2004 Joan Moratinos <jmo@softcatala.org>, Dom Lachowicz
* Copyright (C) 2016-2021 Reuben Thomas <rrt@sc3d.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -16,8 +17,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU General Public License in all
......@@ -29,7 +30,7 @@
/*
* This is the Hunspell Enchant Backend.
* Hunspell is by László Németh. See: http://hunspell.github.io/
* Hunspell is by László Németh. See: https://hunspell.github.io/
*/
#include "config.h"
......@@ -45,17 +46,29 @@
#include "unused-parameter.h"
#include <hunspell/hunspell.hxx>
/* Some versions of hunspell (1.4.x) don't have this defined. */
/* This is the defined value at that point */
#ifndef MAXWORDLEN
#define MAXWORDLEN 176
#endif
// hunspell itself uses this definition (which only supports the BMP)
#define MAXWORDUTF8LEN (MAXWORDLEN * 3)
#include <glib.h>
/***************************************************************************/
static const char *empty_string = "";
static char *do_iconv(GIConv conv, const char *word) {
// g_iconv() does not declare its 'in' parameter const, but iconv() does.
char *in = const_cast<char *>(word);
size_t len_in = strlen(in);
size_t len_out = len_in * 3;
char *out_buf = g_new0(char, len_out + 1);
char *out = out_buf;
size_t result = g_iconv(conv, &in, &len_in, &out, &len_out);
if (static_cast<size_t>(-1) == result)
return nullptr;
*out = '\0';
return out_buf;
}
class HunspellChecker
{
public:
......@@ -73,6 +86,7 @@ private:
GIConv m_translate_in; /* Selected translation from/to Unicode */
GIConv m_translate_out;
Hunspell *hunspell;
char *wordchars; /* Value returned by getWordChars() */
};
/***************************************************************************/
......@@ -84,7 +98,7 @@ g_iconv_is_valid(GIConv i)
}
HunspellChecker::HunspellChecker()
: apostropheIsWordChar(false), m_translate_in(nullptr), m_translate_out(nullptr), hunspell(nullptr)
: apostropheIsWordChar(false), m_translate_in(nullptr), m_translate_out(nullptr), hunspell(nullptr), wordchars(nullptr)
{
}
......@@ -95,80 +109,61 @@ HunspellChecker::~HunspellChecker()
g_iconv_close(m_translate_in);
if (g_iconv_is_valid(m_translate_out))
g_iconv_close(m_translate_out);
free(wordchars);
}
bool
HunspellChecker::checkWord(const char *utf8Word, size_t len)
{
if (len > MAXWORDLEN || !g_iconv_is_valid(m_translate_in))
if (len > MAXWORDUTF8LEN || !g_iconv_is_valid(m_translate_in))
return false;
// the 8bit encodings use precomposed forms
char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC);
char *in = normalizedWord;
char word8[MAXWORDLEN + 1];
char *out = word8;
size_t len_in = strlen(in);
size_t len_out = sizeof( word8 ) - 1;
size_t result = g_iconv(m_translate_in, &in, &len_in, &out, &len_out);
char *out = do_iconv(m_translate_in, normalizedWord);
g_free(normalizedWord);
if (static_cast<size_t>(-1) == result)
return false;
*out = '\0';
if (hunspell->spell(std::string(word8)))
return true;
else
if (out == NULL)
return false;
bool result = hunspell->spell(std::string(out)) != 0;
free(out);
return result;
}
char**
HunspellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug)
{
if (len > MAXWORDLEN
if (len > MAXWORDUTF8LEN
|| !g_iconv_is_valid(m_translate_in)
|| !g_iconv_is_valid(m_translate_out))
return nullptr;
// the 8bit encodings use precomposed forms
char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC);
char *in = normalizedWord;
char word8[MAXWORDLEN + 1];
char *out = word8;
size_t len_in = strlen(in);
size_t len_out = sizeof(word8) - 1;
size_t result = g_iconv(m_translate_in, &in, &len_in, &out, &len_out);
char *out = do_iconv(m_translate_in, normalizedWord);
g_free(normalizedWord);
if (static_cast<size_t>(-1) == result)
if (out == NULL)
return nullptr;
*out = '\0';
std::vector<std::string> sugMS = hunspell->suggest(word8);
std::vector<std::string> sugMS = hunspell->suggest(out);
g_free(out);
*nsug = sugMS.size();
if (*nsug > 0) {
char **sug = g_new0 (char *, *nsug + 1);
for (size_t i=0; i<*nsug; i++) {
in = const_cast<char *>(sugMS[i].c_str());
len_in = strlen(in);
len_out = MAXWORDLEN;
char *word = g_new0(char, len_out + 1);
out = word;
if (static_cast<size_t>(-1) == g_iconv(m_translate_out, &in, &len_in, &out, &len_out)) {
*nsug = i;
break;
}
*out = '\0';
sug[i] = word;
for (size_t i=0, j=0; i<*nsug; i++) {
const char *in = sugMS[i].c_str();
out = do_iconv(m_translate_out, in);
if (out != NULL)
sug[j++] = out;
}
return sug;
}
else
return nullptr;
return nullptr;
}
const char*
_GL_ATTRIBUTE_PURE const char*
HunspellChecker::getWordchars()
{
return hunspell->get_wordchars();
return static_cast<const char *>(wordchars);
}
static void
......@@ -310,8 +305,11 @@ HunspellChecker::requestDictionary(const char *szLang)
std::string aff(s_correspondingAffFile(dic));
if (s_fileExists(aff))
{
if (hunspell)
if (hunspell) {
delete hunspell;
free(wordchars);
wordchars = NULL;
}
hunspell = new Hunspell(aff.c_str(), dic);
}
free(dic);
......@@ -323,9 +321,13 @@ HunspellChecker::requestDictionary(const char *szLang)
m_translate_in = g_iconv_open(enc, "UTF-8");
m_translate_out = g_iconv_open("UTF-8", enc);
const char *word_chars = hunspell->get_wordchars();
apostropheIsWordChar = g_utf8_strchr(word_chars, -1, g_utf8_get_char("'")) ||
g_utf8_strchr(word_chars, -1, g_utf8_get_char("’"));
wordchars = do_iconv(m_translate_out, hunspell->get_wordchars());
if (wordchars == NULL)
wordchars = strdup(empty_string);
if (wordchars == NULL)
return false;
apostropheIsWordChar = g_utf8_strchr(wordchars, -1, g_utf8_get_char("'")) ||
g_utf8_strchr(wordchars, -1, g_utf8_get_char("’"));
return true;
}
......
......@@ -16,8 +16,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU General Public License in all
......
......@@ -19,8 +19,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU Lesser General Public License in all
......
......@@ -16,8 +16,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU Lesser General Public License in all
......
......@@ -14,6 +14,9 @@ is an ispell-compatible spellchecker.
\fB\-d \fIDICTIONARY\fR
use the given dictionary
.TP
\fB\-p \fIWORDLIST\fR
use the given personal wordlist
.TP
.B "\-a"
list suggestions in ispell pipe mode format
.TP
......
......@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* the non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU Lesser General Public License in all
......
......@@ -51,30 +51,53 @@ typedef struct str_enchant_provider EnchantProvider;
*/
char *enchant_get_user_language(void);
/**
* enchant_get_user_config_dir
*
* Returns a string giving the location of the user's Enchant configuration
* directory, or NULL on error, or if none exists. Defaults to the value of
* the environment variable ENCHANT_CONFIG_DIR; if that is not set, then
* glib's g_get_user_config_dir() is called to get the user's configuration
* directory, and the sub-directory "enchant" is appended.
*
* The returned string must be free'd.
*/
char *enchant_get_user_config_dir (void);
/**
* enchant_get_conf_dirs
*
* Returns a list (GSList *) of configuration directories, in the order in
* which they are used, or NULL on error.
*
* The following directories are in the list:
*
* + Enchant's internal configuration directory (pkgdatadir)
* + The system configuration directory (sysconfdir/enchant)
* + The user configuration directory, as returned by
* enchant_get_user_config_dir(), if it exists.
*/
GSList *enchant_get_conf_dirs (void);
/**
* enchant_get_prefix_dir
*
* Returns a string giving the location of the base directory
* of the enchant installation. This corresponds roughly to
* the --prefix option given to ./configure when enchant is
* compiled, except it is determined at runtime based on the location
* of the enchant library.
*
* Returns: the prefix dir. Must be free'd.
* Returns a string giving the location of the base directory of the enchant
* installation. This corresponds roughly to the --prefix option given to
* ./configure when enchant is compiled, except it is determined at runtime
* based on the location of the enchant library.
*
* The return value must be free'd.
*/
char *enchant_get_prefix_dir(void);
/**
* enchant_relocate
*
* Returns a string giving the relocated path according to the location of the
* base directory of the enchant installation.
* Returns a string giving the relocated path according to the location of
* the base directory of the enchant installation.
*
* Returns: the relocated path. Must be free'd.
* The return value must be free'd.
*/
char *enchant_relocate (const char *path);
......@@ -93,8 +116,8 @@ void enchant_dict_set_error (EnchantDict * dict, const char * const err);
* @provider: A non-null provider
* @err: A non-null error message
*
* Sets the current runtime error to @err. This API is private to
* the providers.
* Sets the current runtime error to @err. This API is private to the
* providers.
*/
void enchant_provider_set_error (EnchantProvider * provider, const char * const err);
......@@ -160,4 +183,4 @@ struct str_enchant_provider
}
#endif
#endif /* ENCHANT_H */
#endif /* ENCHANT_PROVIDER_H */
......@@ -14,6 +14,9 @@ is an ispell-compatible spellchecker.
\fB\-d \fIDICTIONARY\fR
use the given dictionary
.TP
\fB\-p \fIWORDLIST\fR
use the given personal wordlist
.TP
.B "\-a"
list suggestions in ispell pipe mode format
.TP
......
/* enchant
* Copyright (C) 2003 Dom Lachowicz
* 2007 Hannu Väisänen
* 2016-2020 Reuben Thomas
* 2016-2021 Reuben Thomas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -18,8 +18,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* the non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU Lesser General Public License in all
......@@ -47,6 +47,7 @@
#endif
#include "enchant.h"
#include "pwl.h"
#include "enchant-provider.h"
......@@ -75,6 +76,7 @@ print_help (const char * prog)
fprintf (stderr,
"Usage: %s -a|-l|-h|-v [-L] [-d DICTIONARY] [FILE]\n\
-d DICTIONARY use the given dictionary\n\
-p FILE use the given personal word list\n\
-a list suggestions in ispell pipe mode format\n\
-l list only the misspellings\n\
-L display line numbers\n\
......@@ -132,10 +134,20 @@ print_utf (const char * str)
}
}
static int
check_word (EnchantDict * dict, EnchantPWL * pwl, GString * word)
{
int ok = word->len <= MIN_WORD_LENGTH ||
enchant_dict_check (dict, word->str, word->len) == 0;
if (!ok && pwl)
ok = enchant_pwl_check (pwl, word->str, word->len) == 0;
return ok;
}
static void
do_mode_a (EnchantDict * dict, GString * word, size_t start_pos, size_t lineCount, gboolean terse_mode)
do_mode_a (EnchantDict * dict, EnchantPWL * pwl, GString * word, size_t start_pos, size_t lineCount, gboolean terse_mode)
{
if (word->len <= MIN_WORD_LENGTH || enchant_dict_check (dict, word->str, word->len) == 0) {
if (check_word (dict, pwl, word)) {
if (!terse_mode) {
if (lineCount)
printf ("* %u\n", (unsigned int)lineCount);
......@@ -145,6 +157,8 @@ do_mode_a (EnchantDict * dict, GString * word, size_t start_pos, size_t lineCoun
} else {
size_t n_suggs;
char ** suggs = enchant_dict_suggest (dict, word->str, word->len, &n_suggs);
if (pwl)
suggs = enchant_pwl_suggest (pwl, word->str, word->len, suggs, &n_suggs);
if (!n_suggs || !suggs) {
printf ("# ");
if (lineCount)
......@@ -174,9 +188,9 @@ do_mode_a (EnchantDict * dict, GString * word, size_t start_pos, size_t lineCoun
}
static void
do_mode_l (EnchantDict * dict, GString * word, size_t lineCount)
do_mode_l (EnchantDict * dict, EnchantPWL * pwl, GString * word, size_t lineCount)
{
if (enchant_dict_check (dict, word->str, word->len) != 0) {
if (!check_word (dict, pwl, word)) {
if (lineCount)
printf ("%u ", (unsigned int)lineCount);
print_utf (word->str);
......@@ -238,7 +252,7 @@ tokenize_line (EnchantDict * dict, GString * line)
}
static int
parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary)
parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary, EnchantPWL *pwl)
{
EnchantBroker * broker;
EnchantDict * dict;
......@@ -301,7 +315,10 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
case '*': /* Insert in personal word list */
if (str->len == 1)
goto empty_word;
enchant_dict_add(dict, str->str + 1, -1);
if (pwl)
enchant_pwl_add (pwl, str->str + 1, -1);
else
enchant_dict_add (dict, str->str + 1, -1);
break;
case '@': /* Accept for this session */
if (str->len == 1)
......@@ -311,7 +328,10 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
case '/': /* Remove from personal word list */
if (str->len == 1)
goto empty_word;
enchant_dict_remove (dict, str->str + 1, -1);
if (pwl)
enchant_pwl_remove (pwl, str->str + 1, -1);
else
enchant_dict_remove (dict, str->str + 1, -1);
break;
case '_': /* Remove from this session */
if (str->len == 1)
......@@ -375,9 +395,9 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
tokens = tokens->next;
if (mode == MODE_A)
do_mode_a (dict, word, pos, lineCount, terse_mode);
do_mode_a (dict, pwl, word, pos, lineCount, terse_mode);
else if (mode == MODE_L)
do_mode_l (dict, word, lineCount);
do_mode_l (dict, pwl, word, lineCount);
g_string_free(word, TRUE);
}
......@@ -409,6 +429,7 @@ int main (int argc, char ** argv)
FILE * fp = stdin;
gboolean countLines = FALSE;
gchar *dictionary = NULL; /* -d dictionary */
gchar *perslist = NULL ; /* -p personal_word_list */
/* Initialize system locale */
setlocale(LC_ALL, "");
......@@ -422,11 +443,14 @@ int main (int argc, char ** argv)
#endif
int optchar;
while ((optchar = getopt (argc, argv, ":d:alvLmB")) != -1) {
while ((optchar = getopt (argc, argv, ":d:p:alvLmB")) != -1) {
switch (optchar) {
case 'd':
dictionary = optarg; /* Emacs calls ispell with '-d dictionary'. */
break;
case 'p':
perslist = optarg;
break;
/* The first mode specified takes precedence. */
case 'a':
if (mode == MODE_NONE)
......@@ -478,7 +502,17 @@ int main (int argc, char ** argv)
exit (1);
}
}
rval = parse_file (fp, mode, countLines, dictionary);
EnchantPWL *pwl = NULL;
if (perslist) {
pwl = enchant_pwl_init_with_file (perslist);
if (!pwl) {
fprintf (stderr, "Error: Could not read the personal word list \"%s\"", perslist);
exit (1);
}
}
rval = parse_file (fp, mode, countLines, dictionary, pwl);
if (pwl)
enchant_pwl_free (pwl);
if (file)
fclose (fp);
......
*:hunspell,nuspell,aspell
en_AU:aspell,hunspell,nuspell
en_CA:aspell,hunspell,nuspell
en_GB:aspell,hunspell,nuspell
en_US:aspell,hunspell,nuspell
fi:voikko,hunspell,nuspell,aspell
fi_FI:voikko,hunspell,nuspell,aspell
he:hspell,hunspell,nuspell
......
......@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, Dom Lachowicz
* gives permission to link the code of this program with
* In addition, as a special exception, the copyright holders
* give permission to link the code of this program with
* non-LGPL Spelling Provider libraries (eg: a MSFT Office
* spell checker backend) and distribute linked combinations including
* the two. You must obey the GNU Lesser General Public License in all
......@@ -808,6 +808,7 @@ enchant_load_providers_in_dir (EnchantBroker * broker, const char *dir_name)
size_t entry_len = strlen (dir_entry);
if ((entry_len > g_module_suffix_len) &&
dir_entry[0] != '.' && /* Skip hidden files */
!strcmp(dir_entry+(entry_len-g_module_suffix_len), G_MODULE_SUFFIX))
{
#ifdef _WIN32
......
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,2,15
PRODUCTVERSION 2,2,15,0
FILEVERSION 2,3,1
PRODUCTVERSION 2,3,1,0
FILEFLAGSMASK 0
FILEFLAGS 0
FILEOS VOS__WINDOWS32
......@@ -15,12 +15,12 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
VALUE "CompanyName", "none"
VALUE "FileDescription", "libenchant"
VALUE "FileVersion", "2.2.15"
VALUE "InternalName", "libenchant-2.2"
VALUE "FileVersion", "2.3.1"
VALUE "InternalName", "libenchant-2.3"
VALUE "LegalCopyright", "Copyright (C) 2002-2007 Dom Lachowicz"
VALUE "OriginalFilename", "libenchant-2.2.dll"
VALUE "OriginalFilename", "libenchant-2.3.dll"
VALUE "ProductName", "libenchant"
VALUE "ProductVersion", "2.2.15"
VALUE "ProductVersion", "2.3.1"
END
END
BLOCK "VarFileInfo"
......
......@@ -313,8 +313,11 @@ static void enchant_pwl_remove_from_trie(EnchantPWL *pwl,
}
void enchant_pwl_add(EnchantPWL *pwl,
const char *const word, size_t len)
const char *const word, ssize_t len)
{
if (len < 0)
len = strlen (word);
enchant_pwl_refresh_from_file(pwl);
enchant_pwl_add_to_trie(pwl, word, len);
......@@ -342,7 +345,7 @@ void enchant_pwl_add(EnchantPWL *pwl,
putc ('\n', f);
}
if (fwrite (word, sizeof(char), len, f) == len)
if (fwrite (word, sizeof(char), len, f) == (size_t)len)
{
putc ('\n', f);
}
......@@ -353,8 +356,11 @@ void enchant_pwl_add(EnchantPWL *pwl,
}
void enchant_pwl_remove(EnchantPWL *pwl,
const char *const word, size_t len)
const char *const word, ssize_t len)
{
if (len < 0)
len = strlen (word);
if(enchant_pwl_check(pwl, word, len) == 1)
return;
......@@ -525,8 +531,11 @@ static gchar* enchant_utf8_strtitle(const gchar*str, gssize len)
return result;
}
int enchant_pwl_check(EnchantPWL *pwl, const char *const word, size_t len)
int enchant_pwl_check(EnchantPWL *pwl, const char *const word, ssize_t len)
{
if (len < 0)
len = strlen (word);
enchant_pwl_refresh_from_file(pwl);
int exists = enchant_pwl_contains(pwl, word, len);
......@@ -609,8 +618,11 @@ static int best_distance(char** suggs, const char *const word, size_t len)
/* gives the best set of suggestions from pwl that are at least as good as the
* given suggs (if suggs == NULL just best from pwl) */
char** enchant_pwl_suggest(EnchantPWL *pwl, const char *const word,
size_t len, char** suggs, size_t* out_n_suggs)
ssize_t len, char** suggs, size_t* out_n_suggs)
{
if (len < 0)
len = strlen (word);
int max_dist = suggs ? best_distance(suggs, word, len) : ENCHANT_PWL_MAX_ERRORS;
max_dist = MIN (max_dist, ENCHANT_PWL_MAX_ERRORS);
......
......@@ -42,12 +42,12 @@ typedef struct str_enchant_pwl EnchantPWL;
EnchantPWL* enchant_pwl_init(void);
EnchantPWL* enchant_pwl_init_with_file(const char * file);
void enchant_pwl_add(EnchantPWL * me, const char *const word, size_t len);
void enchant_pwl_remove(EnchantPWL * me, const char *const word, size_t len);
int enchant_pwl_check(EnchantPWL * me,const char *const word, size_t len);
void enchant_pwl_add(EnchantPWL * me, const char *const word, ssize_t len);
void enchant_pwl_remove(EnchantPWL * me, const char *const word, ssize_t len);
int enchant_pwl_check(EnchantPWL * me, const char *const word, ssize_t len);
/*gives the best set of suggestions from pwl that are at least as good as the given suggs*/
char** enchant_pwl_suggest(EnchantPWL *me, const char *const word,
size_t len, char ** suggs, size_t* out_n_suggs);
ssize_t len, char ** suggs, size_t* out_n_suggs);
void enchant_pwl_free(EnchantPWL* me);
#ifdef __cplusplus
......