0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.1.1526: no numerical value for the patchlevel

Problem:    No numerical value for the patchlevel.
Solution:   Add v:versionlong.
This commit is contained in:
Bram Moolenaar 2019-06-14 14:39:51 +02:00
parent b53fb31a1e
commit 37df9a4401
5 changed files with 25 additions and 11 deletions

View 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 version 5.0 and 5.1 may have a patch 123, but these are
completely different. 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* *vim_did_enter-variable*
v:vim_did_enter Zero until most of startup is done. It is set to one just v:vim_did_enter Zero until most of startup is done. It is set to one just
before |VimEnter| autocommands are triggered. before |VimEnter| autocommands are triggered.

View File

@ -196,6 +196,7 @@ static struct vimvar
{VV_NAME("termstyleresp", VAR_STRING), VV_RO}, {VV_NAME("termstyleresp", VAR_STRING), VV_RO},
{VV_NAME("termblinkresp", VAR_STRING), VV_RO}, {VV_NAME("termblinkresp", VAR_STRING), VV_RO},
{VV_NAME("event", VAR_DICT), VV_RO}, {VV_NAME("event", VAR_DICT), VV_RO},
{VV_NAME("versionlong", VAR_NUMBER), VV_RO},
}; };
/* shorthand */ /* shorthand */
@ -354,6 +355,7 @@ eval_init(void)
hash_add(&compat_hashtab, p->vv_di.di_key); hash_add(&compat_hashtab, p->vv_di.di_key);
} }
vimvars[VV_VERSION].vv_nr = VIM_VERSION_100; 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_SEARCHFORWARD, 1L);
set_vim_var_nr(VV_HLSEARCH, 1L); set_vim_var_nr(VV_HLSEARCH, 1L);

View File

@ -171,6 +171,9 @@ func Test_vvar_scriptversion2()
echo version echo version
call assert_fails('let version = 1', 'E46:') call assert_fails('let version = 1', 'E46:')
call assert_equal(v:version, version) call assert_equal(v:version, version)
call assert_equal(v:version, v:versionlong / 10000)
call assert_true(v:versionlong > 8011525)
endfunc endfunc
func Test_scriptversion() func Test_scriptversion()

View File

@ -777,6 +777,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1526,
/**/ /**/
1525, 1525,
/**/ /**/
@ -3847,13 +3849,8 @@ static char *(extra_patches[]) =
int int
highest_patch(void) highest_patch(void)
{ {
int i; // this relies on the highest patch number to be the first entry
int h = 0; return included_patches[0];
for (i = 0; included_patches[i] != 0; ++i)
if (included_patches[i] > h)
h = included_patches[i];
return h;
} }
#if defined(FEAT_EVAL) || defined(PROTO) #if defined(FEAT_EVAL) || defined(PROTO)

View File

@ -1960,7 +1960,8 @@ typedef int sock_T;
#define VV_TERMSTYLERESP 85 #define VV_TERMSTYLERESP 85
#define VV_TERMBLINKRESP 86 #define VV_TERMBLINKRESP 86
#define VV_EVENT 87 #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 */ /* used for v_number in VAR_SPECIAL */
#define VVAL_FALSE 0L #define VVAL_FALSE 0L