]> granicus.if.org Git - vim/commitdiff
patch 8.1.1526: no numerical value for the patchlevel v8.1.1526
authorBram Moolenaar <Bram@vim.org>
Fri, 14 Jun 2019 12:39:51 +0000 (14:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 14 Jun 2019 12:39:51 +0000 (14:39 +0200)
Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.

runtime/doc/eval.txt
src/eval.c
src/testdir/test_eval_stuff.vim
src/version.c
src/vim.h

index 5f8156003f1bc50ff85f7582c563b02b0121c105..da45de805a837b28908b86e79a347e36c43cf673 100644 (file)
@@ -2173,6 +2173,17 @@ v:version        Version number of Vim: Major version number times 100 plus
                version 5.0 and 5.1 may have a patch 123, but these are
                completely different.
 
+                                       *v:versionlong* *versionlong-variable*
+v:versionlong  Like v:version, but also including the patchlevel.  Version
+               8.1 with patch 1234 has value 8011234.  This can be used like
+               this: >
+                       if v:versionlong >= 8011234
+<              However, if there are gaps in the list of patches included
+               this will not work well.  This can happen if a recent patch
+               was included into an older version, e.g. for a security fix.
+               Use the has() function to make sure the patch is actually
+               included.
+
                                *v:vim_did_enter* *vim_did_enter-variable*
 v:vim_did_enter        Zero until most of startup is done.  It is set to one just
                before |VimEnter| autocommands are triggered.
index c86d0a6646e770f2a58eb002361f964977c7bd90..e2d3d48bd3c1a63fb0d0a46d42cf2f194fe74efa 100644 (file)
@@ -193,9 +193,10 @@ static struct vimvar
     {VV_NAME("termrfgresp",     VAR_STRING), VV_RO},
     {VV_NAME("termrbgresp",     VAR_STRING), VV_RO},
     {VV_NAME("termu7resp",      VAR_STRING), VV_RO},
-    {VV_NAME("termstyleresp",  VAR_STRING), VV_RO},
-    {VV_NAME("termblinkresp",  VAR_STRING), VV_RO},
-    {VV_NAME("event",          VAR_DICT), VV_RO},
+    {VV_NAME("termstyleresp",   VAR_STRING), VV_RO},
+    {VV_NAME("termblinkresp",   VAR_STRING), VV_RO},
+    {VV_NAME("event",           VAR_DICT), VV_RO},
+    {VV_NAME("versionlong",     VAR_NUMBER), VV_RO},
 };
 
 /* shorthand */
@@ -354,6 +355,7 @@ eval_init(void)
            hash_add(&compat_hashtab, p->vv_di.di_key);
     }
     vimvars[VV_VERSION].vv_nr = VIM_VERSION_100;
+    vimvars[VV_VERSIONLONG].vv_nr = VIM_VERSION_100 * 10000 + highest_patch();
 
     set_vim_var_nr(VV_SEARCHFORWARD, 1L);
     set_vim_var_nr(VV_HLSEARCH, 1L);
index db68e2a40292c5731b285ab0c10d2578ccce7fa1..08ab59ea53d7d23d245eee9b63dabbf9b7eeb4a9 100644 (file)
@@ -171,6 +171,9 @@ func Test_vvar_scriptversion2()
   echo version
   call assert_fails('let version = 1', 'E46:')
   call assert_equal(v:version, version)
+
+  call assert_equal(v:version, v:versionlong / 10000)
+  call assert_true(v:versionlong > 8011525)
 endfunc
 
 func Test_scriptversion()
index 058dbc702d6a98d23fd3ef52d471b89d2c4dae82..8a9885c399abd0ca32833f88954fb1a507defd5c 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1526,
 /**/
     1525,
 /**/
@@ -3847,13 +3849,8 @@ static char *(extra_patches[]) =
     int
 highest_patch(void)
 {
-    int                i;
-    int                h = 0;
-
-    for (i = 0; included_patches[i] != 0; ++i)
-       if (included_patches[i] > h)
-           h = included_patches[i];
-    return h;
+    // this relies on the highest patch number to be the first entry
+    return included_patches[0];
 }
 
 #if defined(FEAT_EVAL) || defined(PROTO)
index 3b4582bc915ed59a1217c06efd329a5677d0e410..90208cdc7eb8cc78ffd0b1c918c390f95ba1064e 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -1960,7 +1960,8 @@ typedef int sock_T;
 #define VV_TERMSTYLERESP 85
 #define VV_TERMBLINKRESP 86
 #define VV_EVENT       87
-#define VV_LEN         88      /* number of v: vars */
+#define VV_VERSIONLONG 88
+#define VV_LEN         89      // number of v: vars
 
 /* used for v_number in VAR_SPECIAL */
 #define VVAL_FALSE     0L