[gspell] checker: add string length parameter to get_suggestions()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] checker: add string length parameter to get_suggestions()
- Date: Sun, 22 Nov 2015 17:22:18 +0000 (UTC)
commit bd2f1c8d4fdaf3c74127cd40eb72d3670a461125
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Nov 22 18:20:28 2015 +0100
checker: add string length parameter to get_suggestions()
gspell/gspell-checker-dialog.c | 4 ++--
gspell/gspell-checker.c | 7 +++++--
gspell/gspell-checker.h | 3 ++-
gspell/gspell-inline-checker-gtv.c | 2 +-
4 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gspell/gspell-checker-dialog.c b/gspell/gspell-checker-dialog.c
index ab23b8f..c413109 100644
--- a/gspell/gspell-checker-dialog.c
+++ b/gspell/gspell-checker-dialog.c
@@ -193,7 +193,7 @@ set_misspelled_word (GspellCheckerDialog *dialog,
gtk_label_set_markup (priv->misspelled_word_label, label);
g_free (label);
- suggestions = gspell_checker_get_suggestions (priv->checker, priv->misspelled_word);
+ suggestions = gspell_checker_get_suggestions (priv->checker, priv->misspelled_word, -1);
set_suggestions (dialog, suggestions);
@@ -508,7 +508,7 @@ check_word_button_clicked_handler (GtkButton *button,
{
GSList *suggestions;
- suggestions = gspell_checker_get_suggestions (priv->checker, word);
+ suggestions = gspell_checker_get_suggestions (priv->checker, word, -1);
set_suggestions (dialog, suggestions);
diff --git a/gspell/gspell-checker.c b/gspell/gspell-checker.c
index 51508f3..e54b7dd 100644
--- a/gspell/gspell-checker.c
+++ b/gspell/gspell-checker.c
@@ -490,6 +490,7 @@ gspell_checker_check_word (GspellChecker *checker,
* gspell_checker_get_suggestions:
* @checker: a #GspellChecker.
* @word: a misspelled word.
+ * @word_length: the byte length of @word, or -1 if @word is nul-terminated.
*
* Gets the suggestions for @word. Free the return value with
* g_slist_free_full(suggestions, g_free).
@@ -498,7 +499,8 @@ gspell_checker_check_word (GspellChecker *checker,
*/
GSList *
gspell_checker_get_suggestions (GspellChecker *checker,
- const gchar *word)
+ const gchar *word,
+ gssize word_length)
{
GspellCheckerPrivate *priv;
gchar **suggestions;
@@ -507,11 +509,12 @@ gspell_checker_get_suggestions (GspellChecker *checker,
g_return_val_if_fail (GSPELL_IS_CHECKER (checker), NULL);
g_return_val_if_fail (word != NULL, NULL);
+ g_return_val_if_fail (word_length >= -1, NULL);
g_return_val_if_fail (_gspell_checker_check_language_set (checker), NULL);
priv = gspell_checker_get_instance_private (checker);
- suggestions = enchant_dict_suggest (priv->dict, word, -1, NULL);
+ suggestions = enchant_dict_suggest (priv->dict, word, word_length, NULL);
if (suggestions == NULL)
{
diff --git a/gspell/gspell-checker.h b/gspell/gspell-checker.h
index 1f09047..11f4c8d 100644
--- a/gspell/gspell-checker.h
+++ b/gspell/gspell-checker.h
@@ -91,7 +91,8 @@ gboolean gspell_checker_check_word (GspellChecker *checker,
GError **error);
GSList * gspell_checker_get_suggestions (GspellChecker *checker,
- const gchar *word);
+ const gchar *word,
+ gssize word_length);
void gspell_checker_add_word_to_personal (GspellChecker *checker,
const gchar *word);
diff --git a/gspell/gspell-inline-checker-gtv.c b/gspell/gspell-inline-checker-gtv.c
index 47f6d6a..1677659 100644
--- a/gspell/gspell-inline-checker-gtv.c
+++ b/gspell/gspell-inline-checker-gtv.c
@@ -569,7 +569,7 @@ get_suggestion_menu (GspellInlineCheckerGtv *spell,
top_menu = gtk_menu_new ();
- suggestions = gspell_checker_get_suggestions (spell->spell_checker, word);
+ suggestions = gspell_checker_get_suggestions (spell->spell_checker, word, -1);
if (suggestions == NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]