diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:15:05 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:27:38 +0000 |
commit | c5d770d311841ea5230426cc4c868e8db27300a8 (patch) | |
tree | dd21f70127b4b8b5f109baefc8ecc5016f507c91 /src/nvim/spell.c | |
parent | 9be89f131f87608f224f0ee06d199fcd09d32176 (diff) | |
parent | 081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff) | |
download | rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2 rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r-- | src/nvim/spell.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 8ec28c7f61..a0fdd46b04 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2091,7 +2091,7 @@ char *parse_spelllang(win_T *wp) int_wordlist_spl(spf_name); } else { // One entry in 'spellfile'. - copy_option_part(&spf, spf_name, MAXPATHL - 5, ","); + copy_option_part(&spf, spf_name, MAXPATHL - 4, ","); strcat(spf_name, ".spl"); int c; @@ -3664,30 +3664,26 @@ bool valid_spelllang(const char *val) bool valid_spellfile(const char *val) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - for (const char *s = val; *s != NUL; s++) { - if (!vim_is_fname_char((uint8_t)(*s))) { + char spf_name[MAXPATHL]; + char *spf = (char *)val; + while (*spf != NUL) { + size_t l = copy_option_part(&spf, spf_name, MAXPATHL, ","); + if (l >= MAXPATHL - 4 || l < 4 || strcmp(spf_name + l - 4, ".add") != 0) { return false; } + for (char *s = spf_name; *s != NUL; s++) { + if (!vim_is_fname_char((uint8_t)(*s))) { + return false; + } + } } return true; } -const char *did_set_spell_option(bool is_spellfile) +const char *did_set_spell_option(void) { const char *errmsg = NULL; - if (is_spellfile) { - int l = (int)strlen(curwin->w_s->b_p_spf); - if (l > 0 - && (l < 4 || strcmp(curwin->w_s->b_p_spf + l - 4, ".add") != 0)) { - errmsg = e_invarg; - } - } - - if (errmsg != NULL) { - return errmsg; - } - FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp->w_buffer == curbuf && wp->w_p_spell) { errmsg = parse_spelllang(wp); |