From 5d1752c5e3347eaf37d729261de111138fa0eb78 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 4 Apr 2016 17:53:26 +0200 Subject: [PATCH] speller: simplify the calculation of the width of the misspelled word When finding a misspelled word, the length of the match is simply the length of that word, and its span in columns is simply the number of columns that it occupies. Compute it thus directly. Signed-off-by: Benno Schulenberg --- src/text.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/text.c b/src/text.c index 01c4b2e0..5c2bf2d4 100644 --- a/src/text.c +++ b/src/text.c @@ -2354,7 +2354,7 @@ void do_full_justify(void) bool do_int_spell_fix(const char *word) { char *save_search, *exp_word; - size_t match_len, current_x_save = openfile->current_x; + size_t current_x_save = openfile->current_x; size_t pww_save = openfile->placewewant; filestruct *edittop_save = openfile->edittop; filestruct *current_save = openfile->current; @@ -2422,15 +2422,14 @@ bool do_int_spell_fix(const char *word) findnextstr_wrap_reset(); /* Find the first whole occurrence of word. */ - result = findnextstr(TRUE, openfile->fileage, 0, word, &match_len); + result = findnextstr(TRUE, openfile->fileage, 0, word, NULL); /* The word must exist; if not, something is wrong. */ if (result == 0) statusbar("Internal error: speller listed unfindable word"); else if (result == 1) { exp_word = display_string(openfile->current->data, xplustabs(), - strnlenpt(openfile->current->data, - openfile->current_x + match_len) - xplustabs(), FALSE); + strlenpt(word), FALSE); edit_refresh();