summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Albright <eric_albright@sil.org>2007-11-29 08:16:03 +0000
committerEric Albright <eric_albright@sil.org>2007-11-29 08:16:03 +0000
commitecd6723df72585fba3d269aebc2e28fd057dd74a (patch)
tree67a852099899c4d144cadb296bdca0fc368ea981
parent828e6fb695329011d2ae41b3492fde8e479891b1 (diff)
downloadenchant-ecd6723df72585fba3d269aebc2e28fd057dd74a.tar.gz
Handle case where all suggestions are excluded
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@22360 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--src/enchant.c5
-rw-r--r--unittests/dictionary/enchant_dict_suggest_tests.cpp10
2 files changed, 15 insertions, 0 deletions
diff --git a/src/enchant.c b/src/enchant.c
index bbcdc65..266c89c 100644
--- a/src/enchant.c
+++ b/src/enchant.c
@@ -799,6 +799,11 @@ enchant_dict_suggest (EnchantDict * dict, const char *const word,
n_suggs = enchant_dict_merge_suggestions(dict,
suggs, n_suggs,
pwl_suggs, n_pwl_suggs);
+ if(n_suggs == 0)
+ {
+ g_free(suggs);
+ suggs = NULL;
+ }
}
else
{
diff --git a/unittests/dictionary/enchant_dict_suggest_tests.cpp b/unittests/dictionary/enchant_dict_suggest_tests.cpp
index a73255a..3c486c9 100644
--- a/unittests/dictionary/enchant_dict_suggest_tests.cpp
+++ b/unittests/dictionary/enchant_dict_suggest_tests.cpp
@@ -292,6 +292,16 @@ TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
CHECK_ARRAY_EQUAL(GetExpectedSuggestions("helo"), suggestions, std::min((size_t)4,cSuggestions));
}
+TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
+ EnchantDictionarySuggest_SuggestionExcluded_Null)
+{
+ suggestBehavior = returnFianceNfc;
+ RemoveWordFromDictionary(Convert(L"fianc\xe9")); // u00e9 = Latin small letter e with acute
+
+ _suggestions = enchant_dict_suggest(_dict, "fiance", -1, NULL);
+ CHECK(!_suggestions);
+}
+
TEST_FIXTURE(EnchantDictionarySuggest_TestFixture,
EnchantDictionarySuggest_HasPreviousError_ErrorCleared)
{