changeset 16279:36d97f2a4c2b v8.1.1144

patch 8.1.1144: too strict checking of the 'spellfile' option commit https://github.com/vim/vim/commit/862f1e17eaf2b9c6617dfba31d8487cde462658d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 10 22:33:41 2019 +0200 patch 8.1.1144: too strict checking of the 'spellfile' option Problem: Too strict checking of the 'spellfile' option. Solution: Allow for a path.
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Apr 2019 22:45:05 +0200
parents 957309499096
children ba3b1a2c0caf
files src/option.c src/testdir/test_spell.vim src/version.c
diffstat 3 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -6040,6 +6040,20 @@ valid_spellang(char_u *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.
  * 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)
 	    || 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;
 	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. */
     else if (varp == &(curwin->w_s->b_p_spc))
--- a/src/testdir/test_spell.vim
+++ b/src/testdir/test_spell.vim
@@ -376,6 +376,11 @@ func Test_zz_sal_and_addition()
   call assert_equal("elekwint", SecondSpellWord())
 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()
   messages clear
   call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add")
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1144,
+/**/
     1143,
 /**/
     1142,