diff options
author | Dom Lachowicz <domlachowicz@gmail.com> | 2004-03-29 14:16:27 +0000 |
---|---|---|
committer | Dom Lachowicz <domlachowicz@gmail.com> | 2004-03-29 14:16:27 +0000 |
commit | 7e4f0d43711c1f53bd6fb86c84e576afa66fb752 (patch) | |
tree | c3b810f6633bd0c586f9edb4f8752faf89d7e873 | |
parent | b4a6076069ac0ea3390b74bc234ae0fefcf72e53 (diff) | |
download | enchant-7e4f0d43711c1f53bd6fb86c84e576afa66fb752.tar.gz |
deprecate a fn, bugfixes from Graham Orr
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@20922 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r-- | src/aspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/aspell/aspell_provider.c | 21 | ||||
-rw-r--r-- | src/enchant-provider.h | 2 | ||||
-rw-r--r-- | src/enchant.c | 100 | ||||
-rw-r--r-- | src/hspell/hspell_provider.c | 4 | ||||
-rw-r--r-- | src/ispell/ispell_checker.cpp | 4 | ||||
-rw-r--r-- | src/myspell/myspell_checker.cpp | 4 | ||||
-rw-r--r-- | src/uspell/uspell_provider.cpp | 4 |
8 files changed, 107 insertions, 34 deletions
diff --git a/src/aspell/Makefile.am b/src/aspell/Makefile.am index 36c61a2..3b43ebf 100644 --- a/src/aspell/Makefile.am +++ b/src/aspell/Makefile.am @@ -4,7 +4,7 @@ else target_lib = endif -INCLUDES=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) -I@ASPELL_INC@ -D_ENCHANT_BUILD=1 -DASPELL_DICT_DIR=@ASPELL_DICT_DIR@ +INCLUDES=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) -I@ASPELL_INC@ -D_ENCHANT_BUILD=1 @ASPELL_CFLAGS@ aspell_LTLIBRARIES = $(target_lib) aspelldir= $(libdir)/enchant diff --git a/src/aspell/aspell_provider.c b/src/aspell/aspell_provider.c index 2717687..171d13d 100644 --- a/src/aspell/aspell_provider.c +++ b/src/aspell/aspell_provider.c @@ -1,6 +1,6 @@ /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* enchant - * Copyright (C) 2003 Dom Lachowicz + * Copyright (C) 2003,2004 Dom Lachowicz * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -136,7 +136,7 @@ aspell_dict_store_replacement (struct str_enchant_dict * me, } static void -aspell_dict_free_suggestions (EnchantDict * me, char **str_list) +aspell_dict_free_string_list (EnchantDict * me, char **str_list) { g_strfreev (str_list); } @@ -175,7 +175,7 @@ aspell_provider_request_dict (EnchantProvider * me, const char *const tag) 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; - dict->free_suggestions = aspell_dict_free_suggestions; + dict->free_string_list = aspell_dict_free_string_list; return dict; } @@ -232,6 +232,21 @@ aspell_provider_dictionary_exists (struct str_enchant_provider * me, return exists; } +#if 0 + AspellDictInfoEnumeration * dels; + AspellDictInfoList * dlist; + const AspellDictInfo * entry; + + dlist = get_aspell_dict_info_list(m_spellConfig); + dels = aspell_dict_info_list_elements(dlist); + + while ( (entry = aspell_dict_info_enumeration_next(dels)) != 0) { + dict_choice->Append(entry->name); + } + + delete_aspell_dict_info_enumeration(dels); +#endif + static void aspell_provider_dispose (EnchantProvider * me) { diff --git a/src/enchant-provider.h b/src/enchant-provider.h index 847537b..42843bc 100644 --- a/src/enchant-provider.h +++ b/src/enchant-provider.h @@ -84,7 +84,7 @@ struct str_enchant_dict const char *const mis, size_t mis_len, const char *const cor, size_t cor_len); - void (*free_suggestions) (struct str_enchant_dict * me, + void (*free_string_list) (struct str_enchant_dict * me, char **str_list); void * _reserved[5]; diff --git a/src/enchant.c b/src/enchant.c index 88d08d9..ccd2e7f 100644 --- a/src/enchant.c +++ b/src/enchant.c @@ -1,6 +1,6 @@ /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* enchant - * Copyright (C) 2003 Dom Lachowicz + * Copyright (C) 2003, 2004 Dom Lachowicz * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -247,8 +247,14 @@ enchant_session_new_with_pwl (EnchantProvider * provider, const char * const pwl enchant_lock_file (f); while (NULL != (fgets (line, sizeof (line), f))) - g_hash_table_insert (session->personal, g_strdup (line), GINT_TO_POINTER(TRUE)); - + { + size_t l = strlen(line)-1; + if (line[l]=='\n') + line[l] = '\0'; + + g_hash_table_insert (session->personal, g_strdup (line), GINT_TO_POINTER(TRUE)); + } + enchant_unlock_file (f); fclose (f); } @@ -350,6 +356,21 @@ enchant_session_clear_error (EnchantSession * session) /********************************************************************************/ /********************************************************************************/ +static void +enchant_dict_free_string_list_impl (EnchantDict * dict, char **string_list) +{ + EnchantSession * session; + + g_return_if_fail (dict); + g_return_if_fail (string_list); + + session = (EnchantSession*)dict->enchant_private_data; + enchant_session_clear_error (session); + + if (dict->free_string_list) + (*dict->free_string_list) (dict, string_list); +} + /** * enchant_dict_set_error * @dict: A non-null dictionary @@ -423,8 +444,10 @@ enchant_dict_check (EnchantDict * dict, const char *const word, size_t len) if (dict->check) return (*dict->check) (dict, word, len); - - return -1; + else + return -1; + + return 1; } /** @@ -432,7 +455,7 @@ enchant_dict_check (EnchantDict * dict, const char *const word, size_t len) * @dict: A non-null #EnchantDict * @word: The non-null word you wish to find suggestions for, in UTF-8 encoding * @len: The non-zero byte length of @word - * @out_n_suggs: The non-null location to store the # of suggestions returned + * @out_n_suggs: The location to store the # of suggestions returned, or %null * * Will return an %null value if any of those pre-conditions * are not met. @@ -443,16 +466,45 @@ ENCHANT_MODULE_EXPORT (char **) enchant_dict_suggest (EnchantDict * dict, const char *const word, size_t len, size_t * out_n_suggs) { + size_t n_suggs; + char ** suggs; + g_return_val_if_fail (dict, NULL); g_return_val_if_fail (word, NULL); g_return_val_if_fail (len, NULL); - g_return_val_if_fail (out_n_suggs, NULL); - if (dict->suggest) - return (*dict->suggest) (dict, word, len, out_n_suggs); + if (dict->suggest) + { + char ** tmp_suggs; + + tmp_suggs = (*dict->suggest) (dict, word, len, &n_suggs); + + /* clone the suggestion array */ + if (tmp_suggs) + { + size_t i; + + suggs = g_new0 (char *, n_suggs + 1); + for (i = 0; i < n_suggs; i++) + suggs[i] = g_strdup (tmp_suggs[i]); + + enchant_dict_free_string_list_impl (dict, tmp_suggs); + } + else + { + suggs = NULL; + } + } + else + { + suggs = NULL; + n_suggs = 0; + } - *out_n_suggs = 0; - return NULL; + if (out_n_suggs) + *out_n_suggs = n_suggs; + + return suggs; } /** @@ -558,26 +610,32 @@ enchant_dict_store_replacement (EnchantDict * dict, } /** + * enchant_dict_free_string_list + * @dict: A non-null #EnchantDict + * @string_list: + * + * Releases the string list + */ +ENCHANT_MODULE_EXPORT (void) +enchant_dict_free_string_list (EnchantDict * dict, char **string_list) +{ + g_return_if_fail (string_list); + g_strfreev (string_list); +} + +/** * enchant_dict_free_suggestions * @dict: A non-null #EnchantDict * @suggestions: The non-null suggestion list returned by * 'enchant_dict_suggest' * * Releases the suggestions + * This function is DEPRECATED. Please use enchant_dict_free_string_list() instead. */ ENCHANT_MODULE_EXPORT (void) enchant_dict_free_suggestions (EnchantDict * dict, char **suggestions) { - EnchantSession * session; - - g_return_if_fail (dict); - g_return_if_fail (suggestions); - - session = (EnchantSession*)dict->enchant_private_data; - enchant_session_clear_error (session); - - if (dict->free_suggestions) - (*dict->free_suggestions) (dict, suggestions); + enchant_dict_free_string_list (dict, suggestions); } /** diff --git a/src/hspell/hspell_provider.c b/src/hspell/hspell_provider.c index 7a04424..a4f9dc9 100644 --- a/src/hspell/hspell_provider.c +++ b/src/hspell/hspell_provider.c @@ -182,7 +182,7 @@ hspell_dict_suggest (EnchantDict * me, const char *const word, } static void -hspell_dict_free_suggestions (EnchantDict * me, char **str_list) +hspell_dict_free_string_list (EnchantDict * me, char **str_list) { g_strfreev (str_list); } @@ -230,7 +230,7 @@ hspell_provider_request_dict (EnchantProvider * me, const char *const tag) dict = g_new0 (EnchantDict, 1); dict->check = hspell_dict_check; dict->suggest = hspell_dict_suggest; - dict->free_suggestions = hspell_dict_free_suggestions; + dict->free_string_list = hspell_dict_free_string_list; return dict; } diff --git a/src/ispell/ispell_checker.cpp b/src/ispell/ispell_checker.cpp index c989f0a..44c49ac 100644 --- a/src/ispell/ispell_checker.cpp +++ b/src/ispell/ispell_checker.cpp @@ -574,7 +574,7 @@ ispell_dict_check (EnchantDict * me, const char *const word, size_t len) } static void -ispell_dict_free_suggestions (EnchantDict * me, char **str_list) +ispell_dict_free_string_list (EnchantDict * me, char **str_list) { g_strfreev (str_list); } @@ -601,7 +601,7 @@ ispell_provider_request_dict (EnchantProvider * me, const char *const tag) dict->user_data = (void *) checker; dict->check = ispell_dict_check; dict->suggest = ispell_dict_suggest; - dict->free_suggestions = ispell_dict_free_suggestions; + dict->free_string_list = ispell_dict_free_string_list; // don't implement session or personal return dict; diff --git a/src/myspell/myspell_checker.cpp b/src/myspell/myspell_checker.cpp index 9c3fa04..5271c54 100644 --- a/src/myspell/myspell_checker.cpp +++ b/src/myspell/myspell_checker.cpp @@ -286,7 +286,7 @@ myspell_dict_check (EnchantDict * me, const char *const word, size_t len) } static void -myspell_dict_free_suggestions (EnchantDict * me, char **str_list) +myspell_dict_free_string_list (EnchantDict * me, char **str_list) { g_strfreev (str_list); } @@ -311,7 +311,7 @@ myspell_provider_request_dict(EnchantProvider * me, const char *const tag) dict->user_data = (void *) checker; dict->check = myspell_dict_check; dict->suggest = myspell_dict_suggest; - dict->free_suggestions = myspell_dict_free_suggestions; + dict->free_string_list = myspell_dict_free_string_list; // don't implement personal, session return dict; diff --git a/src/uspell/uspell_provider.cpp b/src/uspell/uspell_provider.cpp index 5c8aa9f..53caccd 100644 --- a/src/uspell/uspell_provider.cpp +++ b/src/uspell/uspell_provider.cpp @@ -184,7 +184,7 @@ uspell_dict_add_to_session (EnchantDict * me, const char *const word, } // uspell_dict_add_to_session static void -uspell_dict_free_suggestions (EnchantDict * me, char **str_list) +uspell_dict_free_string_list (EnchantDict * me, char **str_list) { g_strfreev (str_list); } @@ -371,7 +371,7 @@ uspell_provider_request_dict (EnchantProvider * me, const char *const tag) dict->check = uspell_dict_check; dict->suggest = uspell_dict_suggest; dict->add_to_session = uspell_dict_add_to_session; - dict->free_suggestions = uspell_dict_free_suggestions; + dict->free_string_list = uspell_dict_free_string_list; // don't use personal, session - let higher level implement that return dict; |