0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.1.0479: failure when setting 'varsofttabstop' to end in a comma

Problem:    Failure when setting 'varsofttabstop' to end in a comma. (Ralf
            Schandl)
Solution:   Reject value with trailing command.  Add test for invalid values
            (closes #3544)
This commit is contained in:
Bram Moolenaar
2018-10-15 22:51:50 +02:00
parent 65dc12143a
commit 64f410742f
3 changed files with 26 additions and 12 deletions

View File

@@ -12786,17 +12786,18 @@ tabstop_set(char_u *var, int **array)
int t;
char_u *cp;
if ((!var[0] || (var[0] == '0' && !var[1])))
if (var[0] == NUL || (var[0] == '0' && var[1] == NUL))
{
*array = NULL;
return TRUE;
}
for (cp = var; *cp; ++cp)
for (cp = var; *cp != NUL; ++cp)
{
if (cp == var || *(cp - 1) == ',')
if (cp == var || cp[-1] == ',')
{
char_u *end;
if (strtol((char *)cp, (char **)&end, 10) <= 0)
{
if (cp != end)
@@ -12809,7 +12810,7 @@ tabstop_set(char_u *var, int **array)
if (VIM_ISDIGIT(*cp))
continue;
if (*cp == ',' && cp > var && *(cp - 1) != ',')
if (cp[0] == ',' && cp > var && cp[-1] != ',' && cp[1] != NUL)
{
++valcount;
continue;
@@ -12822,12 +12823,12 @@ tabstop_set(char_u *var, int **array)
(*array)[0] = valcount;
t = 1;
for (cp = var; *cp;)
for (cp = var; *cp != NUL;)
{
(*array)[t++] = atoi((char *)cp);
while (*cp && *cp != ',')
while (*cp != NUL && *cp != ',')
++cp;
if (*cp)
if (*cp != NUL)
++cp;
}

View File

@@ -5,11 +5,11 @@ if !has("vartabs")
endif
source view_util.vim
function! s:compare_lines(expect, actual)
func s:compare_lines(expect, actual)
call assert_equal(join(a:expect, "\n"), join(a:actual, "\n"))
endfunction
endfunc
func! Test_vartabs()
func Test_vartabs()
new
%d
@@ -261,7 +261,7 @@ func! Test_vartabs_breakindent()
bwipeout!
endfunc
func! Test_vartabs_linebreak()
func Test_vartabs_linebreak()
if winwidth(0) < 40
return
endif
@@ -296,3 +296,14 @@ func! Test_vartabs_linebreak()
bw!
set nolist listchars&vim
endfunc
func Test_vartabs_failures()
call assert_fails('set vts=8,')
call assert_fails('set vsts=8,')
call assert_fails('set vts=8,,8')
call assert_fails('set vsts=8,,8')
call assert_fails('set vts=8,,8,')
call assert_fails('set vsts=8,,8,')
call assert_fails('set vts=,8')
call assert_fails('set vsts=,8')
endfunc

View File

@@ -792,6 +792,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
479,
/**/
478,
/**/