]> granicus.if.org Git - vim/commitdiff
patch 8.1.1144: too strict checking of the 'spellfile' option v8.1.1144
authorBram Moolenaar <Bram@vim.org>
Wed, 10 Apr 2019 20:33:41 +0000 (22:33 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 10 Apr 2019 20:33:41 +0000 (22:33 +0200)
Problem:    Too strict checking of the 'spellfile' option.
Solution:   Allow for a path.

src/option.c
src/testdir/test_spell.vim
src/version.c

index e4b1d5f43d260a9ad5abe2fee5ab3624314cbd44..b0fad01ede850fbc7ffa83c33f03a838a03cc893 100644 (file)
@@ -6039,6 +6039,20 @@ valid_spellang(char_u *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.
  * 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))
index 6bf43ac3fbc417b3e545c9ea6ba9b7952922881a..b3143c95fd079427e9ff226a98b8b66791ce0ee2 100644 (file)
@@ -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")
index 3e0e95f41d0f4c3123154d1bbb86fa4010d14bf8..1ffc751275d305c0da88f571fe2f4896934a9a2f 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1144,
 /**/
     1143,
 /**/