patch 9.1.0783: 'spell' option setting has problems

Problem:  'spell' option setting has problems
Solution: correctly check for comma for 'spellfile' option,
          remove unnecessary checks, refactor slightly (Milly)

closes: #15873

Signed-off-by: Milly <milly.ca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Milly
2024-10-14 20:21:48 +02:00
committed by Christian Brabandt
parent 0c59c30271
commit 322ad0c953
7 changed files with 28 additions and 23 deletions

View File

@ -2250,7 +2250,7 @@ parse_spelllang(win_T *wp)
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");
// If it was already found above then skip it.
@ -4441,11 +4441,22 @@ valid_spelllang(char_u *val)
int
valid_spellfile(char_u *val)
{
char_u *s;
char_u spf_name[MAXPATHL];
char_u *spf;
char_u *s;
int l;
for (s = val; *s != NUL; ++s)
if (!vim_is_fname_char(*s))
spf = val;
while (*spf != NUL)
{
l = copy_option_part(&spf, spf_name, MAXPATHL, ",");
if (l >= MAXPATHL - 4 || l < 4
|| STRCMP(spf_name + l - 4, ".add") != 0)
return FALSE;
for (s = spf_name; *s != NUL; ++s)
if (!vim_is_fname_char(*s))
return FALSE;
}
return TRUE;
}
@ -4454,22 +4465,10 @@ valid_spellfile(char_u *val)
* Return an error message or NULL for success.
*/
char *
did_set_spell_option(int is_spellfile)
did_set_spell_option(void)
{
char *errmsg = NULL;
win_T *wp;
int l;
if (is_spellfile)
{
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_invalid_argument;
}
if (errmsg != NULL)
return errmsg;
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer == curbuf && wp->w_p_spell)