diff options
author | Reuben Thomas <rrt@sc3d.org> | 2021-11-09 13:03:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 13:03:08 +0000 |
commit | e0d44f3d0e2ec9b40c7662fda7a6e10465028e4f (patch) | |
tree | 7236a0654ad13c95f756ec8db5a7fb9072b99062 /providers/enchant_hunspell.cpp | |
parent | 9bd442f2e48cd4e605bbdf2f8a2e8c3ec02418ac (diff) | |
parent | 34eed0fbd502cc3980e7931dbdb4e9379b34252d (diff) | |
download | enchant-e0d44f3d0e2ec9b40c7662fda7a6e10465028e4f.tar.gz |
Merge pull request #291 from rrthomas/master
Minor fixes and cleanup
Diffstat (limited to 'providers/enchant_hunspell.cpp')
-rw-r--r-- | providers/enchant_hunspell.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/providers/enchant_hunspell.cpp b/providers/enchant_hunspell.cpp index 535aa57..f0156a2 100644 --- a/providers/enchant_hunspell.cpp +++ b/providers/enchant_hunspell.cpp @@ -37,7 +37,7 @@ #include <stdio.h> #include <stdlib.h> -#include <string.h> +#include <string.h> #include <string> #include <vector> @@ -242,16 +242,16 @@ static bool is_plausible_dict_for_tag(const char *dir_entry, const char *tag) size_t tag_len = strlen(tag); if (dir_entry_len - dic_suffix_len < tag_len) - return false; + return false; if (strcmp(dir_entry+dir_entry_len-dic_suffix_len, dic_suffix) != 0) - return false; + return false; if (strncmp (dir_entry, tag, tag_len) != 0) - return false; + return false; //e.g. requested dict for "fi", //reject "fil_PH.dic" //allow "fi-FOO.dic", "fi_FOO.dic", "fi.dic", etc. if (!ispunct(dir_entry[tag_len])) - return false; + return false; return true; } @@ -268,7 +268,7 @@ hunspell_request_dictionary (const char * tag) return strdup (names[i].c_str()); } } - + std::vector<std::string> dirs; s_buildDictionaryDirs (dirs); @@ -278,7 +278,7 @@ hunspell_request_dictionary (const char * tag) const char *dir_entry; while ((dir_entry = g_dir_read_name (dir)) != NULL) { if (is_plausible_dict_for_tag(dir_entry, tag)) { - char *dict = g_build_filename (dirs[i].c_str(), + char *dict = g_build_filename (dirs[i].c_str(), dir_entry, nullptr); if(s_fileExists(s_correspondingAffFile(dict))) { g_dir_close (dir); @@ -348,10 +348,10 @@ static int hunspell_dict_check (EnchantDict * me, const char *const word, size_t len) { HunspellChecker * checker = static_cast<HunspellChecker *>(me->user_data); - + if (checker->checkWord(word, len)) return 0; - + return 1; } @@ -410,8 +410,8 @@ hunspell_provider_enum_dicts (const char * const directory, extern "C" { -static char ** -hunspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, +static char ** +hunspell_provider_list_dicts (EnchantProvider * me _GL_UNUSED_PARAMETER, size_t * out_n_dicts) { std::vector<std::string> dict_dirs, dicts; @@ -439,15 +439,15 @@ static EnchantDict * hunspell_provider_request_dict(EnchantProvider * me _GL_UNUSED_PARAMETER, const char *const tag) { HunspellChecker * checker = new HunspellChecker(); - + if (!checker) return NULL; - + if (!checker->requestDictionary(tag)) { delete checker; return NULL; } - + EnchantDict *dict = g_new0(EnchantDict, 1); dict->user_data = (void *) checker; dict->check = hunspell_dict_check; @@ -455,7 +455,7 @@ hunspell_provider_request_dict(EnchantProvider * me _GL_UNUSED_PARAMETER, const // don't implement personal, session dict->get_extra_word_characters = hunspell_dict_get_extra_word_characters; dict->is_word_character = hunspell_dict_is_word_character; - + return dict; } @@ -464,7 +464,7 @@ hunspell_provider_dispose_dict (EnchantProvider * me _GL_UNUSED_PARAMETER, Encha { HunspellChecker *checker = (HunspellChecker *) dict->user_data; delete checker; - + g_free (dict); } |