Skip to content

Commit

Permalink
patch 9.0.0057: has('patch-xxx') returns true
Browse files Browse the repository at this point in the history
Problem:    has('patch-xxx') returns true.
Solution:   Check for digit. (closes #10751)
  • Loading branch information
brammool committed Jul 18, 2022
1 parent bd683e3 commit 5154a88
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/evalfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6473,7 +6473,7 @@ f_has(typval_T *argvars, typval_T *rettv)
|| (minor == VIM_VERSION_MINOR
&& has_patch(atoi((char *)name + 10))))));
}
else
else if (isdigit(name[5]))

This comment has been minimized.

Copy link
@mattn

mattn Jul 19, 2022

Member

we should not use atoi since invalid number always return 0.

:echo has("patch-1000000000000000000.1.2")

This return 1. strtol should be used for this.

n = has_patch(atoi((char *)name + 5));
}
else if (STRICMP(name, "vim_starting") == 0)
Expand Down
1 change: 1 addition & 0 deletions src/testdir/test_expr.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func Test_version()
call assert_false(has('patch-7.4.'))
call assert_false(has('patch-9.1.0'))
call assert_false(has('patch-9.9.1'))
call assert_false(has('patch-abc'))
endfunc

func Test_op_ternary()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
57,
/**/
56,
/**/
Expand Down

0 comments on commit 5154a88

Please sign in to comment.