]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0138: not enough characters accepted for 'spellfile' v9.0.0138
authorBram Moolenaar <Bram@vim.org>
Thu, 4 Aug 2022 12:01:48 +0000 (13:01 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 4 Aug 2022 12:01:48 +0000 (13:01 +0100)
Problem:    Not enough characters accepted for 'spellfile'.
Solution:   Add vim_is_fname_char() and use it for 'spellfile'.

src/charset.c
src/proto/charset.pro
src/spell.c
src/testdir/test_spellfile.vim
src/version.c

index c2137049b7d3286c0c9a032829fce1e19d96ff15..37c333622d307db59908e859ddab9def7a7ddd6c 100644 (file)
@@ -225,7 +225,8 @@ buf_init_chartab(
                            }
                            else
                            {
-                               g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + 1;
+                               g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK)
+                                                                          + 1;
                                g_chartab[c] |= CT_PRINT_CHAR;
                            }
                        }
@@ -846,8 +847,10 @@ vim_iswordp_buf(char_u *p, buf_T *buf)
 }
 
 /*
- * return TRUE if 'c' is a valid file-name character
+ * Return TRUE if 'c' is a valid file-name character as specified with the
+ * 'isfname' option.
  * Assume characters above 0x100 are valid (multi-byte).
+ * To be used for commands like "gf".
  */
     int
 vim_isfilec(int c)
@@ -855,6 +858,16 @@ vim_isfilec(int c)
     return (c >= 0x100 || (c > 0 && (g_chartab[c] & CT_FNAME_CHAR)));
 }
 
+/*
+ * Return TRUE if 'c' is a valid file-name character, including characters left
+ * out of 'isfname' to make "gf" work, such as comma, space, '@', etc.
+ */
+    int
+vim_is_fname_char(int c)
+{
+    return vim_isfilec(c) || c == ',' || c == ' ' || c == '@';
+}
+
 /*
  * return TRUE if 'c' is a valid file-name character or a wildcard character
  * Assume characters above 0x100 are valid (multi-byte).
index 97aa71e5c01d9e64d9a58404838f787050b0eb33..ebb548a8c49ce5dd52f7766de09e32536cd60f3a 100644 (file)
@@ -25,6 +25,7 @@ int vim_iswordc_buf(int c, buf_T *buf);
 int vim_iswordp(char_u *p);
 int vim_iswordp_buf(char_u *p, buf_T *buf);
 int vim_isfilec(int c);
+int vim_is_fname_char(int c);
 int vim_isfilec_or_wc(int c);
 int vim_isprintc(int c);
 int vim_isprintc_strict(int c);
index 24abce4625dd392f971e6581cb326dc4267e9786..8ca9313a3d028bc70084f54cbbae7f903fb553c3 100644 (file)
@@ -4363,7 +4363,7 @@ valid_spellfile(char_u *val)
     char_u *s;
 
     for (s = val; *s != NUL; ++s)
-       if (!vim_isfilec(*s) && *s != ',' && *s != ' ')
+       if (!vim_is_fname_char(*s))
            return FALSE;
     return TRUE;
 }
index 38d1ec08397435c9e0d2bfa4a45014afcf5c97a6..43dfad4628b67560a3dc5d85f6dca02e5b44cb2a 100644 (file)
@@ -1160,4 +1160,12 @@ func Test_mkspellmem_opt()
   call assert_fails('set mkspellmem=1000,50,0', 'E474:')
 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 = ''
+  delete('Xtest', 'rf')
+enddef
+
 " vim: shiftwidth=2 sts=2 expandtab
index e3e72477695b67afb9630aecb8007019c0726957..a62fb9241198f58b5b746a206425ea5969e1fcd2 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    138,
 /**/
     137,
 /**/