Skip to content
Commits on Source (27)
2.3.2 (November 16, 2021)
-------------------------
Fix the generation of man pages, so that installation-dependent paths are
correctly inserted.
Improve error reporting when enchant-lsmod cannot open a dictionary for a
given language, in particular with the Aspell backend.
Fix compilation on MingW.
Some minor code cleanup.
2.3.1 (August 9, 2021)
----------------------
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for enchant 2.3.1.
# Generated by GNU Autoconf 2.69 for enchant 2.3.2.
#
#
# 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.3.1'
PACKAGE_STRING='enchant 2.3.1'
PACKAGE_VERSION='2.3.2'
PACKAGE_STRING='enchant 2.3.2'
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.3.1 to adapt to many kinds of systems.
\`configure' configures enchant 2.3.2 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.3.1:";;
short | recursive ) echo "Configuration of enchant 2.3.2:";;
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.3.1
enchant configure 2.3.2
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.3.1, which was
It was created by enchant $as_me 2.3.2, 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.3.1'
VERSION='2.3.2'
 
 
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.3.1, which was
This file was extended by enchant $as_me 2.3.2, 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.3.1
enchant config.status 2.3.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
 
......
AC_INIT([enchant],[2.3.1])
AC_INIT([enchant],[2.3.2])
AC_CONFIG_SRCDIR(src/enchant.h)
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([subdir-objects])
......
......@@ -71,7 +71,7 @@ aspell_dict_suggest (EnchantDict * me, const char *const word,
size_t len, size_t * out_n_suggs)
{
AspellSpeller *manager = (AspellSpeller *) me->user_data;
char *normalizedWord = g_utf8_normalize (word, len, G_NORMALIZE_NFC);
const AspellWordList *word_list = aspell_speller_suggest (manager, normalizedWord, strlen(normalizedWord));
g_free(normalizedWord);
......@@ -84,11 +84,11 @@ aspell_dict_suggest (EnchantDict * me, const char *const word,
{
size_t n_suggestions = aspell_word_list_size (word_list);
*out_n_suggs = n_suggestions;
if (n_suggestions)
{
sugg_arr = g_new0 (char *, n_suggestions + 1);
for (size_t i = 0; i < n_suggestions; i++)
{
const char *sugg = aspell_string_enumeration_next (suggestions);
......@@ -99,7 +99,7 @@ aspell_dict_suggest (EnchantDict * me, const char *const word,
delete_aspell_string_enumeration (suggestions);
}
}
return sugg_arr;
}
......@@ -137,18 +137,19 @@ aspell_provider_request_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, const c
AspellConfig *spell_config = new_aspell_config ();
aspell_config_replace (spell_config, "language-tag", tag);
aspell_config_replace (spell_config, "encoding", "utf-8");
AspellCanHaveError *spell_error = new_aspell_speller (spell_config);
delete_aspell_config (spell_config);
if (aspell_error_number (spell_error) != 0)
{
enchant_provider_set_error (me, aspell_error_message (spell_error));
delete_aspell_can_have_error(spell_error);
return NULL;
}
AspellSpeller *manager = to_aspell_speller (spell_error);
EnchantDict *dict = g_new0 (EnchantDict, 1);
dict->user_data = (void *) manager;
dict->check = aspell_dict_check;
......@@ -156,7 +157,7 @@ aspell_provider_request_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, const c
dict->add_to_personal = aspell_dict_add_to_personal;
dict->add_to_session = aspell_dict_add_to_session;
dict->store_replacement = aspell_dict_store_replacement;
return dict;
}
......@@ -165,12 +166,12 @@ aspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, Enchant
{
AspellSpeller *manager = (AspellSpeller *) dict->user_data;
delete_aspell_speller (manager);
g_free (dict);
}
static char **
aspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
static char **
aspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
size_t * out_n_dicts)
{
AspellConfig * spell_config = new_aspell_config ();
......@@ -190,18 +191,18 @@ aspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
if (*out_n_dicts) {
out_list = g_new0 (char *, *out_n_dicts + 1);
dels = aspell_dict_info_list_elements (dlist);
for (size_t i = 0; i < *out_n_dicts; i++) {
entry = aspell_dict_info_enumeration_next (dels);
entry = aspell_dict_info_enumeration_next (dels);
/* FIXME: should this be entry->code or entry->name ? */
out_list[i] = g_strdup (entry->code);
}
delete_aspell_dict_info_enumeration (dels);
}
delete_aspell_config (spell_config);
return out_list;
}
......
......@@ -66,7 +66,7 @@ corlist2strv (struct corlist *cl, size_t nb_sugg)
"utf-8", "iso8859-8", NULL, &len, NULL);
}
}
return sugg_arr;
}
......@@ -87,17 +87,17 @@ hspell_dict_check (EnchantDict * me, const char *const word, size_t len)
struct dict_radix *hspell_dict = (struct dict_radix *)me->user_data;
char *iso_word = hspell_convert_to_iso8859_8 (me, word, len);
g_return_val_if_fail (iso_word, -1);
/* check */
int preflen;
int res = hspell_check_word (hspell_dict, iso_word, &preflen);
/* if not correct try gimatria */
if (res != 1)
res = hspell_is_canonic_gimatria (iso_word) != 0;
g_free (iso_word);
return (res != 1);
}
......@@ -113,13 +113,13 @@ hspell_dict_suggest (EnchantDict * me, const char *const word,
struct corlist cl;
corlist_init (&cl);
hspell_trycorrect (hspell_dict, iso_word, &cl);
*out_n_suggs = corlist_n (&cl);
char **sugg_arr = corlist2strv (&cl, *out_n_suggs);
corlist_free (&cl);
g_free (iso_word);
return sugg_arr;
return sugg_arr;
}
static EnchantDict *
......@@ -127,22 +127,22 @@ hspell_provider_request_dict (EnchantProvider * me, const char *const tag)
{
if(!((strlen(tag) >= 2) && tag[0] == 'h' && tag[1] == 'e'))
return NULL;
/* try to set a new session */
struct dict_radix *hspell_dict = NULL;
int dict_flag = hspell_init (&hspell_dict, HSPELL_OPT_DEFAULT);
if (dict_flag != 0 || !hspell_dict)
{
enchant_provider_set_error (me, "can't create new dict.");
return NULL;
}
EnchantDict *dict = g_new0 (EnchantDict, 1);
dict->user_data = (void *) hspell_dict;
dict->check = hspell_dict_check;
dict->suggest = hspell_dict_suggest;
return dict;
}
......@@ -156,8 +156,8 @@ hspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, Enchant
/* test for the existence of, then return $prefix/share/hspell/hebrew.wgz */
static char **
hspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
static char **
hspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
size_t * out_n_dicts)
{
const char * dictionary_path = hspell_get_dictionary_path();
......@@ -167,8 +167,8 @@ hspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
if(dictionary_path && *dictionary_path && g_file_test (dictionary_path, G_FILE_TEST_EXISTS)) {
out_list = g_new0 (char *, 2);
out_list[(*out_n_dicts)++] = g_strdup ("he");
}
}
return out_list;
}
......
......@@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <string>
#include <vector>
......@@ -242,16 +242,16 @@ static bool is_plausible_dict_for_tag(const char *dir_entry, const char *tag)
size_t tag_len = strlen(tag);
if (dir_entry_len - dic_suffix_len < tag_len)
return false;
return false;
if (strcmp(dir_entry+dir_entry_len-dic_suffix_len, dic_suffix) != 0)
return false;
return false;
if (strncmp (dir_entry, tag, tag_len) != 0)
return false;
return false;
//e.g. requested dict for "fi",
//reject "fil_PH.dic"
//allow "fi-FOO.dic", "fi_FOO.dic", "fi.dic", etc.
if (!ispunct(dir_entry[tag_len]))
return false;
return false;
return true;
}
......@@ -268,7 +268,7 @@ hunspell_request_dictionary (const char * tag)
return strdup (names[i].c_str());
}
}
std::vector<std::string> dirs;
s_buildDictionaryDirs (dirs);
......@@ -278,7 +278,7 @@ hunspell_request_dictionary (const char * tag)
const char *dir_entry;
while ((dir_entry = g_dir_read_name (dir)) != NULL) {
if (is_plausible_dict_for_tag(dir_entry, tag)) {
char *dict = g_build_filename (dirs[i].c_str(),
char *dict = g_build_filename (dirs[i].c_str(),
dir_entry, nullptr);
if(s_fileExists(s_correspondingAffFile(dict))) {
g_dir_close (dir);
......@@ -348,10 +348,10 @@ static int
hunspell_dict_check (EnchantDict * me, const char *const word, size_t len)
{
HunspellChecker * checker = static_cast<HunspellChecker *>(me->user_data);
if (checker->checkWord(word, len))
return 0;
return 1;
}
......@@ -410,8 +410,8 @@ hunspell_provider_enum_dicts (const char * const directory,
extern "C" {
static char **
hunspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
static char **
hunspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
size_t * out_n_dicts)
{
std::vector<std::string> dict_dirs, dicts;
......@@ -439,15 +439,15 @@ static EnchantDict *
hunspell_provider_request_dict(EnchantProvider * me _GL_UNUSED_PARAMETER, const char *const tag)
{
HunspellChecker * checker = new HunspellChecker();
if (!checker)
return NULL;
if (!checker->requestDictionary(tag)) {
delete checker;
return NULL;
}
EnchantDict *dict = g_new0(EnchantDict, 1);
dict->user_data = (void *) checker;
dict->check = hunspell_dict_check;
......@@ -455,7 +455,7 @@ hunspell_provider_request_dict(EnchantProvider * me _GL_UNUSED_PARAMETER, const
// don't implement personal, session
dict->get_extra_word_characters = hunspell_dict_get_extra_word_characters;
dict->is_word_character = hunspell_dict_is_word_character;
return dict;
}
......@@ -464,7 +464,7 @@ hunspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, Encha
{
HunspellChecker *checker = (HunspellChecker *) dict->user_data;
delete checker;
g_free (dict);
}
......
......@@ -50,7 +50,7 @@
static int
voikko_dict_check (EnchantDict * me, const char *const word, size_t len)
{
char *word_nul = strndup(word, len);
char *word_nul = g_strndup(word, len);
int result = voikkoSpellCstr((struct VoikkoHandle *)me->user_data, word_nul);
free(word_nul);
if (result == VOIKKO_SPELL_FAILED)
......@@ -65,7 +65,7 @@ static char **
voikko_dict_suggest (EnchantDict * me, const char *const word,
size_t len, size_t * out_n_suggs)
{
char *word_nul = strndup(word, len);
char *word_nul = g_strndup(word, len);
char **voikko_sugg_arr = voikkoSuggestCstr((struct VoikkoHandle *)me->user_data, word_nul);
free(word_nul);
if (voikko_sugg_arr == NULL)
......@@ -113,7 +113,7 @@ voikko_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
static int
voikko_provider_dictionary_exists (struct str_enchant_provider * me _GL_UNUSED_PARAMETER,
const char *const tag)
const char *const tag)
{
size_t i;
int exists = 0;
......
/* Copyright (C) 2006 Barış Metin <baris@pardus.org.tr>
* Copyright (C) 2007 Serkan Kaba <serkan_kaba@yahoo.com>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
......@@ -52,7 +52,7 @@ static bool zemberek_service_is_running ()
"/net/zemberekserver/server/dbus/ZemberekDbus",
"net.zemberekserver.server.dbus.ZemberekDbusInterface",
&Error);
dbus_g_connection_unref (connection);
if (proxy == NULL) {
return false;
......@@ -67,7 +67,7 @@ class Zemberek
public:
Zemberek();
~Zemberek();
int checkWord(const char* word) const;
char** suggestWord(const char* word, size_t *out_n_suggs);
......@@ -101,9 +101,9 @@ Zemberek::Zemberek()
Zemberek::~Zemberek()
{
if(proxy)
g_object_unref (proxy);
g_object_unref (proxy);
if(connection)
dbus_g_connection_unref (connection);
dbus_g_connection_unref (connection);
}
......@@ -112,10 +112,10 @@ int Zemberek::checkWord(const char* word) const
gboolean result;
GError *Error = NULL;
if (!dbus_g_proxy_call (proxy, "kelimeDenetle", &Error,
G_TYPE_STRING,word,G_TYPE_INVALID,
G_TYPE_BOOLEAN, &result, G_TYPE_INVALID)) {
g_error_free (Error);
return -1;
G_TYPE_STRING,word,G_TYPE_INVALID,
G_TYPE_BOOLEAN, &result, G_TYPE_INVALID)) {
g_error_free (Error);
return -1;
}
else
return !result;
......@@ -127,10 +127,10 @@ char** Zemberek::suggestWord(const char* word, size_t *out_n_suggs)
char** suggs;
GError *Error = NULL;
if (!dbus_g_proxy_call (proxy, "oner", &Error,
G_TYPE_STRING,word,G_TYPE_INVALID,
G_TYPE_STRV, &suggs,G_TYPE_INVALID)) {
g_error_free (Error);
return NULL;
G_TYPE_STRING,word,G_TYPE_INVALID,
G_TYPE_STRV, &suggs,G_TYPE_INVALID)) {
g_error_free (Error);
return NULL;
}
*out_n_suggs = g_strv_length(suggs);
return suggs;
......@@ -172,23 +172,23 @@ static EnchantDict*
zemberek_provider_request_dict(EnchantProvider *me _GL_UNUSED_PARAMETER, const char *tag)
{
if (!((strcmp(tag, "tr") == 0) || (strncmp(tag, "tr_", 3) == 0)))
return NULL; // only handle turkish
return NULL; // only handle turkish
try
{
Zemberek* checker = new Zemberek();
Zemberek* checker = new Zemberek();
EnchantDict* dict = g_new0(EnchantDict, 1);
dict->user_data = (void *) checker;
dict->check = zemberek_dict_check;
dict->suggest = zemberek_dict_suggest;
EnchantDict* dict = g_new0(EnchantDict, 1);
dict->user_data = (void *) checker;
dict->check = zemberek_dict_check;
dict->suggest = zemberek_dict_suggest;
return dict;
return dict;
}
catch(...)
{
// will fail if zemberek service isn't running
return NULL;
// will fail if zemberek service isn't running
return NULL;
}
}
......@@ -203,31 +203,31 @@ zemberek_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, Encha
static const char *
zemberek_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER)
{
return "zemberek";
return "zemberek";
}
static const char *
zemberek_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER)
{
return "Zemberek Provider";
return "Zemberek Provider";
}
static char **
zemberek_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER,
size_t * out_n_dicts)
size_t * out_n_dicts)
{
if (!zemberek_service_is_running ())
{
*out_n_dicts = 0;
return NULL;
*out_n_dicts = 0;
return NULL;
}
else
{
*out_n_dicts = 1;
char ** out_list = g_new0 (char *, 2);
out_list[0] = g_strdup ("tr");
*out_n_dicts = 1;
char ** out_list = g_new0 (char *, 2);
out_list[0] = g_strdup ("tr");
return out_list;
return out_list;
}
}
......
......@@ -19,13 +19,14 @@ endif
libenchant_includedir = $(pkgincludedir)-@ENCHANT_MAJOR_VERSION@
libenchant_include_HEADERS = enchant.h enchant-provider.h enchant++.h
noinst_HEADERS = debug.h
pkgdata_DATA = enchant.ordering
dist_man_MANS = enchant-@ENCHANT_MAJOR_VERSION@.1 enchant-lsmod-@ENCHANT_MAJOR_VERSION@.1
edit = sed \
-e 's|@datadir[@]|$(datadir)|g'
-e 's|DATADIR|$(datadir)|g'
DISTCLEANFILES = $(dist_man_MANS)
......@@ -35,9 +36,7 @@ enchant-@ENCHANT_MAJOR_VERSION@.1: $(builddir)/enchant.1 Makefile.am $(top_build
mv $@.tmp $@
enchant-lsmod-@ENCHANT_MAJOR_VERSION@.1: $(builddir)/enchant-lsmod.1 Makefile.am $(top_builddir)/config.status
rm -f $@ $@.tmp
$(edit) $(abs_builddir)/enchant-lsmod.1 >$@.tmp
mv $@.tmp $@
cp $(abs_builddir)/enchant-lsmod.1 $@
LDADD = libenchant-@ENCHANT_MAJOR_VERSION@.la $(ENCHANT_LIBS) $(top_builddir)/lib/libgnu.la
bin_PROGRAMS = enchant-@ENCHANT_MAJOR_VERSION@ enchant-lsmod-@ENCHANT_MAJOR_VERSION@
......
......@@ -127,7 +127,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(libenchant_include_HEADERS) \
$(am__DIST_COMMON)
$(noinst_HEADERS) $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = libenchant.rc enchant.1 enchant-lsmod.1
......@@ -254,7 +254,7 @@ man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(dist_man_MANS)
DATA = $(pkgdata_DATA)
HEADERS = $(libenchant_include_HEADERS)
HEADERS = $(libenchant_include_HEADERS) $(noinst_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
......@@ -800,10 +800,11 @@ libenchant_@ENCHANT_MAJOR_VERSION@_la_SOURCES = lib.c pwl.c enchant.h \
pwl.h $(am__append_3)
libenchant_includedir = $(pkgincludedir)-@ENCHANT_MAJOR_VERSION@
libenchant_include_HEADERS = enchant.h enchant-provider.h enchant++.h
noinst_HEADERS = debug.h
pkgdata_DATA = enchant.ordering
dist_man_MANS = enchant-@ENCHANT_MAJOR_VERSION@.1 enchant-lsmod-@ENCHANT_MAJOR_VERSION@.1
edit = sed \
-e 's|@datadir[@]|$(datadir)|g'
-e 's|DATADIR|$(datadir)|g'
DISTCLEANFILES = $(dist_man_MANS)
LDADD = libenchant-@ENCHANT_MAJOR_VERSION@.la $(ENCHANT_LIBS) $(top_builddir)/lib/libgnu.la
......@@ -1328,9 +1329,7 @@ enchant-@ENCHANT_MAJOR_VERSION@.1: $(builddir)/enchant.1 Makefile.am $(top_build
mv $@.tmp $@
enchant-lsmod-@ENCHANT_MAJOR_VERSION@.1: $(builddir)/enchant-lsmod.1 Makefile.am $(top_builddir)/config.status
rm -f $@ $@.tmp
$(edit) $(abs_builddir)/enchant-lsmod.1 >$@.tmp
mv $@.tmp $@
cp $(abs_builddir)/enchant-lsmod.1 $@
.rc.lo:
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) $< -o $@
......
/* enchant
* Copyright (C) 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* 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
* respects for all of the code used other than said providers. If you modify
* this file, you may extend this exception to your version of the
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*/
#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
......@@ -35,7 +35,7 @@
#include <vector>
#include <exception>
namespace enchant
namespace enchant
{
void set_prefix_dir (const std::string prefix) {
enchant_set_prefix_dir (prefix.c_str ());
......@@ -46,7 +46,7 @@ namespace enchant
class Exception : public std::exception
{
public:
explicit Exception (const char * ex)
explicit Exception (const char * ex)
: std::exception (), m_ex ("") {
if (ex)
m_ex = ex;
......@@ -54,7 +54,7 @@ namespace enchant
virtual ~Exception () noexcept {
}
virtual const char * what () const noexcept {
return m_ex.c_str();
}
......@@ -66,17 +66,17 @@ namespace enchant
class Dict
{
friend class enchant::Broker;
public:
~Dict () {
enchant_broker_free_dict (m_broker, m_dict);
}
bool check (const std::string & utf8word) {
int val;
val = enchant_dict_check (m_dict, utf8word.c_str(),
val = enchant_dict_check (m_dict, utf8word.c_str(),
utf8word.size());
if (val == 0)
return true;
......@@ -89,70 +89,70 @@ namespace enchant
return false; // never reached
}
void suggest (const std::string & utf8word,
void suggest (const std::string & utf8word,
std::vector<std::string> & out_suggestions) {
size_t n_suggs;
char ** suggs;
out_suggestions.clear ();
suggs = enchant_dict_suggest (m_dict, utf8word.c_str(),
suggs = enchant_dict_suggest (m_dict, utf8word.c_str(),
utf8word.size(), &n_suggs);
if (suggs && n_suggs) {
out_suggestions.reserve(n_suggs);
for (size_t i = 0; i < n_suggs; i++) {
out_suggestions.push_back (suggs[i]);
}
enchant_dict_free_string_list (m_dict, suggs);
}
}
std::vector<std::string> suggest (const std::string & utf8word) {
std::vector<std::string> result;
suggest (utf8word, result);
return result;
}
void add (const std::string & utf8word) {
enchant_dict_add (m_dict, utf8word.c_str(),
enchant_dict_add (m_dict, utf8word.c_str(),
utf8word.size());
}
void add_to_session (const std::string & utf8word) {
enchant_dict_add_to_session (m_dict, utf8word.c_str(),
enchant_dict_add_to_session (m_dict, utf8word.c_str(),
utf8word.size());
}
void is_added (const std::string & utf8word) {
enchant_dict_is_added (m_dict, utf8word.c_str(),
enchant_dict_is_added (m_dict, utf8word.c_str(),
utf8word.size());
}
void remove (const std::string & utf8word) {
enchant_dict_remove (m_dict, utf8word.c_str(),
enchant_dict_remove (m_dict, utf8word.c_str(),
utf8word.size());
}
void remove_from_session (const std::string & utf8word) {
enchant_dict_remove_from_session (m_dict, utf8word.c_str(),
enchant_dict_remove_from_session (m_dict, utf8word.c_str(),
utf8word.size());
}
void is_removed (const std::string & utf8word) {
enchant_dict_is_removed (m_dict, utf8word.c_str(),
enchant_dict_is_removed (m_dict, utf8word.c_str(),
utf8word.size());
}
void store_replacement (const std::string & utf8bad,
void store_replacement (const std::string & utf8bad,
const std::string & utf8good) {
enchant_dict_store_replacement (m_dict,
enchant_dict_store_replacement (m_dict,
utf8bad.c_str(), utf8bad.size(),
utf8good.c_str(), utf8good.size());
}
const std::string & get_lang () const {
return m_lang;
}
......@@ -172,7 +172,7 @@ namespace enchant
private:
// space reserved for API/ABI expansion
void * _private[5];
void * _private[5];
static void s_describe_fn (const char * const lang,
const char * const provider_name,
......@@ -180,7 +180,7 @@ namespace enchant
const char * const provider_file,
void * user_data) {
enchant::Dict * dict = static_cast<enchant::Dict *> (user_data);
dict->m_lang = lang;
dict->m_provider_name = provider_name;
dict->m_provider_desc = provider_desc;
......@@ -196,7 +196,7 @@ namespace enchant
Dict ();
Dict (const Dict & rhs);
Dict& operator=(const Dict & rhs);
EnchantDict * m_dict;
EnchantBroker * m_broker;
......@@ -205,12 +205,12 @@ namespace enchant
std::string m_provider_desc;
std::string m_provider_file;
}; // class enchant::Dict
class Broker
{
public:
Broker ()
: m_broker (enchant_broker_init ())
{
......@@ -222,40 +222,40 @@ namespace enchant
Dict * request_dict (const std::string & lang) {
EnchantDict * dict = enchant_broker_request_dict (m_broker, lang.c_str());
if (!dict) {
throw enchant::Exception (enchant_broker_get_error (m_broker));
return 0; // never reached
}
return new Dict (dict, m_broker);
}
Dict * request_pwl_dict (const std::string & pwl) {
EnchantDict * dict = enchant_broker_request_pwl_dict (m_broker, pwl.c_str());
if (!dict) {
throw enchant::Exception (enchant_broker_get_error (m_broker));
return 0; // never reached
}
return new Dict (dict, m_broker);
}
bool dict_exists (const std::string & lang) {
if (enchant_broker_dict_exists (m_broker, lang.c_str()))
return true;
return false;
}
void set_ordering (const std::string & tag, const std::string & ordering) {
enchant_broker_set_ordering (m_broker, tag.c_str(), ordering.c_str());
}
void describe (EnchantBrokerDescribeFn fn, void * user_data = NULL) {
enchant_broker_describe (m_broker, fn, user_data);
}
void list_dicts (EnchantDictDescribeFn fn, void * user_data = NULL) {
enchant_broker_list_dicts (m_broker, fn, user_data);
}
......@@ -265,7 +265,7 @@ namespace enchant
// not implemented
Broker (const Broker & rhs);
Broker& operator=(const Broker & rhs);
EnchantBroker * m_broker;
}; // class enchant::Broker
} // enchant namespace
......
......@@ -36,8 +36,9 @@ Enchant uses global and per-user ordering files named \fIenchant.ordering\fR
to decide which spelling provider to use for particular languages.
The per-user file takes precedence.
.PP
The ordering file takes the form language_tag:<comma-separated list of spelling
providers>. To see what providers are available, run \fIenchant-lsmod-2\fR. '*' is
The ordering file takes the form \fIlanguage_tag:<comma-separated list of spelling
providers>\fR. The language tag is an IETF BCP 47 language tag, typically of the form \fICOUNTRY_LANGUAGE\fR.
To see what dictionaries are available, run \fIenchant-lsmod-2\fR. '*' is
used to mean "use this ordering for all languages, unless instructed otherwise." For example:
.PP
*:aspell,hunspell,nuspell
......@@ -59,11 +60,11 @@ Default: \fI~/.config/enchant\fR
\fICSIDL_LOCAL_APPDATA\\enchant\fR (Windows systems)
Default: \fIC:\\Documents and Settings\\\fRusername\fI\\Local Settings\\Application Data\\enchant
.TP
\fI${prefix}/share/enchant\fR
\fI/home/rrt/.local/share/enchant\fR
(Or the equivalent location relative to the enchant library for a relocatable build.)
.PP
Dictionaries are looked for in a subdirectory with the same name as the
provider; for example, \fI${prefix}/share/enchant/hunspell\fR and
provider; for example, \fI/home/rrt/.local/share/enchant/hunspell\fR and
\fI~/.config/enchant/hunspell\fR.
.PP
Some providers may also look in a standard system directory for their
......
......@@ -103,7 +103,11 @@ main (int argc, char **argv)
} else {
EnchantDict *dict = enchant_broker_request_dict (broker, lang_tag);
if (!dict) {
fprintf (stderr, "No dictionary available for '%s'\n", lang_tag);
fprintf (stderr, "No dictionary available for '%s'", lang_tag);
const char *errmsg = enchant_broker_get_error (broker);
if (errmsg != NULL)
fprintf (stderr, ": %s", errmsg);
putc('\n', stderr);
retcode = 1;
} else {
enchant_dict_describe (dict,
......
......@@ -128,22 +128,22 @@ struct str_enchant_dict
int (*check) (struct str_enchant_dict * me, const char *const word,
size_t len);
/* returns utf8*/
char **(*suggest) (struct str_enchant_dict * me,
const char *const word, size_t len,
size_t * out_n_suggs);
void (*add_to_personal) (struct str_enchant_dict * me,
const char *const word, size_t len);
void (*add_to_session) (struct str_enchant_dict * me,
const char *const word, size_t len);
void (*store_replacement) (struct str_enchant_dict * me,
const char *const mis, size_t mis_len,
const char *const cor, size_t cor_len);
void (*add_to_exclude) (struct str_enchant_dict * me,
const char *const word, size_t len);
......@@ -152,21 +152,21 @@ struct str_enchant_dict
int (*is_word_character) (struct str_enchant_dict * me,
uint32_t uc_in, size_t n);
};
struct str_enchant_provider
{
void *user_data;
void *enchant_private_data;
EnchantBroker * owner;
void (*dispose) (struct str_enchant_provider * me);
EnchantDict *(*request_dict) (struct str_enchant_provider * me,
const char *const tag);
void (*dispose_dict) (struct str_enchant_provider * me,
EnchantDict * dict);
int (*dictionary_exists) (struct str_enchant_provider * me,
const char *const tag);
......
......@@ -36,8 +36,9 @@ Enchant uses global and per-user ordering files named \fIenchant.ordering\fR
to decide which spelling provider to use for particular languages.
The per-user file takes precedence.
.PP
The ordering file takes the form language_tag:<comma-separated list of spelling
providers>. To see what providers are available, run \fIenchant-lsmod-@ENCHANT_MAJOR_VERSION@\fR. '*' is
The ordering file takes the form \fIlanguage_tag:<comma-separated list of spelling
providers>\fR. The language tag is an IETF BCP 47 language tag, typically of the form \fICOUNTRY_LANGUAGE\fR.
To see what dictionaries are available, run \fIenchant-lsmod-@ENCHANT_MAJOR_VERSION@\fR. '*' is
used to mean "use this ordering for all languages, unless instructed otherwise." For example:
.PP
*:aspell,hunspell,nuspell
......@@ -59,11 +60,11 @@ Default: \fI~/.config/enchant\fR
\fICSIDL_LOCAL_APPDATA\\enchant\fR (Windows systems)
Default: \fIC:\\Documents and Settings\\\fRusername\fI\\Local Settings\\Application Data\\enchant
.TP
\fI@datadir@/enchant\fR
\fIDATADIR/enchant\fR
(Or the equivalent location relative to the enchant library for a relocatable build.)
.PP
Dictionaries are looked for in a subdirectory with the same name as the
provider; for example, \fI@datadir@/enchant/hunspell\fR and
provider; for example, \fIDATADIR/enchant/hunspell\fR and
\fI~/.config/enchant/hunspell\fR.
.PP
Some providers may also look in a standard system directory for their
......
......@@ -56,14 +56,14 @@
static const char *charset;
typedef enum
typedef enum
{
MODE_NONE,
MODE_A,
MODE_L
} IspellMode_t;
static void
static void
print_version (FILE * to)
{
fprintf (to, "@(#) International Ispell Version 3.1.20 (but really Enchant %s)\n", PACKAGE_VERSION);
......@@ -110,8 +110,8 @@ consume_line (FILE * in, GString * str)
if (utf) {
g_string_assign (str, utf);
g_free (utf);
}
/* Else str->str stays the same. we'll assume that it's
}
/* Else str->str stays the same. we'll assume that it's
already utf8 and glib is just being stupid. */
}
......@@ -128,10 +128,9 @@ print_utf (const char * str)
if (native) {
fwrite (native, 1, bytes_written, stdout);
g_free (native);
} else {
} else
/* Assume that it's already utf8 and glib is just being stupid. */
printf ("%s", str);
}
}
static int
......@@ -171,7 +170,7 @@ do_mode_a (EnchantDict * dict, EnchantPWL * pwl, GString * word, size_t start_po
printf ("%u ", (unsigned int)lineCount);
print_utf (word->str);
printf (" %u %u:", (unsigned int)n_suggs, (unsigned int)start_pos);
for (size_t i = 0; i < n_suggs; i++) {
putchar (' ');
print_utf (suggs[i]);
......@@ -212,11 +211,11 @@ tokenize_line (EnchantDict * dict, GString * line)
while (cur_pos < line->len && *utf) {
gunichar uc;
/* Skip non-word characters. */
/* Skip non-word characters. */
cur_pos = g_utf8_pointer_to_offset ((const char*)line->str, utf);
uc = g_utf8_get_char (utf);
while (cur_pos < line->len && *utf && !enchant_dict_is_word_character (dict, uc, 0)) {
utf = g_utf8_next_char (utf);
utf = g_utf8_next_char (utf);
uc = g_utf8_get_char (utf);
cur_pos = g_utf8_pointer_to_offset ((const char*)line->str, utf);
}
......@@ -225,13 +224,13 @@ tokenize_line (EnchantDict * dict, GString * line)
/* Skip over word characters. */
while (cur_pos < line->len && *utf && enchant_dict_is_word_character (dict, uc, 1)) {
g_string_append_unichar (word, uc);
utf = g_utf8_next_char (utf);
utf = g_utf8_next_char (utf);
uc = g_utf8_get_char (utf);
cur_pos = g_utf8_pointer_to_offset ((const char*)line->str, utf);
}
/* Skip backwards over any characters that can't appear at the end of a word. */
for (gchar *i_utf = word->str + word->len;
/* Skip backwards over any characters that can't appear at the end of a word. */
for (gchar *i_utf = word->str + word->len;
(i_utf = g_utf8_find_prev_char (word->str, i_utf)) != NULL;
g_string_truncate (word, i_utf - word->str)) {
uc = g_utf8_get_char (i_utf);
......@@ -240,8 +239,8 @@ tokenize_line (EnchantDict * dict, GString * line)
}
/* Save (word, position) tuple. */
if (word->len) {
tokens = g_slist_append (tokens, g_string_new_len (word->str, word->len));
if (word->len) {
tokens = g_slist_append (tokens, g_string_new_len (word->str, word->len));
tokens = g_slist_append (tokens, GINT_TO_POINTER(start_pos));
g_string_truncate (word, 0);
}
......@@ -256,7 +255,7 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
{
EnchantBroker * broker;
EnchantDict * dict;
GString * str, * word = NULL;
GSList * tokens, *token_ptr;
gchar * lang;
......@@ -270,13 +269,13 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
if (dictionary)
lang = strdup (dictionary);
else {
lang = enchant_get_user_language();
lang = enchant_get_user_language();
if(!lang)
return 1;
}
}
/* Enchant will get rid of trailing information like de_DE@euro or de_DE.ISO-8859-15 */
broker = enchant_broker_init ();
dict = enchant_broker_request_dict (broker, lang);
......@@ -290,7 +289,7 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
free (lang);
str = g_string_new (NULL);
while (!was_last_line) {
gboolean mode_A_no_command = FALSE;
was_last_line = consume_line (in, str);
......@@ -364,9 +363,9 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
ssize_t mis_len = comma - mis;
ssize_t cor_len = strlen(str->str) - (cor - str->str);
enchant_dict_store_replacement(dict, mis, mis_len, cor, cor_len);
} else if (g_str_has_prefix(str->str, "$$wc")) { /* Return the extra word chars list */
} else if (g_str_has_prefix(str->str, "$$wc"))
/* Return the extra word chars list */
printf("%s\n", enchant_dict_get_extra_word_characters(dict));
}
}
break;
......@@ -404,11 +403,10 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
if (token_ptr)
g_slist_free (token_ptr);
}
}
if (mode == MODE_A && corrected_something) {
putchar('\n');
}
if (mode == MODE_A && corrected_something)
putchar('\n');
g_string_truncate (str, 0);
fflush (stdout);
}
......@@ -437,9 +435,8 @@ int main (int argc, char ** argv)
g_get_charset(&charset);
#ifdef _WIN32
/* If reading from stdin, its CP may not be the system CP (which glib's locale gives us) */
if (GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR) {
if (GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR)
charset = g_strdup_printf("CP%u", GetConsoleCP());
}
#endif
int optchar;
......@@ -515,6 +512,6 @@ int main (int argc, char ** argv)
enchant_pwl_free (pwl);
if (file)
fclose (fp);
return rval;
}
......@@ -111,7 +111,7 @@ int enchant_broker_dict_exists (EnchantBroker * broker, const char * const tag);
* language that does not explictly declare an ordering.
*/
void enchant_broker_set_ordering (EnchantBroker * broker,
const char * const tag,
const char * const tag,
const char * const ordering);
/**
* enchant_broker_get_error
......@@ -136,7 +136,7 @@ typedef void (*EnchantBrokerDescribeFn) (const char * const provider_name,
const char * const provider_desc,
const char * const provider_dll_file,
void * user_data);
/**
* enchant_broker_describe
* @broker: A non-null #EnchantBroker
......@@ -176,7 +176,7 @@ int enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len)
* Returns: A %null terminated list of UTF-8 encoded suggestions, or %null
*/
char **enchant_dict_suggest (EnchantDict * dict, const char *const word,
ssize_t len, size_t * out_n_suggs);
ssize_t len, size_t * out_n_suggs);
/**
* enchant_dict_add
......
/* enchant
* Copyright (C) 2003, 2004 Dom Lachowicz
* Copyright (C) 2017 Reuben Thomas <rrt@sc3d.org>
* Copyright (C) 2017-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
......@@ -46,6 +46,7 @@
#include "enchant.h"
#include "enchant-provider.h"
#include "debug.h"
#include "pwl.h"
#include "unused-parameter.h"
#include "relocatable.h"
......@@ -166,10 +167,8 @@ enchant_is_valid_dictionary_tag(const char * const tag)
{
const char * it;
for (it = tag; *it; ++it)
{
if(!g_ascii_isalnum(*it) && *it != '_')
return 0;
}
if(!g_ascii_isalnum(*it) && *it != '_')
return 0;
return it != tag; /*empty tag invalid*/
}
......@@ -772,18 +771,20 @@ enchant_provider_is_valid(EnchantProvider * provider)
{
if (provider == NULL)
g_warning ("EnchantProvider cannot be NULL\n");
else if (provider->dispose == NULL)
g_warning ("EnchantProvider's dispose method cannot be NULL\n");
else if (provider->request_dict == NULL)
g_warning ("EnchantProvider's request_dict method cannot be NULL\n");
else if (provider->dispose_dict == NULL)
g_warning ("EnchantProvider's dispose_dict method cannot be NULL\n");
else if (provider->identify == NULL)
g_warning ("EnchantProvider's identify method cannot be NULL\n");
else if (!g_utf8_validate((*provider->identify)(provider), -1, NULL))
g_warning ("EnchantProvider's identify method does not return valid UTF-8.\n");
g_warning ("EnchantProvider's identify method does not return valid UTF-8\n");
else if (provider->describe == NULL)
g_warning ("EnchantProvider's describe method cannot be NULL\n");
else if (!g_utf8_validate((*provider->describe)(provider), -1, NULL))
g_warning ("EnchantProvider's describe method does not return valid UTF-8.\n");
else if (provider->dispose == NULL)
g_warning ("EnchantProvider's dispose method cannot be NULL\n");
else if (provider->dispose_dict == NULL)
g_warning ("EnchantProvider's dispose_dict method cannot be NULL\n");
g_warning ("EnchantProvider's describe method does not return valid UTF-8\n");
else if (provider->list_dicts == NULL)
g_warning ("EnchantProvider's list_dicts method cannot be NULL\n");
else
......@@ -836,14 +837,10 @@ enchant_load_providers_in_dir (EnchantBroker * broker, const char *dir_name)
}
}
else
{
g_module_close (module);
}
g_module_close (module);
}
else
{
g_warning ("Error loading plugin: %s\n", g_module_error());
}
g_warning ("Error loading plugin: %s\n", g_module_error());
g_free (filename);
#ifdef _WIN32
......@@ -961,10 +958,8 @@ enchant_get_ordered_providers (EnchantBroker * broker, const char * const tag)
/* append providers not in the list, or from an unordered list */
for (GSList * iter = broker->provider_list; iter != NULL; iter = g_slist_next (iter))
{
if (!g_slist_find (list, iter->data))
list = g_slist_append (list, iter->data);
}
if (!g_slist_find (list, iter->data))
list = g_slist_append (list, iter->data);
return list;
}
......@@ -1084,25 +1079,19 @@ _enchant_broker_request_dict (EnchantBroker * broker, const char *const tag)
GSList * list = enchant_get_ordered_providers (broker, tag);
for (GSList *listIter = list; listIter != NULL; listIter = g_slist_next (listIter))
{
EnchantProvider * provider;
EnchantProvider * provider = (EnchantProvider *) listIter->data;
provider = (EnchantProvider *) listIter->data;
dict = (*provider->request_dict) (provider, tag);
if (provider->request_dict)
if (dict)
{
dict = (*provider->request_dict) (provider, tag);
if (dict)
{
EnchantSession *session = enchant_session_new (provider, tag);
EnchantDictPrivateData *enchant_dict_private_data = g_new0 (EnchantDictPrivateData, 1);
enchant_dict_private_data->reference_count = 1;
enchant_dict_private_data->session = session;
dict->enchant_private_data = (void *)enchant_dict_private_data;
g_hash_table_insert (broker->dict_map, (gpointer)strdup (tag), dict);
break;
}
EnchantSession *session = enchant_session_new (provider, tag);
EnchantDictPrivateData *enchant_dict_private_data = g_new0 (EnchantDictPrivateData, 1);
enchant_dict_private_data->reference_count = 1;
enchant_dict_private_data->session = session;
dict->enchant_private_data = (void *)enchant_dict_private_data;
g_hash_table_insert (broker->dict_map, (gpointer)strdup (tag), dict);
break;
}
}
g_slist_free (list);
......@@ -1122,9 +1111,7 @@ enchant_broker_request_dict (EnchantBroker * broker, const char *const tag)
char * normalized_tag = enchant_normalize_dictionary_tag (tag);
if(!enchant_is_valid_dictionary_tag(normalized_tag))
{
enchant_broker_set_error (broker, "invalid tag character found");
}
enchant_broker_set_error (broker, "invalid tag character found");
else if ((dict = _enchant_broker_request_dict (broker, normalized_tag)) == NULL)
{
char * iso_639_only_tag = enchant_iso_639_from_tag (normalized_tag);
......@@ -1177,31 +1164,28 @@ enchant_broker_list_dicts (EnchantBroker * broker, EnchantDictDescribeFn fn, voi
{
EnchantProvider *provider = (EnchantProvider *) list->data;
if (provider->list_dicts)
{
size_t n_dicts;
char ** dicts = (*provider->list_dicts) (provider, &n_dicts);
size_t n_dicts;
char ** dicts = (*provider->list_dicts) (provider, &n_dicts);
for (size_t i = 0; i < n_dicts; i++)
{
const char * tag = dicts[i];
if (enchant_is_valid_dictionary_tag (tag)) {
GSList *providers = enchant_get_ordered_providers (broker, tag);
gint this_priority = g_slist_index (providers, provider);
if (this_priority != -1) {
gint min_priority = this_priority + 1;
gpointer ptr = g_hash_table_lookup (tag_map, tag);
if (ptr != NULL)
min_priority = g_slist_index (providers, ptr);
if (this_priority < min_priority)
g_hash_table_insert (tag_map, strdup (tag), provider);
}
g_slist_free (providers);
}
for (size_t i = 0; i < n_dicts; i++)
{
const char * tag = dicts[i];
if (enchant_is_valid_dictionary_tag (tag)) {
GSList *providers = enchant_get_ordered_providers (broker, tag);
gint this_priority = g_slist_index (providers, provider);
if (this_priority != -1) {
gint min_priority = this_priority + 1;
gpointer ptr = g_hash_table_lookup (tag_map, tag);
if (ptr != NULL)
min_priority = g_slist_index (providers, ptr);
if (this_priority < min_priority)
g_hash_table_insert (tag_map, strdup (tag), provider);
}
enchant_free_string_list (dicts);
g_slist_free (providers);
}
}
enchant_free_string_list (dicts);
}
GSList *tags = NULL;
......@@ -1253,20 +1237,16 @@ enchant_provider_dictionary_exists (EnchantProvider * provider, const char * con
int exists = 0;
if (provider->dictionary_exists)
{
exists = (*provider->dictionary_exists) (provider, tag);
}
else if (provider->list_dicts)
exists = (*provider->dictionary_exists) (provider, tag);
else
{
size_t n_dicts;
char ** dicts = (*provider->list_dicts) (provider, &n_dicts);
for (size_t i = 0; i < n_dicts; i++)
{
if (!strcmp(dicts[i], tag)) {
exists = 1;
break;
}
if (!strcmp(dicts[i], tag)) {
exists = 1;
break;
}
enchant_free_string_list (dicts);
......@@ -1286,10 +1266,9 @@ _enchant_broker_dict_exists (EnchantBroker * broker, const char * const tag)
if (g_hash_table_lookup (broker->dict_map, (gpointer) tag) != NULL)
return 1;
for (GSList *list = broker->provider_list; list != NULL; list = g_slist_next (list)) {
for (GSList *list = broker->provider_list; list != NULL; list = g_slist_next (list))
if (enchant_provider_dictionary_exists ((EnchantProvider *) list->data, tag))
return 1;
}
return 0;
}
......@@ -1306,19 +1285,13 @@ enchant_broker_dict_exists (EnchantBroker * broker, const char * const tag)
int exists = 0;
if(!enchant_is_valid_dictionary_tag(normalized_tag))
{
enchant_broker_set_error (broker, "invalid tag character found");
}
enchant_broker_set_error (broker, "invalid tag character found");
else if ((exists = _enchant_broker_dict_exists (broker, normalized_tag)) == 0)
{
char * iso_639_only_tag;
iso_639_only_tag = enchant_iso_639_from_tag (normalized_tag);
char * iso_639_only_tag = enchant_iso_639_from_tag (normalized_tag);
if (strcmp (normalized_tag, iso_639_only_tag) != 0)
{
exists = _enchant_broker_dict_exists (broker, iso_639_only_tag);
}
exists = _enchant_broker_dict_exists (broker, iso_639_only_tag);
free (iso_639_only_tag);
}
......@@ -1346,9 +1319,8 @@ enchant_dict_is_word_character (EnchantDict * dict, uint32_t uc_in, size_t n)
gunichar uc = (gunichar)uc_in;
/* Accept quote marks anywhere except at the end of a word */
if (uc == g_utf8_get_char("'") || uc == g_utf8_get_char("’")) {
if (uc == g_utf8_get_char("'") || uc == g_utf8_get_char("’"))
return n < 2;
}
GUnicodeType type = g_unichar_type(uc);
......@@ -1368,9 +1340,8 @@ enchant_dict_is_word_character (EnchantDict * dict, uint32_t uc_in, size_t n)
return 1; /* Enchant 1.3.0 defines word chars like this. */
case G_UNICODE_DASH_PUNCTUATION:
if ((n == 1) && (type == G_UNICODE_DASH_PUNCTUATION)) {
if ((n == 1) && (type == G_UNICODE_DASH_PUNCTUATION))
return 1; /* hyphens only accepted within a word. */
}
/* Fallthrough */
case G_UNICODE_CONTROL:
......
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,3,1
PRODUCTVERSION 2,3,1,0
FILEVERSION 2,3,2
PRODUCTVERSION 2,3,2,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.3.1"
VALUE "FileVersion", "2.3.2"
VALUE "InternalName", "libenchant-2.3"
VALUE "LegalCopyright", "Copyright (C) 2002-2007 Dom Lachowicz"
VALUE "OriginalFilename", "libenchant-2.3.dll"
VALUE "ProductName", "libenchant"
VALUE "ProductVersion", "2.3.1"
VALUE "ProductVersion", "2.3.2"
END
END
BLOCK "VarFileInfo"
......