aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spellsuggest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/spellsuggest.c')
-rw-r--r--src/nvim/spellsuggest.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 5c0e295f88..a7de20d14e 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -480,12 +480,11 @@ void spell_suggest(int count)
badlen++;
end_visual_mode();
// make sure we don't include the NUL at the end of the line
- char *line = get_cursor_line_ptr();
- if (badlen > (int)strlen(line) - (int)curwin->w_cursor.col) {
- badlen = (int)strlen(line) - (int)curwin->w_cursor.col;
+ if (badlen > get_cursor_line_len() - curwin->w_cursor.col) {
+ badlen = get_cursor_line_len() - curwin->w_cursor.col;
}
// Find the start of the badly spelled word.
- } else if (spell_move_to(curwin, FORWARD, true, true, NULL) == 0
+ } else if (spell_move_to(curwin, FORWARD, SMT_ALL, true, NULL) == 0
|| curwin->w_cursor.col > prev_cursor.col) {
// No bad word or it starts after the cursor: use the word under the
// cursor.
@@ -514,7 +513,7 @@ void spell_suggest(int count)
int need_cap = check_need_cap(curwin, curwin->w_cursor.lnum, curwin->w_cursor.col);
// Make a copy of current line since autocommands may free the line.
- char *line = xstrdup(get_cursor_line_ptr());
+ char *line = xstrnsave(get_cursor_line_ptr(), (size_t)get_cursor_line_len());
spell_suggest_timeout = 5000;
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
@@ -562,7 +561,8 @@ void spell_suggest(int count)
xstrlcpy(wcopy, stp->st_word, MAXWLEN + 1);
int el = sug.su_badlen - stp->st_orglen;
if (el > 0 && stp->st_wordlen + el <= MAXWLEN) {
- xstrlcpy(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen, (size_t)el + 1);
+ assert(sug.su_badptr != NULL);
+ xmemcpyz(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen, (size_t)el);
}
vim_snprintf(IObuff, IOSIZE, "%2d", i + 1);
if (cmdmsg_rl) {
@@ -734,7 +734,7 @@ static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxc
if (su->su_badlen >= MAXWLEN) {
su->su_badlen = MAXWLEN - 1; // just in case
}
- xstrlcpy(su->su_badword, su->su_badptr, (size_t)su->su_badlen + 1);
+ xmemcpyz(su->su_badword, su->su_badptr, (size_t)su->su_badlen);
spell_casefold(curwin, su->su_badptr, su->su_badlen, su->su_fbadword,
MAXWLEN);
@@ -1368,9 +1368,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
compflags[sp->ts_complen] = (uint8_t)((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
- xstrlcpy(preword + sp->ts_prewordlen,
+ xmemcpyz(preword + sp->ts_prewordlen,
tword + sp->ts_splitoff,
- (size_t)(sp->ts_twordlen - sp->ts_splitoff) + 1);
+ (size_t)(sp->ts_twordlen - sp->ts_splitoff));
// Verify CHECKCOMPOUNDPATTERN rules.
if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
@@ -2647,8 +2647,8 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *ba
// Add part of the bad word to the good word, so that we soundfold
// what replaces the bad word.
STRCPY(goodword, stp->st_word);
- xstrlcpy(goodword + stp->st_wordlen,
- su->su_badptr + su->su_badlen - lendiff, (size_t)lendiff + 1);
+ xmemcpyz(goodword + stp->st_wordlen,
+ su->su_badptr + su->su_badlen - lendiff, (size_t)lendiff);
pgood = goodword;
} else {
pgood = stp->st_word;