diff options
author | Eric Albright <eric_albright@sil.org> | 2008-05-02 06:04:46 +0000 |
---|---|---|
committer | Eric Albright <eric_albright@sil.org> | 2008-05-02 06:04:46 +0000 |
commit | 9baf434ae7810dd4fa624e9209085b91725b0eff (patch) | |
tree | a5baa18853d68a81212791cd32e396eca62d0817 | |
parent | 0ed48af1f728561b45969096c698e900a600028e (diff) | |
download | enchant-9baf434ae7810dd4fa624e9209085b91725b0eff.tar.gz |
Ensure that a partial setup (where dic file exists but aff file doesn't) will not cause mismatch between what is claimed to be provided and what can actually be provided later
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@23736 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r-- | src/myspell/myspell_checker.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/myspell/myspell_checker.cpp b/src/myspell/myspell_checker.cpp index 7b86ca9..0379206 100644 --- a/src/myspell/myspell_checker.cpp +++ b/src/myspell/myspell_checker.cpp @@ -308,6 +308,14 @@ s_buildHashNames (std::vector<std::string> & names, const char * dict) g_free(dict_dic); } +static bool +s_hasCorrespondingAffFile(const std::string & dicFile) +{ + std::string aff = dicFile; + aff.replace(aff.end()-3,aff.end(), "aff"); + return g_file_test(aff.c_str(), G_FILE_TEST_EXISTS) != 0; +} + static char * myspell_request_dictionary (const char * tag) { @@ -316,8 +324,11 @@ myspell_request_dictionary (const char * tag) s_buildHashNames (names, tag); for (size_t i = 0; i < names.size (); i++) { - if (g_file_test(names[i].c_str(), G_FILE_TEST_EXISTS)) - return g_strdup (names[i].c_str()); + if (g_file_test(names[i].c_str(), G_FILE_TEST_EXISTS)) { + if(s_hasCorrespondingAffFile(names[i])){ + return g_strdup (names[i].c_str()); + } + } } std::vector<std::string> dirs; @@ -333,7 +344,9 @@ myspell_request_dictionary (const char * tag) char *dict = g_build_filename (dirs[i].c_str(), dir_entry, NULL); g_dir_close (dir); - return dict; + if(s_hasCorrespondingAffFile(dict)){ + return dict; + } } } |