Skip to content

Commit

Permalink
patch 9.0.0010: returning 0 for has('patch-9.0.0') is inconsistent
Browse files Browse the repository at this point in the history
Problem:    Returning 0 for has('patch-9.0.0') is inconsistent.
Solution:   Make it return 1. (closes #10640)
  • Loading branch information
brammool committed Jun 30, 2022
1 parent 083692d commit b0375d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/testdir/test_functions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func Test_has()
" Will we ever have patch 9999?
let ver = 'patch-' .. v:version / 100 .. '.' .. v:version % 100 .. '.9999'
call assert_equal(0, has(ver))

" There actually isn't a patch 9.0.0, but this is more consistent.
call assert_equal(1, has('patch-9.0.0'))
endfunc

func Test_empty()
Expand Down
6 changes: 5 additions & 1 deletion 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 */
/**/
10,
/**/
9,
/**/
Expand Down Expand Up @@ -789,11 +791,13 @@ has_patch(int n)
// Perform a binary search.
l = 0;
h = (int)ARRAY_LENGTH(included_patches) - 1;
while (l < h)
for (;;)
{
m = (l + h) / 2;
if (included_patches[m] == n)
return TRUE;
if (l == h)
break;
if (included_patches[m] < n)
h = m;
else
Expand Down

0 comments on commit b0375d4

Please sign in to comment.