[gspell] checker: add string length parameter to set_correction()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] checker: add string length parameter to set_correction()
- Date: Sun, 22 Nov 2015 17:46:08 +0000 (UTC)
commit e224417b9b6b3284b86a09f91cca9404046d4016
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Nov 22 18:44:35 2015 +0100
checker: add string length parameter to set_correction()
https://bugzilla.gnome.org/show_bug.cgi?id=758455
gspell/gspell-checker-dialog.c | 8 ++++----
gspell/gspell-checker.c | 13 ++++++++++---
gspell/gspell-checker.h | 4 +++-
gspell/gspell-inline-checker-gtv.c | 4 +++-
4 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/gspell/gspell-checker-dialog.c b/gspell/gspell-checker-dialog.c
index 1e4717c..128684c 100644
--- a/gspell/gspell-checker-dialog.c
+++ b/gspell/gspell-checker-dialog.c
@@ -569,8 +569,8 @@ change_button_clicked_handler (GtkButton *button,
g_return_if_fail (change_to[0] != '\0');
gspell_checker_set_correction (priv->checker,
- priv->misspelled_word,
- change_to);
+ priv->misspelled_word, -1,
+ change_to, -1);
gspell_navigator_change (priv->navigator, priv->misspelled_word, change_to);
g_free (change_to);
@@ -608,8 +608,8 @@ change_all_button_clicked_handler (GtkButton *button,
g_return_if_fail (change_to[0] != '\0');
gspell_checker_set_correction (priv->checker,
- priv->misspelled_word,
- change_to);
+ priv->misspelled_word, -1,
+ change_to, -1);
gspell_navigator_change_all (priv->navigator, priv->misspelled_word, change_to);
g_free (change_to);
diff --git a/gspell/gspell-checker.c b/gspell/gspell-checker.c
index f177d5b..0e40d4f 100644
--- a/gspell/gspell-checker.c
+++ b/gspell/gspell-checker.c
@@ -649,27 +649,34 @@ gspell_checker_clear_session (GspellChecker *checker)
* gspell_checker_set_correction:
* @checker: a #GspellChecker.
* @word: a word.
+ * @word_length: the byte length of @word, or -1 if @word is nul-terminated.
* @replacement: the replacement word.
+ * @replacement_length: the byte length of @replacement, or -1 if @replacement
+ * is nul-terminated.
*
* Informs the spell checker that @word is replaced/corrected by @replacement.
*/
void
gspell_checker_set_correction (GspellChecker *checker,
const gchar *word,
- const gchar *replacement)
+ gssize word_length,
+ const gchar *replacement,
+ gssize replacement_length)
{
GspellCheckerPrivate *priv;
g_return_if_fail (GSPELL_IS_CHECKER (checker));
g_return_if_fail (word != NULL);
+ g_return_if_fail (word_length >= -1);
g_return_if_fail (replacement != NULL);
+ g_return_if_fail (replacement_length >= -1);
g_return_if_fail (_gspell_checker_check_language_set (checker));
priv = gspell_checker_get_instance_private (checker);
enchant_dict_store_replacement (priv->dict,
- word, -1,
- replacement, -1);
+ word, word_length,
+ replacement, replacement_length);
}
/* ex:set ts=8 noet: */
diff --git a/gspell/gspell-checker.h b/gspell/gspell-checker.h
index 077e708..94a1886 100644
--- a/gspell/gspell-checker.h
+++ b/gspell/gspell-checker.h
@@ -106,7 +106,9 @@ void gspell_checker_clear_session (GspellChecker *checker);
void gspell_checker_set_correction (GspellChecker *checker,
const gchar *word,
- const gchar *replacement);
+ gssize word_length,
+ const gchar *replacement,
+ gssize replacement_length);
/* Non-exported function */
G_GNUC_INTERNAL
diff --git a/gspell/gspell-inline-checker-gtv.c b/gspell/gspell-inline-checker-gtv.c
index 4651422..09ccfdf 100644
--- a/gspell/gspell-inline-checker-gtv.c
+++ b/gspell/gspell-inline-checker-gtv.c
@@ -554,7 +554,9 @@ replace_word_cb (GtkWidget *menu_item,
gtk_text_buffer_end_user_action (spell->buffer);
- gspell_checker_set_correction (spell->spell_checker, old_word, new_word);
+ gspell_checker_set_correction (spell->spell_checker,
+ old_word, -1,
+ new_word, -1);
g_free (old_word);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]