Projects
openEuler:Mainline
enchant2
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 2
View file
_service:tar_scm:enchant2.spec
Changed
@@ -1,11 +1,11 @@ Name: enchant2 -Version: 2.2.15 -Release: 2 +Version: 2.3.3 +Release: 1 Summary: Generic spell checking library License: LGPLv2+ URL: https://github.com/AbiWord/enchant Source0: https://github.com/AbiWord/enchant/releases/download/v%{version}/enchant-%{version}.tar.gz -Patch6000: backport-enchant_aspell.patch + BuildRequires: automake autoconf libtool gcc-c++ glib2-devel aspell-devel hunspell-devel libvoikko-devel @@ -94,6 +94,9 @@ %{_mandir}/man1/* %changelog +* Thu Sep 15 2022 lutcunpeng <lutkunpeng@163.com> - 2.3.3-1 +- DESC: update to 2.3.3 + * Thu Apr 29 2021 zhaoyuxing <zhaoyuxing2@huawei.com> - 2.2.15-2 - Type:bugfix - CVE:NA
View file
_service:tar_scm:backport-enchant_aspell.patch
Deleted
@@ -1,44 +0,0 @@ -Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1574893 -Conflict: NA - ---- - configure.ac | 2 +- - providers/Makefile.am | 1 + - tests/test.pwl.orig | 2 -- - 3 files changed, 2 insertions(+), 3 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 4877edc..eda506e 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -210,7 +210,7 @@ build_providers= - dnl Standard providers - ENCHANT_CHECK_PKG_CONFIG_PROVIDER(hunspell, HUNSPELL) - ENCHANT_CHECK_PKG_CONFIG_PROVIDER(nuspell, NUSPELL, nuspell >= 4.1.0) --ENCHANT_CHECK_LIB_PROVIDER(aspell, ASPELL, get_aspell_dict_info_list) -+ENCHANT_CHECK_PKG_CONFIG_PROVIDER(aspell, ASPELL) - ENCHANT_CHECK_LIB_PROVIDER(hspell, HSPELL, hspell_get_dictionary_path,, -lz) - ENCHANT_CHECK_PKG_CONFIG_PROVIDER(voikko, VOIKKO, libvoikko) - dnl FIXME: The test below assumes GCC(-compatible) ObjC++ compiler, but -diff --git a/providers/Makefile.am b/providers/Makefile.am -index 8571dcc..4ba8a94 100644 ---- a/providers/Makefile.am -+++ b/providers/Makefile.am -@@ -12,6 +12,7 @@ AM_LDFLAGS = -module -avoid-version -no-undefined $(ENCHANT_LIBS) $(top_builddir - if WITH_ASPELL - provider_LTLIBRARIES += enchant_aspell.la - endif -+enchant_aspell_la_LIBADD = $(ASPELL_LIBS) - - if WITH_HSPELL - provider_LTLIBRARIES += enchant_hspell.la -diff --git a/tests/test.pwl.orig b/tests/test.pwl.orig -index c6089a7..e69de29 100644 ---- a/tests/test.pwl.orig -+++ b/tests/test.pwl.orig -@@ -1,2 +0,0 @@ --hello --tag --- -2.23.0 -
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="scm">git</param> <param name="url">git@gitee.com:src-openeuler/enchant2.git</param> - <param name="revision">1e017aa1f7f2c8b2312e9b0401dadc7cd15ab0b5</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:enchant-2.2.15.tar.gz/NEWS -> _service:tar_scm:enchant-2.3.3.tar.gz/NEWS
Changed
@@ -1,3 +1,60 @@ +2.3.3 (April 16, 2022) +---------------------- + +Update Nuspell provider, requiring Nuspell 5.1.0. The new provider takes +advantage of recently-added Nuspell APIs to be smaller and simpler. + +Fix the C++ API is_added() method to return a boolean rather than void. + +Require C99 and POSIX 2008, and as a result use fewer gnulib modules, +which gives a modest build time reduction. + + +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) +---------------------- + +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) --------------------------
View file
_service:tar_scm:enchant-2.2.15.tar.gz/configure -> _service:tar_scm:enchant-2.3.3.tar.gz/configure
Changed
@@ -1,6 +1,6 @@ #! /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.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ # 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.3' +PACKAGE_STRING='enchant 2.3.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1787,7 +1787,7 @@ # 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.3 to adapt to many kinds of systems. Usage: $0 OPTION... VAR=VALUE... @@ -1858,7 +1858,7 @@ 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.3:";; esac cat <<\_ACEOF @@ -2025,7 +2025,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -enchant configure 2.2.15 +enchant configure 2.3.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2881,7 +2881,7 @@ 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.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3752,7 +3752,7 @@ # Define the identity of the package. PACKAGE='enchant' - VERSION='2.2.15' + VERSION='2.3.3' cat >>confdefs.h <<_ACEOF @@ -3937,6 +3937,69 @@ +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : + ;; +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +$as_echo "${_am_result}" >&6; } + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5315,69 +5378,6 @@ ac_compile_for_check_decl="$ac_compile" fi -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 -$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } -cat > confinc.mk << 'END' -am__doit: - @echo this is the am__doit target >confinc.out -.PHONY: am__doit -END -am__include="#" -am__quote= -# BSD make does it like this. -echo '.include "confinc.mk" # ignored' > confmf.BSD -# Other make implementations (GNU, Solaris 10, AIX) do it like this. -echo 'include confinc.mk # ignored' > confmf.GNU -_am_result=no -for s in GNU BSD; do - { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 - (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - case $?:`cat confinc.out 2>/dev/null` in #( - '0:this is the am__doit target') : - case $s in #( - BSD) : - am__include='.include' am__quote='"' ;; #( - *) : - am__include='include' am__quote='' ;; -esac ;; #( - *) : - ;; -esac - if test "$am__include" != "#"; then - _am_result="yes ($s style)" - break - fi -done -rm -f confinc.* confmf.* -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 -$as_echo "${_am_result}" >&6; } - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi -
View file
_service:tar_scm:enchant-2.2.15.tar.gz/configure.ac -> _service:tar_scm:enchant-2.3.3.tar.gz/configure.ac
Changed
@@ -1,4 +1,4 @@ -AC_INIT(enchant,2.2.15) +AC_INIT(enchant,2.3.3) AC_CONFIG_SRCDIR(src/enchant.h) AC_CONFIG_AUX_DIR(build-aux) AM_INIT_AUTOMAKE(subdir-objects) @@ -36,7 +36,9 @@ AC_SUBST(ENCHANT_MICRO_VERSION) dnl Checks for programs. -AC_PROG_CC +AC_PROG_CC_C99 +AS_IF(test "$ac_cv_prog_cc_c99" = no, + AC_MSG_ERROR(A C99 or later compiler is required)) gl_EARLY AC_PROG_CXX AX_CXX_COMPILE_STDCXX(11) @@ -78,6 +80,8 @@ nw="$nw -Wconversion" # These warnings usually don’t point to mistakes. nw="$nw -Wsign-conversion" # Likewise. nw="$nw -Wimplicit-fallthrough=5" # We want to allow "fallthrough" comments. + nw="$nw -Wold-style-cast" # Warning from glib macros like g_new0 + nw="$nw -Wuseless-cast" # Likewise gl_MANYWARN_ALL_GCC(warnings) @@ -209,7 +213,7 @@ dnl Standard providers ENCHANT_CHECK_PKG_CONFIG_PROVIDER(hunspell, HUNSPELL) -ENCHANT_CHECK_PKG_CONFIG_PROVIDER(nuspell, NUSPELL, nuspell >= 4.1.0) +ENCHANT_CHECK_PKG_CONFIG_PROVIDER(nuspell, NUSPELL, nuspell >= 5.1.0) ENCHANT_CHECK_LIB_PROVIDER(aspell, ASPELL, get_aspell_dict_info_list) ENCHANT_CHECK_LIB_PROVIDER(hspell, HSPELL, hspell_get_dictionary_path,, -lz) ENCHANT_CHECK_PKG_CONFIG_PROVIDER(voikko, VOIKKO, libvoikko)
View file
_service:tar_scm:enchant-2.2.15.tar.gz/providers/enchant_aspell.c -> _service:tar_scm:enchant-2.3.3.tar.gz/providers/enchant_aspell.c
Changed
@@ -42,7 +42,6 @@ #include <aspell.h> #include "enchant-provider.h" -#include "unused-parameter.h" EnchantProvider *init_enchant_provider (void); @@ -71,7 +70,7 @@ 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 +83,11 @@ { 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 +98,7 @@ delete_aspell_string_enumeration (suggestions); } } - + return sugg_arr; } @@ -132,23 +131,24 @@ } static EnchantDict * -aspell_provider_request_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, const char *const tag) +aspell_provider_request_dict (EnchantProvider * me _GL_UNUSED, const char *const tag) { 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,21 +156,21 @@ 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; } static void -aspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) +aspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED, EnchantDict * dict) { 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, size_t * out_n_dicts) { AspellConfig * spell_config = new_aspell_config (); @@ -190,18 +190,18 @@ 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_listi = g_strdup (entry->code); } - + delete_aspell_dict_info_enumeration (dels); } - + delete_aspell_config (spell_config); - + return out_list; } @@ -212,13 +212,13 @@ } static const char * -aspell_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) +aspell_provider_identify (EnchantProvider * me _GL_UNUSED) { return "aspell"; } static const char * -aspell_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) +aspell_provider_describe (EnchantProvider * me _GL_UNUSED) { return "Aspell Provider"; }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/providers/enchant_hspell.c -> _service:tar_scm:enchant-2.3.3.tar.gz/providers/enchant_hspell.c
Changed
@@ -43,7 +43,6 @@ #include <hspell.h> #include "enchant-provider.h" -#include "unused-parameter.h" /** * convert struct corlist to **char @@ -66,7 +65,7 @@ "utf-8", "iso8859-8", NULL, &len, NULL); } } - + return sugg_arr; } @@ -87,17 +86,17 @@ 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 +112,13 @@ 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,27 +126,27 @@ { if(!((strlen(tag) >= 2) && tag0 == 'h' && tag1 == '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; } static void -hspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) +hspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED, EnchantDict * dict) { struct dict_radix *hspell_dict = (struct dict_radix *)dict->user_data; hspell_uninit (hspell_dict); @@ -156,8 +155,8 @@ /* 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, size_t * out_n_dicts) { const char * dictionary_path = hspell_get_dictionary_path(); @@ -167,8 +166,8 @@ 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; } @@ -187,13 +186,13 @@ } static const char * -hspell_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) +hspell_provider_identify (EnchantProvider * me _GL_UNUSED) { return "hspell"; } static const char * -hspell_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) +hspell_provider_describe (EnchantProvider * me _GL_UNUSED) { return "Hspell Provider"; }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/providers/enchant_hunspell.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/providers/enchant_hunspell.cpp
Changed
@@ -1,5 +1,6 @@ /* 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,33 +30,44 @@ /* * 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" #include <stdio.h> #include <stdlib.h> -#include <string.h> +#include <string.h> #include <string> #include <vector> #include "enchant-provider.h" -#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 +85,7 @@ GIConv m_translate_in; /* Selected translation from/to Unicode */ GIConv m_translate_out; Hunspell *hunspell; + char *wordchars; /* Value returned by getWordChars() */ }; /***************************************************************************/ @@ -84,7 +97,7 @@ } 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 +108,61 @@ 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 word8MAXWORDLEN + 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 word8MAXWORDLEN + 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 *>(sugMSi.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'; - sugi = word; + for (size_t i=0, j=0; i<*nsug; i++) { + const char *in = sugMSi.c_str(); + out = do_iconv(m_translate_out, in); + if (out != NULL) + sugj++ = 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 @@ -247,16 +241,16 @@ 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)
View file
_service:tar_scm:enchant-2.2.15.tar.gz/providers/enchant_nuspell.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/providers/enchant_nuspell.cpp
Changed
@@ -1,4 +1,5 @@ /* enchant + * Copyright (C) 2022 Dimitrij Mijoski * Copyright (C) 2020 Sander van Geloven * * This library is free software; you can redistribute it and/or @@ -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 @@ -35,15 +36,9 @@ #include "config.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <string> -#include <vector> +#include <memory> #include "enchant-provider.h" -#include "unused-parameter.h" #include <nuspell/dictionary.hxx> #include <nuspell/finder.hxx> @@ -51,372 +46,130 @@ #include <glib.h> using namespace std; -using namespace nuspell; - -/***************************************************************************/ -class NuspellChecker +// EnchantDict functions +static int nuspell_dict_check(EnchantDict* me, const char* const word, + size_t len) { -public: - bool checkWord (const char *word, size_t len); - char **suggestWord (const char* const word, size_t len, size_t *out_n_suggs); - - bool requestDictionary (const char * szLang); - -private: - Dictionary nuspell; -}; + auto dict = static_cast<nuspell::Dictionary*>(me->user_data); -/***************************************************************************/ - -bool -NuspellChecker::checkWord(const char *utf8Word, size_t len) -{ - // the 8-bit encodings use precomposed forms - char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC); - auto ret = nuspell.spell(normalizedWord); - g_free(normalizedWord); - return ret; + using UniquePtr = unique_ptr<char, decltype(&g_free)>; + auto normalized_word = + UniquePtr(g_utf8_normalize(word, len, G_NORMALIZE_NFC), g_free); + return !dict->spell(normalized_word.get()); } -char** -NuspellChecker::suggestWord(const char* const utf8Word, size_t len, size_t *nsug) +static char** nuspell_dict_suggest(EnchantDict* me, const char* const word, + size_t len, size_t* out_n_suggs) { + auto dict = static_cast<nuspell::Dictionary*>(me->user_data); + + using UniquePtr = unique_ptr<char, decltype(&g_free)>; // the 8-bit encodings use precomposed forms - char *normalizedWord = g_utf8_normalize (utf8Word, len, G_NORMALIZE_NFC); + auto normalized_word = + UniquePtr(g_utf8_normalize(word, len, G_NORMALIZE_NFC), g_free); auto suggestions = vector<string>(); - nuspell.suggest(normalizedWord, suggestions); - g_free(normalizedWord); - if (suggestions.empty()) + dict->suggest(normalized_word.get(), suggestions); + if (empty(suggestions)) { + *out_n_suggs = 0; return nullptr; - *nsug = suggestions.size(); - char **sug = g_new0 (char *, *nsug + 1); - size_t i = 0; - for (auto& suggest : suggestions) { - char *word = g_new0(char, suggest.size() + 1); - strcpy(word, suggest.c_str()); - sugi = word; - i++; - } - return sug; -} - -static void -s_buildDictionaryDirs (vector<string> & dirs) -{ - dirs.clear (); - - /* 1. personal overrides for Enchant - * ~/.config/enchant/nuspell - */ - gchar * tmp; - char * config_dir = enchant_get_user_config_dir (); - tmp = g_build_filename (config_dir, "nuspell", nullptr); - dirs.push_back (tmp); - free (config_dir); - g_free(tmp); - - /* Dynamically retrieved from Nuspell dictionary finder: - * 2. personal overrides for Hunspell - * $XDG_DATA_HOME/hunspell - * $XDG_DATA_HOME by default is $HOME/.local/share/ - * 3. system installed for Hunspell - * $XDG_DATA_DIRS/hunspell - * $XDG_DATA_DIRS/myspell (needed for Fedora) - * $XDG_DATA_DIRS by default are /usr/local/share and /usr/share - */ - nuspell::append_default_dir_paths(dirs); - - /* 5. system installations by Enchant - * /usr/local/share/enchant/nuspell - * /usr/share/enchant/nuspell - */ - char * enchant_prefix = enchant_get_prefix_dir(); - if (enchant_prefix) { - tmp = g_build_filename(enchant_prefix, "share", "enchant", "nuspell", nullptr); - dirs.push_back (tmp); - g_free(enchant_prefix); - g_free(tmp); - } - - /* Hunspell paths are used, therefore ENCHANT_NUSPELL_DICT_DIR is - * irrelevant. Hence, the following paths are not to be considered: - * /usr/local/share/nuspell and /usr/share/nuspell - */ -} - -static void -s_buildHashNames (vector<string> & names, const char * dict) -{ - names.clear (); - - vector<string> dirs; - s_buildDictionaryDirs (dirs); - - char *dict_dic = g_strconcat(dict, ".dic", nullptr); - for (size_t i = 0; i < dirs.size(); i++) { - char *tmp = g_build_filename (dirsi.c_str(), dict_dic, nullptr); - names.push_back (tmp); - g_free (tmp); - } - - g_free(dict_dic); -} - -static const string -s_correspondingAffFile(const string & dicFile) -{ - string aff = dicFile; - if (aff.size() >= 4 && aff.compare(aff.size() - 4, 4, ".dic") == 0) { - aff.erase(aff.size() - 3); - aff += "aff"; } - return aff; + char** sug_list = g_new0(char*, size(suggestions) + 1); + transform(begin(suggestions), end(suggestions), sug_list, + (const string& sug) { return g_strdup(sug.c_str()); }); + *out_n_suggs = size(suggestions); + return sug_list; } +// End EnchantDict functions -static bool -s_fileExists(const string & file) -{ - return g_file_test(file.c_str(), G_FILE_TEST_EXISTS) != 0; -} +// EnchantProvider functions +static void nuspell_provider_dispose(EnchantProvider* me) { g_free(me); } -static bool is_plausible_dict_for_tag(const char *dir_entry, const char *tag) +static EnchantDict* +nuspell_provider_request_dict(_GL_UNUSED EnchantProvider* me, + const char* const tag) { - const char *dic_suffix = ".dic"; - size_t dic_suffix_len = strlen(dic_suffix);
View file
_service:tar_scm:enchant-2.2.15.tar.gz/providers/enchant_voikko.c -> _service:tar_scm:enchant-2.3.3.tar.gz/providers/enchant_voikko.c
Changed
@@ -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 @@ -37,7 +37,6 @@ #include <string.h> #include <libvoikko/voikko.h> -#include "unused-parameter.h" #include "enchant-provider.h" @@ -50,7 +49,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 +64,7 @@ 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) @@ -81,14 +80,14 @@ } static void -voikko_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) +voikko_provider_dispose_dict (EnchantProvider * me _GL_UNUSED, EnchantDict * dict) { voikkoTerminate((struct VoikkoHandle *)dict->user_data); free (dict); } static char ** -voikko_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, +voikko_provider_list_dicts (EnchantProvider * me _GL_UNUSED, size_t * out_n_dicts) { size_t i; @@ -112,8 +111,8 @@ } static int -voikko_provider_dictionary_exists (struct str_enchant_provider * me _GL_UNUSED_PARAMETER, - const char *const tag) +voikko_provider_dictionary_exists (struct str_enchant_provider * me _GL_UNUSED, + const char *const tag) { size_t i; int exists = 0; @@ -160,13 +159,13 @@ } static const char * -voikko_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) +voikko_provider_identify (EnchantProvider * me _GL_UNUSED) { return "voikko"; } static const char * -voikko_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) +voikko_provider_describe (EnchantProvider * me _GL_UNUSED) { return "Voikko Provider"; }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/providers/enchant_zemberek.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/providers/enchant_zemberek.cpp
Changed
@@ -1,6 +1,6 @@ /* 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 @@ -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 @@ -34,7 +34,6 @@ #include <glib.h> #include "enchant-provider.h" -#include "unused-parameter.h" static bool zemberek_service_is_running () @@ -52,7 +51,7 @@ "/net/zemberekserver/server/dbus/ZemberekDbus", "net.zemberekserver.server.dbus.ZemberekDbusInterface", &Error); - + dbus_g_connection_unref (connection); if (proxy == NULL) { return false; @@ -67,7 +66,7 @@ public: Zemberek(); ~Zemberek(); - + int checkWord(const char* word) const; char** suggestWord(const char* word, size_t *out_n_suggs); @@ -101,9 +100,9 @@ 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 +111,10 @@ 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 +126,10 @@ 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; @@ -169,31 +168,31 @@ } static EnchantDict* -zemberek_provider_request_dict(EnchantProvider *me _GL_UNUSED_PARAMETER, const char *tag) +zemberek_provider_request_dict(EnchantProvider *me _GL_UNUSED, 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; } } static void -zemberek_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, EnchantDict * dict) +zemberek_provider_dispose_dict (EnchantProvider * me _GL_UNUSED, EnchantDict * dict) { Zemberek *checker = (Zemberek *) dict->user_data; delete checker; @@ -201,33 +200,33 @@ } static const char * -zemberek_provider_identify (EnchantProvider * me _GL_UNUSED_PARAMETER) +zemberek_provider_identify (EnchantProvider * me _GL_UNUSED) { - return "zemberek"; + return "zemberek"; } static const char * -zemberek_provider_describe (EnchantProvider * me _GL_UNUSED_PARAMETER) +zemberek_provider_describe (EnchantProvider * me _GL_UNUSED) { - return "Zemberek Provider"; + return "Zemberek Provider"; } static char ** -zemberek_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, - size_t * out_n_dicts) +zemberek_provider_list_dicts (EnchantProvider * me _GL_UNUSED, + 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_list0 = g_strdup ("tr"); + *out_n_dicts = 1; + char ** out_list = g_new0 (char *, 2); + out_list0 = g_strdup ("tr"); - return out_list; + return out_list; } }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/Makefile.am -> _service:tar_scm:enchant-2.3.3.tar.gz/src/Makefile.am
Changed
@@ -19,13 +19,14 @@ 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 @@ 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@
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/Makefile.in -> _service:tar_scm:enchant-2.3.3.tar.gz/src/Makefile.in
Changed
@@ -127,7 +127,7 @@ 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 @@ 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 @@ 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 @@ 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 $@
View file
_service:tar_scm:enchant-2.3.3.tar.gz/src/debug.h
Added
@@ -0,0 +1,34 @@ +/* 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
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant++.h -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant++.h
Changed
@@ -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 @@ 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 @@ virtual ~Exception () noexcept { } - + virtual const char * what () const noexcept { return m_ex.c_str(); } @@ -66,17 +66,17 @@ 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 @@ 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 (suggsi); } - + 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(), - utf8word.size()); + + bool is_added (const std::string & utf8word) { + return 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 @@ private: // space reserved for API/ABI expansion - void * _private5; + void * _private5; static void s_describe_fn (const char * const lang, const char * const provider_name, @@ -180,7 +180,7 @@ 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 @@ Dict (); Dict (const Dict & rhs); Dict& operator=(const Dict & rhs); - + EnchantDict * m_dict; EnchantBroker * m_broker; @@ -205,12 +205,12 @@ 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 @@ 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); }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant-2.1 -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant-2.1
Changed
@@ -14,6 +14,9 @@ \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 @@ -33,8 +36,9 @@ 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 @@ -56,11 +60,11 @@ \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
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant-lsmod.c -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant-lsmod.c
Changed
@@ -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 @@ -34,7 +34,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "unused-parameter.h" #include "enchant.h" #include "enchant-provider.h" @@ -42,18 +41,18 @@ static void describe_dict (const char * const lang_tag, const char * const provider_name, - const char * const provider_desc _GL_UNUSED_PARAMETER, - const char * const provider_file _GL_UNUSED_PARAMETER, - void * user_data _GL_UNUSED_PARAMETER) + const char * const provider_desc _GL_UNUSED, + const char * const provider_file _GL_UNUSED, + void * user_data _GL_UNUSED) { printf ("%s (%s)\n", lang_tag, provider_name); } static void -describe_word_chars (const char * const lang_tag _GL_UNUSED_PARAMETER, - const char * const provider_name _GL_UNUSED_PARAMETER, - const char * const provider_desc _GL_UNUSED_PARAMETER, - const char * const provider_file _GL_UNUSED_PARAMETER, +describe_word_chars (const char * const lang_tag _GL_UNUSED, + const char * const provider_name _GL_UNUSED, + const char * const provider_desc _GL_UNUSED, + const char * const provider_file _GL_UNUSED, void * user_data) { EnchantDict *dict = (EnchantDict *)user_data; @@ -66,8 +65,8 @@ static void describe_provider (const char * name, const char * desc, - const char * file _GL_UNUSED_PARAMETER, - void * user_data _GL_UNUSED_PARAMETER) + const char * file _GL_UNUSED, + void * user_data _GL_UNUSED) { printf ("%s (%s)\n", name, desc); } @@ -103,7 +102,11 @@ } 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,
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant-provider.h -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant-provider.h
Changed
@@ -51,30 +51,53 @@ */ 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 @@ * @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); @@ -105,22 +128,22 @@ 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); @@ -129,21 +152,21 @@ 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); @@ -160,4 +183,4 @@ } #endif -#endif /* ENCHANT_H */ +#endif /* ENCHANT_PROVIDER_H */
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant.1.in -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant.1.in
Changed
@@ -14,6 +14,9 @@ \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 @@ -33,8 +36,9 @@ 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 @@ -56,11 +60,11 @@ \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
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant.c -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant.c
Changed
@@ -1,7 +1,7 @@ /* 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" @@ -55,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); @@ -75,6 +76,7 @@ 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\ @@ -108,8 +110,8 @@ 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. */ } @@ -126,16 +128,25 @@ 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 +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 +156,8 @@ } 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) @@ -157,7 +170,7 @@ 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 (suggsi); @@ -174,9 +187,9 @@ } 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); @@ -198,11 +211,11 @@ 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); } @@ -211,13 +224,13 @@ /* 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); @@ -226,8 +239,8 @@ } /* 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); } @@ -238,11 +251,11 @@ } 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; - + GString * str, * word = NULL; GSList * tokens, *token_ptr; gchar * lang; @@ -256,13 +269,13 @@ 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); @@ -276,7 +289,7 @@ free (lang);
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant.h -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant.h
Changed
@@ -111,7 +111,7 @@ * 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 @@ 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 @@ * 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
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/enchant.ordering -> _service:tar_scm:enchant-2.3.3.tar.gz/src/enchant.ordering
Changed
@@ -1,4 +1,8 @@ *: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
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/lib.c -> _service:tar_scm:enchant-2.3.3.tar.gz/src/lib.c
Changed
@@ -1,6 +1,6 @@ /* 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 @@ -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 @@ -46,8 +46,8 @@ #include "enchant.h" #include "enchant-provider.h" +#include "debug.h" #include "pwl.h" -#include "unused-parameter.h" #include "relocatable.h" #include "configmake.h" @@ -161,15 +161,13 @@ /* returns TRUE if tag is valid * for requires alphanumeric ASCII or underscore */ -static _GL_ATTRIBUTE_PURE int +static G_GNUC_PURE int 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 +770,20 @@ { 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 @@ -808,6 +808,7 @@ size_t entry_len = strlen (dir_entry); if ((entry_len > g_module_suffix_len) && + dir_entry0 != '.' && /* Skip hidden files */ !strcmp(dir_entry+(entry_len-g_module_suffix_len), G_MODULE_SUFFIX)) { #ifdef _WIN32 @@ -835,14 +836,10 @@ } } 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 @@ -960,10 +957,8 @@ /* 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; } @@ -1083,25 +1078,19 @@ 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); @@ -1121,9 +1110,7 @@ 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); @@ -1176,31 +1163,28 @@ { 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 = dictsi; - 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 = dictsi; + 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);
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/libenchant.rc -> _service:tar_scm:enchant-2.3.3.tar.gz/src/libenchant.rc
Changed
@@ -1,8 +1,8 @@ #include <winver.h> VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,2,15 - PRODUCTVERSION 2,2,15,0 + FILEVERSION 2,3,3 + PRODUCTVERSION 2,3,3,0 FILEFLAGSMASK 0 FILEFLAGS 0 FILEOS VOS__WINDOWS32 @@ -15,12 +15,12 @@ BEGIN VALUE "CompanyName", "none" VALUE "FileDescription", "libenchant" - VALUE "FileVersion", "2.2.15" - VALUE "InternalName", "libenchant-2.2" + VALUE "FileVersion", "2.3.3" + 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.3" END END BLOCK "VarFileInfo"
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/pwl.c -> _service:tar_scm:enchant-2.3.3.tar.gz/src/pwl.c
Changed
@@ -1,5 +1,6 @@ /* enchant * Copyright (C) 2003, 2004 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 @@ -64,7 +65,6 @@ #include <glib.h> #include <glib/gstdio.h> #include "enchant-provider.h" -#include "unused-parameter.h" #include "pwl.h" @@ -75,7 +75,7 @@ /* A PWL dictionary is stored as a Trie-like data structure EnchantTrie. * The EnchantTrie datatype is completely recursive - all child nodes - * are simply EnchantTrie pointers. This means that all functions + * are simply EnchantTrie pointers. This means that all functions * that potentially modify a trie need to return the modified trie, * as additional memory may have been allocated. * @@ -202,7 +202,7 @@ * * Returns: a new PWL object used to store/check/suggest words * or NULL if the file cannot be opened or created - */ + */ EnchantPWL* enchant_pwl_init_with_file(const char * file) { g_return_val_if_fail (file != NULL, NULL); @@ -233,13 +233,13 @@ pwl->words_in_trie = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); FILE *f = g_fopen(pwl->filename, "r"); - if (!f) + if (!f) return; pwl->file_changed = stats.st_mtime; enchant_lock_file (f); - + char bufferBUFSIZ + 1; size_t line_number = 1; for (; NULL != (fgets (buffer, sizeof (buffer), f)); ++line_number) @@ -248,12 +248,12 @@ if(line_number == 1 && BOM == g_utf8_get_char(line)) line = g_utf8_next_char(line); - if(linestrlen(line)-1 != '\n' && !feof(f)) /* ignore lines longer than BUFSIZ. */ + if(linestrlen(line)-1 != '\n' && !feof(f)) /* ignore lines longer than BUFSIZ. */ { g_warning ("Line too long (ignored) in %s at line:%zu\n", pwl->filename, line_number); while (NULL != (fgets (buffer, sizeof (buffer), f))) { - if (linestrlen(buffer)-1=='\n') + if (linestrlen(buffer)-1=='\n') break; } continue; @@ -268,7 +268,7 @@ g_warning ("Bad UTF-8 sequence in %s at line:%zu\n", pwl->filename, line_number); } } - + enchant_unlock_file (f); fclose (f); } @@ -289,7 +289,7 @@ g_free (normalized_word); return; } - + g_hash_table_insert (pwl->words_in_trie, normalized_word, g_strndup(word,len)); pwl->trie = enchant_trie_insert(pwl->trie, normalized_word); @@ -308,13 +308,16 @@ pwl->trie = NULL; /* make trie empty if has no content */ } } - + g_free(normalized_word); } 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,19 +345,20 @@ putc ('\n', f); } - if (fwrite (word, sizeof(char), len, f) == len) - { - putc ('\n', f); - } + if (fwrite (word, sizeof(char), len, f) == (size_t)len) + putc ('\n', f); enchant_unlock_file (f); fclose (f); - } + } } } 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; @@ -395,7 +399,7 @@ fwrite (searchstart, sizeof(char), length - (searchstart - contents), f); break; } - else + else { char* foundend = needle+len; if((needle == filestart || contentsneedle-contents-1 == '\n' || contentsneedle-contents-1 == '\r') && @@ -413,7 +417,7 @@ } } g_free(key); - + GStatBuf stats; if(g_stat(pwl->filename, &stats)==0) pwl->file_changed = stats.st_mtime; @@ -421,7 +425,7 @@ enchant_unlock_file (f); fclose (f); - } + } g_free(contents); } } @@ -489,7 +493,7 @@ return hasCap; } -static _GL_ATTRIBUTE_PURE int enchant_is_title_case(const char * const word, size_t len) +static G_GNUC_PURE int enchant_is_title_case(const char * const word, size_t len) { g_return_val_if_fail (word && *word, 0); @@ -498,7 +502,7 @@ if ((type != G_UNICODE_UPPERCASE_LETTER && type != G_UNICODE_TITLECASE_LETTER) || ch != g_unichar_totitle(ch)) return 0; - + for (const char* it = g_utf8_next_char(word); it < word + len; it = g_utf8_next_char(it)) { type = g_unichar_type(g_utf8_get_char(it)); @@ -525,12 +529,15 @@ 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); - + if(exists) return 0; @@ -563,8 +570,8 @@ (*((int*)(matcher->cbdata)))++; } -static void enchant_pwl_case_and_denormalize_suggestions(EnchantPWL *pwl, - const char *const word, size_t len, +static void enchant_pwl_case_and_denormalize_suggestions(EnchantPWL *pwl, + const char *const word, size_t len, EnchantSuggList* suggs_list)
View file
_service:tar_scm:enchant-2.2.15.tar.gz/src/pwl.h -> _service:tar_scm:enchant-2.3.3.tar.gz/src/pwl.h
Changed
@@ -42,12 +42,12 @@ 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
View file
_service:tar_scm:enchant-2.2.15.tar.gz/tests/enchant_providers/Provider/provider_list_dicts.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/tests/enchant_providers/Provider/provider_list_dicts.cpp
Changed
@@ -62,19 +62,17 @@ TEST_FIXTURE(ProviderListDicts_TestFixture, ProviderListDicts_ForEachReturned_RequestDictSucceeds) { - if(_provider->list_dicts && _provider->request_dict) + if(_provider->list_dicts) { - size_t n_dicts; + size_t n_dicts; - _dicts = (*_provider->list_dicts) (_provider, &n_dicts); - for (size_t i = 0; i < n_dicts; i++) - { - EnchantDict* dict = (*_provider->request_dict) (_provider, _dictsi); - CHECK(dict != NULL); - if (dict && _provider->dispose_dict) - { + _dicts = (*_provider->list_dicts) (_provider, &n_dicts); + for (size_t i = 0; i < n_dicts; i++) + { + EnchantDict* dict = (*_provider->request_dict) (_provider, _dictsi); + CHECK(dict != NULL); + if (dict) _provider->dispose_dict(_provider, dict); - } } } }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/tests/enchant_providers/Provider/provider_request_dict.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/tests/enchant_providers/Provider/provider_request_dict.cpp
Changed
@@ -34,10 +34,8 @@ //Teardown ~ProviderRequestDictionary_TestFixture() { - if (_dict && _provider->dispose_dict) - { - _provider->dispose_dict(_provider, _dict); - } + if (_dict) + _provider->dispose_dict(_provider, _dict); } }; @@ -49,19 +47,6 @@ TEST_FIXTURE(ProviderRequestDictionary_TestFixture, ProviderRequestDictionary_ProviderDoesNotHave_ReturnsNull) { - if (_provider->request_dict) - { - _dict = (*_provider->request_dict) (_provider, "zxx"); /*zxx is no linguistic content*/ - CHECK_EQUAL((void*)NULL, _dict); - } -} - -TEST_FIXTURE(ProviderRequestDictionary_TestFixture, - ProviderRequestDictionary_ProviderDoesNotHave_ProviderDoesNotSetError) -{ - if (_provider->request_dict) - { - _dict = (*_provider->request_dict) (_provider, "zxx"); /*zxx is no linguistic content*/ - CHECK_EQUAL((void*)NULL, GetErrorMessage(_provider)); - } + _dict = (*_provider->request_dict) (_provider, "zxx"); /*zxx is no linguistic content*/ + CHECK_EQUAL((void*)NULL, _dict); }
View file
_service:tar_scm:enchant-2.2.15.tar.gz/tests/enchant_providers/providers.test.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/tests/enchant_providers/providers.test.cpp
Changed
@@ -26,6 +26,7 @@ #include <gmodule.h> #include <assert.h> #include <string.h> +#include <stdlib.h> #include "unittest_enchant_providers.h" int Test(char* path); @@ -167,6 +168,7 @@ g_provider->dispose(g_provider); g_provider = NULL; + free(broker.error); } if(module){
View file
_service:tar_scm:enchant-2.2.15.tar.gz/tests/enchant_providers/unittest_enchant_providers.h -> _service:tar_scm:enchant-2.3.3.tar.gz/tests/enchant_providers/unittest_enchant_providers.h
Changed
@@ -69,14 +69,11 @@ // Try getting dictionary for user's default language char *lang = enchant_get_user_language(); - if (_provider->request_dict) - { - dict = (*_provider->request_dict) (_provider, lang); - } + dict = (*_provider->request_dict) (_provider, lang); g_free (lang); // If not available, get the first dictionary listed as being available - if (!dict && _provider->list_dicts && _provider->request_dict) + if (!dict && _provider->list_dicts) { size_t n_dicts; @@ -90,18 +87,12 @@ EnchantDict* GetDictionary(const char* language) { - if(_provider->request_dict) - { return (*_provider->request_dict) (_provider, language); - } - return NULL; } virtual void ReleaseDictionary(EnchantDict* dict) { - if (dict && _provider->dispose_dict) - { + if (dict) _provider->dispose_dict(_provider, dict); - } } };
View file
_service:tar_scm:enchant-2.2.15.tar.gz/tests/mock_provider.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/tests/mock_provider.cpp
Changed
@@ -31,6 +31,12 @@ g_free(me); } +static EnchantDict * +mock_provider_request_dict(EnchantProvider *, const char *const) +{ + return NULL; +} + static void mock_provider_dispose_dict(EnchantProvider *me, EnchantDict *dict) { @@ -88,7 +94,7 @@ provider = g_new0(EnchantProvider, 1); provider->dispose = mock_provider_dispose; //although this is technically optional, it will result in a memory leak - provider->request_dict = NULL; + provider->request_dict = mock_provider_request_dict; // this is required or module won't load provider->dispose_dict = mock_provider_dispose_dict; provider->identify = hasIdentify ? mock_provider_identify : NULL; // this is required or module won't load provider->describe = hasDescribe ? mock_provider_describe : NULL; // this is required or module won't load
View file
_service:tar_scm:enchant-2.2.15.tar.gz/tests/pwl/enchant_pwl_tests.cpp -> _service:tar_scm:enchant-2.3.3.tar.gz/tests/pwl/enchant_pwl_tests.cpp
Changed
@@ -309,6 +309,7 @@ AddWordsToDictionary(sNoiseWords); std::vector<std::string> suggestions = GetSuggestionsFromWord("saskep"); + CHECK(suggestions.size() > 0); // FIXME: The string in the next line was originally "hasten", but the // test failed. Is this now correct? CHECK(suggestions0 != "hastens");
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2