Skip to content

Commit 322ad0c

Browse files
Millychrisbra
authored andcommitted
patch 9.1.0783: 'spell' option setting has problems
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>
1 parent 0c59c30 commit 322ad0c

7 files changed

Lines changed: 28 additions & 23 deletions

File tree

src/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2956,7 +2956,7 @@ didset_options(void)
29562956
(void)spell_check_msm();
29572957
(void)spell_check_sps();
29582958
(void)compile_cap_prog(curwin->w_s);
2959-
(void)did_set_spell_option(TRUE);
2959+
(void)did_set_spell_option();
29602960
#endif
29612961
// set cedit_key
29622962
(void)did_set_cedit(NULL);

src/optionstr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3584,7 +3584,7 @@ did_set_spellfile(optset_T *args)
35843584

35853585
// If there is a window for this buffer in which 'spell' is set load the
35863586
// wordlists.
3587-
return did_set_spell_option(TRUE);
3587+
return did_set_spell_option();
35883588
}
35893589

35903590
/*
@@ -3600,7 +3600,7 @@ did_set_spelllang(optset_T *args)
36003600

36013601
// If there is a window for this buffer in which 'spell' is set load the
36023602
// wordlists.
3603-
return did_set_spell_option(FALSE);
3603+
return did_set_spell_option();
36043604
}
36053605

36063606
/*

src/proto/spell.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ void spell_expand_check_cap(colnr_T col);
4545
int expand_spelling(linenr_T lnum, char_u *pat, char_u ***matchp);
4646
int valid_spelllang(char_u *val);
4747
int valid_spellfile(char_u *val);
48-
char *did_set_spell_option(int is_spellfile);
48+
char *did_set_spell_option(void);
4949
char *compile_cap_prog(synblock_T *synblock);
5050
/* vim: set ft=c : */

src/spell.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,7 @@ parse_spelllang(win_T *wp)
22502250
else
22512251
{
22522252
// One entry in 'spellfile'.
2253-
copy_option_part(&spf, spf_name, MAXPATHL - 5, ",");
2253+
copy_option_part(&spf, spf_name, MAXPATHL - 4, ",");
22542254
STRCAT(spf_name, ".spl");
22552255

22562256
// If it was already found above then skip it.
@@ -4441,11 +4441,22 @@ valid_spelllang(char_u *val)
44414441
int
44424442
valid_spellfile(char_u *val)
44434443
{
4444-
char_u *s;
4444+
char_u spf_name[MAXPATHL];
4445+
char_u *spf;
4446+
char_u *s;
4447+
int l;
44454448

4446-
for (s = val; *s != NUL; ++s)
4447-
if (!vim_is_fname_char(*s))
4449+
spf = val;
4450+
while (*spf != NUL)
4451+
{
4452+
l = copy_option_part(&spf, spf_name, MAXPATHL, ",");
4453+
if (l >= MAXPATHL - 4 || l < 4
4454+
|| STRCMP(spf_name + l - 4, ".add") != 0)
44484455
return FALSE;
4456+
for (s = spf_name; *s != NUL; ++s)
4457+
if (!vim_is_fname_char(*s))
4458+
return FALSE;
4459+
}
44494460
return TRUE;
44504461
}
44514462

@@ -4454,22 +4465,10 @@ valid_spellfile(char_u *val)
44544465
* Return an error message or NULL for success.
44554466
*/
44564467
char *
4457-
did_set_spell_option(int is_spellfile)
4468+
did_set_spell_option(void)
44584469
{
44594470
char *errmsg = NULL;
44604471
win_T *wp;
4461-
int l;
4462-
4463-
if (is_spellfile)
4464-
{
4465-
l = (int)STRLEN(curwin->w_s->b_p_spf);
4466-
if (l > 0 && (l < 4
4467-
|| STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
4468-
errmsg = e_invalid_argument;
4469-
}
4470-
4471-
if (errmsg != NULL)
4472-
return errmsg;
44734472

44744473
FOR_ALL_WINDOWS(wp)
44754474
if (wp->w_buffer == curbuf && wp->w_p_spell)

src/testdir/gen_opt_test.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ let test_values = {
146146
\ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
147147
\ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
148148
\ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
149-
\ 'spellfile': [['', 'file.en.add', '/tmp/dir\ with\ space/en.utf-8.add'], ['xxx', '/tmp/file']],
149+
\ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
150+
\ '/tmp/dir\ with\ space/en.utf-8.add',
151+
\ '/tmp/dir\\,with\\,comma/en.utf-8.add'],
152+
\ ['xxx', '/tmp/file', ',file.en.add', 'xxx,yyy.en.add',
153+
\ 'xxx.en.add,yyy,zzz.ja.add']],
150154
\ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
151155
\ 'spelloptions': [['', 'camel'], ['xxx']],
152156
\ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],

src/testdir/test_spellfile.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ endfunc
11541154
" 'spellfile' accepts '@' on top of 'isfname'.
11551155
def Test_spellfile_allow_at_character()
11561156
mkdir('Xtest/the foo@bar,dir', 'p')
1157-
&spellfile = './Xtest/the foo@bar,dir/Xspellfile.add'
1157+
&spellfile = './Xtest/the foo@bar\,dir/Xspellfile.add'
11581158
&spellfile = ''
11591159
delete('Xtest', 'rf')
11601160
enddef

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
783,
707709
/**/
708710
782,
709711
/**/

0 commit comments

Comments
 (0)