0
0
mirror of https://github.com/vim/vim.git synced 2025-10-07 05:54:16 -04:00

patch 8.1.1144: too strict checking of the 'spellfile' option

Problem:    Too strict checking of the 'spellfile' option.
Solution:   Allow for a path.
This commit is contained in:
Bram Moolenaar
2019-04-10 22:33:41 +02:00
parent 8f130eda47
commit 862f1e17ea
3 changed files with 26 additions and 2 deletions

View File

@@ -6039,6 +6039,20 @@ valid_spellang(char_u *val)
return valid_name(val, ".-_,"); return valid_name(val, ".-_,");
} }
/*
* Return TRUE if "val" is a valid 'spellfile' value.
*/
static int
valid_spellfile(char_u *val)
{
char_u *s;
for (s = val; *s != NUL; ++s)
if (!vim_isfilec(*s) && *s != ',')
return FALSE;
return TRUE;
}
/* /*
* Handle string options that need some action to perform when changed. * Handle string options that need some action to perform when changed.
* Returns NULL for success, or an error message for an error. * Returns NULL for success, or an error message for an error.
@@ -7101,10 +7115,13 @@ did_set_string_option(
else if (varp == &(curwin->w_s->b_p_spl) else if (varp == &(curwin->w_s->b_p_spl)
|| varp == &(curwin->w_s->b_p_spf)) || varp == &(curwin->w_s->b_p_spf))
{ {
if (!valid_spellang(*varp)) int is_spellfile = varp == &(curwin->w_s->b_p_spf);
if ((is_spellfile && !valid_spellfile(*varp))
|| (!is_spellfile && !valid_spellang(*varp)))
errmsg = e_invarg; errmsg = e_invarg;
else else
errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf)); errmsg = did_set_spell_option(is_spellfile);
} }
/* When 'spellcapcheck' is set compile the regexp program. */ /* When 'spellcapcheck' is set compile the regexp program. */
else if (varp == &(curwin->w_s->b_p_spc)) else if (varp == &(curwin->w_s->b_p_spc))

View File

@@ -376,6 +376,11 @@ func Test_zz_sal_and_addition()
call assert_equal("elekwint", SecondSpellWord()) call assert_equal("elekwint", SecondSpellWord())
endfunc endfunc
func Test_spellfile_value()
set spellfile=Xdir/Xtest.latin1.add
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
endfunc
func Test_region_error() func Test_region_error()
messages clear messages clear
call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add") call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")

View File

@@ -771,6 +771,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1144,
/**/ /**/
1143, 1143,
/**/ /**/