]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0783: 'spell' option setting has problems v9.1.0783
authorMilly <milly.ca@gmail.com>
Mon, 14 Oct 2024 18:21:48 +0000 (20:21 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 14 Oct 2024 18:21:48 +0000 (20:21 +0200)
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>
src/option.c
src/optionstr.c
src/proto/spell.pro
src/spell.c
src/testdir/gen_opt_test.vim
src/testdir/test_spellfile.vim
src/version.c

index cdd457b4d7241edd6e066a2002bf672189774e16..a108c521a05e760842f9ad8fcc2a6eceb6d426b2 100644 (file)
@@ -2956,7 +2956,7 @@ didset_options(void)
     (void)spell_check_msm();
     (void)spell_check_sps();
     (void)compile_cap_prog(curwin->w_s);
-    (void)did_set_spell_option(TRUE);
+    (void)did_set_spell_option();
 #endif
     // set cedit_key
     (void)did_set_cedit(NULL);
index bf7135ab0ba04abfe41671dac188db07d1c57ef9..b1bb39a62c5482c56d5fe538d8f6a66a5d8b8fe7 100644 (file)
@@ -3584,7 +3584,7 @@ did_set_spellfile(optset_T *args)
 
     // If there is a window for this buffer in which 'spell' is set load the
     // wordlists.
-    return did_set_spell_option(TRUE);
+    return did_set_spell_option();
 }
 
 /*
@@ -3600,7 +3600,7 @@ did_set_spelllang(optset_T *args)
 
     // If there is a window for this buffer in which 'spell' is set load the
     // wordlists.
-    return did_set_spell_option(FALSE);
+    return did_set_spell_option();
 }
 
 /*
index 680bf34f4f5fc07d7756f749d4f406008b198a47..a68de8f1d8895f32fa212acbe6594a51997409ae 100644 (file)
@@ -45,6 +45,6 @@ void spell_expand_check_cap(colnr_T col);
 int expand_spelling(linenr_T lnum, char_u *pat, char_u ***matchp);
 int valid_spelllang(char_u *val);
 int valid_spellfile(char_u *val);
-char *did_set_spell_option(int is_spellfile);
+char *did_set_spell_option(void);
 char *compile_cap_prog(synblock_T *synblock);
 /* vim: set ft=c : */
index 909d426e2018a9e108c43154682492d853cd325c..5a7720f7f3510b8a8f505cad8bde55e29eb940bc 100644 (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)
index 0d277606ca46515420e63454a832289ea850d688..4ca3c09386e717452ed3796b386ff40a01bfa1e8 100644 (file)
@@ -146,7 +146,11 @@ let test_values = {
       \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
       \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
       \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
-      \ 'spellfile': [['', 'file.en.add', '/tmp/dir\ with\ space/en.utf-8.add'], ['xxx', '/tmp/file']],
+      \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
+      \                '/tmp/dir\ with\ space/en.utf-8.add',
+      \                '/tmp/dir\\,with\\,comma/en.utf-8.add'],
+      \                ['xxx', '/tmp/file', ',file.en.add', 'xxx,yyy.en.add',
+      \                'xxx.en.add,yyy,zzz.ja.add']],
       \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
       \ 'spelloptions': [['', 'camel'], ['xxx']],
       \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
index 8abb680622c1de7cd77b3dc9efa4c6c7821a1b02..dd12698b99b86de591aa5026f453782d07982fd9 100644 (file)
@@ -1154,7 +1154,7 @@ endfunc
 " 'spellfile' accepts '@' on top of 'isfname'.
 def Test_spellfile_allow_at_character()
   mkdir('Xtest/the foo@bar,dir', 'p')
-  &spellfile = './Xtest/the foo@bar,dir/Xspellfile.add'
+  &spellfile = './Xtest/the foo@bar\,dir/Xspellfile.add'
   &spellfile = ''
   delete('Xtest', 'rf')
 enddef
index c6362115687cdb9f0014f77feb3a84acd16dc13b..2043563288a184e7d536a024d33e7f6c0333b17e 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    783,
 /**/
     782,
 /**/