vim-patch:8.2.0296: mixing up "long long" and __int64 may cause problems

Problem:    Mixing up "long long" and __int64 may cause problems. (John
            Marriott)
Solution:   Pass varnumber_T to vim_snprintf().  Add v:numbersize.
f9706e9df0
This commit is contained in:
Jan Edmund Lazo 2021-04-26 22:47:12 -04:00
parent e257aff016
commit 25c0675fe3
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
4 changed files with 14 additions and 0 deletions

View File

@ -19,6 +19,7 @@ There are six types of variables:
*Number* *Integer* *Number* *Integer*
Number A 32 or 64 bit signed number. |expr-number| Number A 32 or 64 bit signed number. |expr-number|
The number of bits is available in |v:numbersize|.
Examples: -123 0x10 0177 0b1011 Examples: -123 0x10 0177 0b1011
Float A floating point number. |floating-point-format| *Float* Float A floating point number. |floating-point-format| *Float*
@ -1793,6 +1794,10 @@ v:null Special value used to put "null" in JSON and NIL in msgpack.
operator) and to zero when used as a Number (e.g. in |expr5| operator) and to zero when used as a Number (e.g. in |expr5|
or |expr7| when used with numeric operators). Read-only. or |expr7| when used with numeric operators). Read-only.
*v:numbersize* *numbersize-variable*
v:numbersize Number of bits in a Number. This is normally 64, but on some
systems it may be 32.
*v:oldfiles* *oldfiles-variable* *v:oldfiles* *oldfiles-variable*
v:oldfiles List of file names that is loaded from the |shada| file on v:oldfiles List of file names that is loaded from the |shada| file on
startup. These are the files that Vim remembers marks for. startup. These are the files that Vim remembers marks for.

View File

@ -213,6 +213,7 @@ static struct vimvar {
VV(VV_FALSE, "false", VAR_BOOL, VV_RO), VV(VV_FALSE, "false", VAR_BOOL, VV_RO),
VV(VV_TRUE, "true", VAR_BOOL, VV_RO), VV(VV_TRUE, "true", VAR_BOOL, VV_RO),
VV(VV_NULL, "null", VAR_SPECIAL, VV_RO), VV(VV_NULL, "null", VAR_SPECIAL, VV_RO),
VV(VV_NUMBERSIZE, "numbersize", VAR_NUMBER, VV_RO),
VV(VV_VIM_DID_ENTER, "vim_did_enter", VAR_NUMBER, VV_RO), VV(VV_VIM_DID_ENTER, "vim_did_enter", VAR_NUMBER, VV_RO),
VV(VV_TESTING, "testing", VAR_NUMBER, 0), VV(VV_TESTING, "testing", VAR_NUMBER, 0),
VV(VV_TYPE_NUMBER, "t_number", VAR_NUMBER, VV_RO), VV(VV_TYPE_NUMBER, "t_number", VAR_NUMBER, VV_RO),
@ -394,6 +395,7 @@ void eval_init(void)
set_vim_var_bool(VV_FALSE, kBoolVarFalse); set_vim_var_bool(VV_FALSE, kBoolVarFalse);
set_vim_var_bool(VV_TRUE, kBoolVarTrue); set_vim_var_bool(VV_TRUE, kBoolVarTrue);
set_vim_var_special(VV_NULL, kSpecialVarNull); set_vim_var_special(VV_NULL, kSpecialVarNull);
set_vim_var_nr(VV_NUMBERSIZE, sizeof(varnumber_T) * 8);
set_vim_var_special(VV_EXITING, kSpecialVarNull); set_vim_var_special(VV_EXITING, kSpecialVarNull);
set_vim_var_nr(VV_ECHOSPACE, sc_col - 1); set_vim_var_nr(VV_ECHOSPACE, sc_col - 1);

View File

@ -142,6 +142,7 @@ typedef enum {
VV_FALSE, VV_FALSE,
VV_TRUE, VV_TRUE,
VV_NULL, VV_NULL,
VV_NUMBERSIZE,
VV_VIM_DID_ENTER, VV_VIM_DID_ENTER,
VV_TESTING, VV_TESTING,
VV_TYPE_NUMBER, VV_TYPE_NUMBER,

View File

@ -120,6 +120,12 @@ func Test_skip_after_throw()
endtry endtry
endfunc endfunc
func Test_numbersize()
" This will fail on systems without 64 bit int support or when not configured
" correctly.
call assert_equal(64, v:numbersize)
endfunc
func Test_curly_assignment() func Test_curly_assignment()
let s:svar = 'svar' let s:svar = 'svar'
let g:gvar = 'gvar' let g:gvar = 'gvar'