]> granicus.if.org Git - vim/commitdiff
patch 9.0.0010: returning 0 for has('patch-9.0.0') is inconsistent v9.0.0010
authorBram Moolenaar <Bram@vim.org>
Thu, 30 Jun 2022 10:03:39 +0000 (11:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 30 Jun 2022 10:03:39 +0000 (11:03 +0100)
Problem:    Returning 0 for has('patch-9.0.0') is inconsistent.
Solution:   Make it return 1. (closes #10640)

src/testdir/test_functions.vim
src/version.c

index f55e846fa5942f81a131318066936477af3e5dcb..38cd7930aff3e9f1f090746433a379d2f36ed43e 100644 (file)
@@ -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()
index 003984ab6617e411fac278df40e219e166f0ed75..c2726aa77ede3bf96863aefdb1a38837a79d1d84 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    10,
 /**/
     9,
 /**/
@@ -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