aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spellfile.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-13 15:00:43 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-03-14 13:09:54 +0800
commit090d1fd0b86897d2f5a80a600becf1525398ef30 (patch)
tree94b10da1cf7d680654d6b597dae2c5bd0686b0be /src/nvim/spellfile.c
parent3502aa63f0f4ea8d8982aea81a819424e71029bc (diff)
downloadrneovim-090d1fd0b86897d2f5a80a600becf1525398ef30.tar.gz
rneovim-090d1fd0b86897d2f5a80a600becf1525398ef30.tar.bz2
rneovim-090d1fd0b86897d2f5a80a600becf1525398ef30.zip
vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()
Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: vim/vim#14183 https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
Diffstat (limited to 'src/nvim/spellfile.c')
-rw-r--r--src/nvim/spellfile.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 1c632d2700..45e1b37818 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -5114,13 +5114,12 @@ static void sug_write(spellinfo_T *spin, char *fname)
for (linenr_T lnum = 1; lnum <= wcount; lnum++) {
// <sugline>: <sugnr> ... NUL
char *line = ml_get_buf(spin->si_spellbuf, lnum);
- size_t len = strlen(line) + 1;
- if (fwrite(line, len, 1, fd) == 0) {
+ int len = ml_get_buf_len(spin->si_spellbuf, lnum) + 1;
+ if (fwrite(line, (size_t)len, 1, fd) == 0) {
emsg(_(e_write));
goto theend;
}
- assert((size_t)spin->si_memtot + len <= INT_MAX);
- spin->si_memtot += (int)len;
+ spin->si_memtot += len;
}
// Write another byte to check for errors.