vim-patch:7.4.1976

Problem:    Number variables are not 64 bits while they could be.
Solution:   Add the num64 feature. (Ken Takata)

22fcfad292
This commit is contained in:
James McCoy
2016-11-16 11:09:04 -05:00
parent 953f26bace
commit 81be7358be
19 changed files with 137 additions and 93 deletions

View File

@@ -22,6 +22,8 @@ done, the features in this document are not available. See |+eval| and
There are six types of variables: There are six types of variables:
Number A 32 or 64 bit signed number. |expr-number| *Number* Number A 32 or 64 bit signed number. |expr-number| *Number*
64-bit Number is available only when compiled with the
|+num64| feature.
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*
@@ -887,6 +889,11 @@ When dividing a Number by zero the result depends on the value:
<0 / 0 = -0x7fffffff (like negative infinity) <0 / 0 = -0x7fffffff (like negative infinity)
(before Vim 7.2 it was always 0x7fffffff) (before Vim 7.2 it was always 0x7fffffff)
When 64-bit Number support is enabled:
0 / 0 = -0x8000000000000000 (like NaN for Float)
>0 / 0 = 0x7fffffffffffffff (like positive infinity)
<0 / 0 = -0x7fffffffffffffff (like negative infinity)
When the righthand side of '%' is zero, the result is 0. When the righthand side of '%' is zero, the result is 0.
None of these work for |Funcref|s. None of these work for |Funcref|s.
@@ -3536,17 +3543,19 @@ float2nr({expr}) *float2nr()*
decimal point. decimal point.
{expr} must evaluate to a |Float| or a Number. {expr} must evaluate to a |Float| or a Number.
When the value of {expr} is out of range for a |Number| the When the value of {expr} is out of range for a |Number| the
result is truncated to 0x7fffffff or -0x7fffffff. NaN results result is truncated to 0x7fffffff or -0x7fffffff (or when
in -0x80000000. 64-bit Number support is enabled, 0x7fffffffffffffff or
-0x7fffffffffffffff. NaN results in -0x80000000 (or when
64-bit Number support is enabled, -0x8000000000000000).
Examples: > Examples: >
echo float2nr(3.95) echo float2nr(3.95)
< 3 > < 3 >
echo float2nr(-23.45) echo float2nr(-23.45)
< -23 > < -23 >
echo float2nr(1.0e100) echo float2nr(1.0e100)
< 2147483647 > < 2147483647 (or 9223372036854775807) >
echo float2nr(-1.0e150) echo float2nr(-1.0e150)
< -2147483647 > < -2147483647 (or -9223372036854775807) >
echo float2nr(1.0e-100) echo float2nr(1.0e-100)
< 0 < 0
@@ -7983,7 +7992,10 @@ winwidth({nr}) *winwidth()*
:if winwidth(0) <= 50 :if winwidth(0) <= 50
: exe "normal 50\<C-W>|" : exe "normal 50\<C-W>|"
:endif :endif
< < For getting the terminal or screen size, see the 'columns'
option.
wordcount() *wordcount()* wordcount() *wordcount()*
The result is a dictionary of byte/chars/word statistics for The result is a dictionary of byte/chars/word statistics for
the current buffer. This is the same info as provided by the current buffer. This is the same info as provided by
@@ -8137,6 +8149,7 @@ mouseshape Compiled with support for 'mouseshape'.
multi_byte Compiled with support for 'encoding' multi_byte Compiled with support for 'encoding'
multi_byte_encoding 'encoding' is set to a multi-byte encoding. multi_byte_encoding 'encoding' is set to a multi-byte encoding.
multi_lang Compiled with support for multiple languages. multi_lang Compiled with support for multiple languages.
num64 Compiled with 64-bit |Number| support.
nvim This is Nvim. |has-patch| nvim This is Nvim. |has-patch|
path_extra Compiled with up/downwards search in 'path' and 'tags' path_extra Compiled with up/downwards search in 'path' and 'tags'
persistent_undo Compiled with support for persistent undo history. persistent_undo Compiled with support for persistent undo history.

View File

@@ -352,6 +352,7 @@ N *+mouseshape* |'mouseshape'|
N *+multi_byte* 16 and 32 bit characters |multibyte| N *+multi_byte* 16 and 32 bit characters |multibyte|
*+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime| *+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime|
N *+multi_lang* non-English language support |multi-lang| N *+multi_lang* non-English language support |multi-lang|
*+num64* 64-bit Number support |Number|
N *+path_extra* Up/downwards search in 'path' and 'tags' N *+path_extra* Up/downwards search in 'path' and 'tags'
N *+persistent_undo* Persistent undo |undo-persistence| N *+persistent_undo* Persistent undo |undo-persistence|
*+postscript* |:hardcopy| writes a PostScript file *+postscript* |:hardcopy| writes a PostScript file

View File

@@ -83,14 +83,16 @@ static inline void restore_win_for_buf(win_T *save_curwin,
} }
} }
static inline void buf_set_changedtick(buf_T *const buf, const int changedtick) static inline void buf_set_changedtick(buf_T *const buf,
const varnumber_T changedtick)
REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE; REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE;
/// Set b_changedtick and corresponding variable /// Set b_changedtick and corresponding variable
/// ///
/// @param[out] buf Buffer to set changedtick in. /// @param[out] buf Buffer to set changedtick in.
/// @param[in] changedtick New value. /// @param[in] changedtick New value.
static inline void buf_set_changedtick(buf_T *const buf, const int changedtick) static inline void buf_set_changedtick(buf_T *const buf,
const varnumber_T changedtick)
{ {
#ifndef NDEBUG #ifndef NDEBUG
dictitem_T *const changedtick_di = tv_dict_find( dictitem_T *const changedtick_di = tv_dict_find(

View File

@@ -1621,13 +1621,13 @@ bool vim_isblankline(char_u *lbuf)
/// @param unptr Returns the unsigned result. /// @param unptr Returns the unsigned result.
/// @param maxlen Max length of string to check. /// @param maxlen Max length of string to check.
void vim_str2nr(const char_u *const start, int *const prep, int *const len, void vim_str2nr(const char_u *const start, int *const prep, int *const len,
const int what, long *const nptr, unsigned long *const unptr, const int what, varnumber_T *const nptr,
const int maxlen) uvarnumber_T *const unptr, const int maxlen)
{ {
const char_u *ptr = start; const char_u *ptr = start;
int pre = 0; // default is decimal int pre = 0; // default is decimal
bool negative = false; bool negative = false;
unsigned long un = 0; uvarnumber_T un = 0;
if (ptr[0] == '-') { if (ptr[0] == '-') {
negative = true; negative = true;
@@ -1683,7 +1683,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
n += 2; // skip over "0b" n += 2; // skip over "0b"
} }
while ('0' <= *ptr && *ptr <= '1') { while ('0' <= *ptr && *ptr <= '1') {
un = 2 * un + (unsigned long)(*ptr - '0'); un = 2 * un + (uvarnumber_T)(*ptr - '0');
ptr++; ptr++;
if (n++ == maxlen) { if (n++ == maxlen) {
break; break;
@@ -1692,7 +1692,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
} else if ((pre == '0') || what == STR2NR_OCT + STR2NR_FORCE) { } else if ((pre == '0') || what == STR2NR_OCT + STR2NR_FORCE) {
// octal // octal
while ('0' <= *ptr && *ptr <= '7') { while ('0' <= *ptr && *ptr <= '7') {
un = 8 * un + (unsigned long)(*ptr - '0'); un = 8 * un + (uvarnumber_T)(*ptr - '0');
ptr++; ptr++;
if (n++ == maxlen) { if (n++ == maxlen) {
break; break;
@@ -1705,7 +1705,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
n += 2; // skip over "0x" n += 2; // skip over "0x"
} }
while (ascii_isxdigit(*ptr)) { while (ascii_isxdigit(*ptr)) {
un = 16 * un + (unsigned long)hex2nr(*ptr); un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
ptr++; ptr++;
if (n++ == maxlen) { if (n++ == maxlen) {
break; break;
@@ -1733,9 +1733,9 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
if (nptr != NULL) { if (nptr != NULL) {
if (negative) { if (negative) {
// account for leading '-' for decimal numbers // account for leading '-' for decimal numbers
*nptr = -(long)un; *nptr = -(varnumber_T)un;
} else { } else {
*nptr = (long)un; *nptr = (varnumber_T)un;
} }
} }

View File

@@ -446,7 +446,7 @@ typedef struct {
bool rpc; bool rpc;
int refcount; int refcount;
Callback on_stdout, on_stderr, on_exit; Callback on_stdout, on_stderr, on_exit;
int *status_ptr; varnumber_T *status_ptr;
uint64_t id; uint64_t id;
MultiQueue *events; MultiQueue *events;
} TerminalJobData; } TerminalJobData;
@@ -970,7 +970,7 @@ eval_to_bool (
emsg_skip--; emsg_skip--;
} }
return retval; return (int)retval;
} }
/// Top level evaluation function, returning a string /// Top level evaluation function, returning a string
@@ -1081,10 +1081,10 @@ char_u *eval_to_string_safe(char_u *arg, char_u **nextcmd, int use_sandbox)
* Evaluates "expr" silently. * Evaluates "expr" silently.
* Returns -1 for an error. * Returns -1 for an error.
*/ */
int eval_to_number(char_u *expr) varnumber_T eval_to_number(char_u *expr)
{ {
typval_T rettv; typval_T rettv;
int retval; varnumber_T retval;
char_u *p = skipwhite(expr); char_u *p = skipwhite(expr);
++emsg_off; ++emsg_off;
@@ -1203,7 +1203,7 @@ int call_vim_function(
typval_T *rettv typval_T *rettv
) )
{ {
long n; varnumber_T n;
int len; int len;
int doesrange; int doesrange;
void *save_funccalp = NULL; void *save_funccalp = NULL;
@@ -1261,7 +1261,7 @@ int call_vim_function(
* Returns -1 when calling the function fails. * Returns -1 when calling the function fails.
* Uses argv[argc] for the function arguments. * Uses argv[argc] for the function arguments.
*/ */
long varnumber_T
call_func_retnr ( call_func_retnr (
char_u *func, char_u *func,
int argc, int argc,
@@ -1270,7 +1270,7 @@ call_func_retnr (
) )
{ {
typval_T rettv; typval_T rettv;
long retval; varnumber_T retval;
/* All arguments are passed as strings, no conversion to number. */ /* All arguments are passed as strings, no conversion to number. */
if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL) if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
@@ -1399,7 +1399,7 @@ void prof_child_exit(proftime_T *tm /* where waittime was stored */
int eval_foldexpr(char_u *arg, int *cp) int eval_foldexpr(char_u *arg, int *cp)
{ {
typval_T tv; typval_T tv;
int retval; varnumber_T retval;
char_u *s; char_u *s;
int use_sandbox = was_set_insecurely((char_u *)"foldexpr", int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
OPT_LOCAL); OPT_LOCAL);
@@ -1432,7 +1432,7 @@ int eval_foldexpr(char_u *arg, int *cp)
--sandbox; --sandbox;
--textlock; --textlock;
return retval; return (int)retval;
} }
/* /*
@@ -2286,7 +2286,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
if (empty1) { if (empty1) {
lp->ll_n1 = 0; lp->ll_n1 = 0;
} else { } else {
lp->ll_n1 = tv_get_number(&var1); // Is number or string. lp->ll_n1 = (long)tv_get_number(&var1); // Is number or string.
tv_clear(&var1); tv_clear(&var1);
} }
lp->ll_dict = NULL; lp->ll_dict = NULL;
@@ -2315,7 +2315,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv,
* Otherwise "lp->ll_n2" is set to the second index. * Otherwise "lp->ll_n2" is set to the second index.
*/ */
if (lp->ll_range && !lp->ll_empty2) { if (lp->ll_range && !lp->ll_empty2) {
lp->ll_n2 = tv_get_number(&var2); // Is number or string. lp->ll_n2 = (long)tv_get_number(&var2); // Is number or string.
tv_clear(&var2); tv_clear(&var2);
if (lp->ll_n2 < 0) { if (lp->ll_n2 < 0) {
ni = tv_list_find(lp->ll_list, lp->ll_n2); ni = tv_list_find(lp->ll_list, lp->ll_n2);
@@ -3525,7 +3525,7 @@ static int eval4(char_u **arg, typval_T *rettv, int evaluate)
exptype_T type = TYPE_UNKNOWN; exptype_T type = TYPE_UNKNOWN;
int type_is = FALSE; /* TRUE for "is" and "isnot" */ int type_is = FALSE; /* TRUE for "is" and "isnot" */
int len = 2; int len = 2;
long n1, n2; varnumber_T n1, n2;
int ic; int ic;
/* /*
@@ -3787,7 +3787,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate)
typval_T var2; typval_T var2;
typval_T var3; typval_T var3;
int op; int op;
long n1, n2; varnumber_T n1, n2;
float_T f1 = 0, f2 = 0; float_T f1 = 0, f2 = 0;
char_u *p; char_u *p;
@@ -3938,7 +3938,7 @@ eval6 (
{ {
typval_T var2; typval_T var2;
int op; int op;
long n1, n2; varnumber_T n1, n2;
int use_float = FALSE; int use_float = FALSE;
float_T f1 = 0, f2; float_T f1 = 0, f2;
bool error = false; bool error = false;
@@ -4032,11 +4032,11 @@ eval6 (
else if (op == '/') { else if (op == '/') {
if (n2 == 0) { /* give an error message? */ if (n2 == 0) { /* give an error message? */
if (n1 == 0) if (n1 == 0)
n1 = -0x7fffffffL - 1L; /* similar to NaN */ n1 = -0x7fffffffffffffff - 1; /* similar to NaN */
else if (n1 < 0) else if (n1 < 0)
n1 = -0x7fffffffL; n1 = -0x7fffffffffffffff;
else else
n1 = 0x7fffffffL; n1 = 0x7fffffffffffffff;
} else } else
n1 = n1 / n2; n1 = n1 / n2;
} else { } else {
@@ -4087,7 +4087,7 @@ static int eval7(
int want_string // after "." operator int want_string // after "." operator
) )
{ {
long n; varnumber_T n;
int len; int len;
char_u *s; char_u *s;
char_u *start_leader, *end_leader; char_u *start_leader, *end_leader;
@@ -4285,7 +4285,7 @@ static int eval7(
// Apply logical NOT and unary '-', from right to left, ignore '+'. // Apply logical NOT and unary '-', from right to left, ignore '+'.
if (ret == OK && evaluate && end_leader > start_leader) { if (ret == OK && evaluate && end_leader > start_leader) {
bool error = false; bool error = false;
int val = 0; varnumber_T val = 0;
float_T f = 0.0; float_T f = 0.0;
if (rettv->v_type == VAR_FLOAT) { if (rettv->v_type == VAR_FLOAT) {
@@ -7614,9 +7614,9 @@ static void f_cursor(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} }
} else { } else {
line = tv_get_lnum(argvars); line = tv_get_lnum(argvars);
col = tv_get_number_chk(&argvars[1], NULL); col = (long)tv_get_number_chk(&argvars[1], NULL);
if (argvars[2].v_type != VAR_UNKNOWN) { if (argvars[2].v_type != VAR_UNKNOWN) {
coladd = tv_get_number_chk(&argvars[2], NULL); coladd = (long)tv_get_number_chk(&argvars[2], NULL);
} }
} }
if (line < 0 || col < 0 if (line < 0 || col < 0
@@ -8170,7 +8170,7 @@ static void f_extend(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} else if (!tv_check_lock(l1->lv_lock, arg_errmsg, TV_TRANSLATE)) { } else if (!tv_check_lock(l1->lv_lock, arg_errmsg, TV_TRANSLATE)) {
listitem_T *item; listitem_T *item;
if (argvars[2].v_type != VAR_UNKNOWN) { if (argvars[2].v_type != VAR_UNKNOWN) {
before = tv_get_number_chk(&argvars[2], &error); before = (long)tv_get_number_chk(&argvars[2], &error);
if (error) { if (error) {
return; // Type error; errmsg already given. return; // Type error; errmsg already given.
} }
@@ -10516,6 +10516,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
"mouse", "mouse",
"multi_byte", "multi_byte",
"multi_lang", "multi_lang",
"num64",
"packages", "packages",
"path_extra", "path_extra",
"persistent_undo", "persistent_undo",
@@ -12945,7 +12946,7 @@ static void f_range(typval_T *argvars, typval_T *rettv, FunPtr fptr)
varnumber_T start; varnumber_T start;
varnumber_T end; varnumber_T end;
varnumber_T stride = 1; varnumber_T stride = 1;
long i; varnumber_T i;
bool error = false; bool error = false;
start = tv_get_number_chk(&argvars[0], &error); start = tv_get_number_chk(&argvars[0], &error);
@@ -13163,7 +13164,7 @@ static int list2proftime(typval_T *arg, proftime_T *tm) FUNC_ATTR_NONNULL_ALL
// in f_reltime() we split up the 64-bit proftime_T into two 32-bit // in f_reltime() we split up the 64-bit proftime_T into two 32-bit
// values, now we combine them again. // values, now we combine them again.
union { union {
struct { varnumber_T low, high; } split; struct { int32_t low, high; } split;
proftime_T prof; proftime_T prof;
} u = { .split.high = n1, .split.low = n2 }; } u = { .split.high = n1, .split.low = n2 };
@@ -13204,7 +13205,7 @@ static void f_reltime(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// (varnumber_T is defined as int). For all our supported platforms, int's // (varnumber_T is defined as int). For all our supported platforms, int's
// are at least 32-bits wide. So we'll use two 32-bit values to store it. // are at least 32-bits wide. So we'll use two 32-bit values to store it.
union { union {
struct { varnumber_T low, high; } split; struct { int32_t low, high; } split;
proftime_T prof; proftime_T prof;
} u = { .prof = res }; } u = { .prof = res };
@@ -15152,8 +15153,8 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero)
int res; int res;
if (sortinfo->item_compare_numbers) { if (sortinfo->item_compare_numbers) {
const long v1 = tv_get_number(tv1); const varnumber_T v1 = tv_get_number(tv1);
const long v2 = tv_get_number(tv2); const varnumber_T v2 = tv_get_number(tv2);
res = v1 == v2 ? 0 : v1 > v2 ? 1 : -1; res = v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
goto item_compare_end; goto item_compare_end;
@@ -15697,7 +15698,7 @@ static void f_str2float(typval_T *argvars, typval_T *rettv, FunPtr fptr)
static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_str2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{ {
int base = 10; int base = 10;
long n; varnumber_T n;
int what; int what;
if (argvars[1].v_type != VAR_UNKNOWN) { if (argvars[1].v_type != VAR_UNKNOWN) {
@@ -18108,7 +18109,7 @@ static int eval_isnamec1(int c)
/* /*
* Get number v: variable value. * Get number v: variable value.
*/ */
long get_vim_var_nr(int idx) FUNC_ATTR_PURE varnumber_T get_vim_var_nr(int idx) FUNC_ATTR_PURE
{ {
return vimvars[idx].vv_nr; return vimvars[idx].vv_nr;
} }

View File

@@ -435,7 +435,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
case 'u': { case 'u': {
const char ubuf[] = { t[1], t[2], t[3], t[4] }; const char ubuf[] = { t[1], t[2], t[3], t[4] };
t += 4; t += 4;
unsigned long ch; uvarnumber_T ch;
vim_str2nr((char_u *) ubuf, NULL, NULL, vim_str2nr((char_u *) ubuf, NULL, NULL,
STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4); STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4);
if (ch == 0) { if (ch == 0) {
@@ -609,7 +609,7 @@ parse_json_number_check:
tv.v_type = VAR_FLOAT; tv.v_type = VAR_FLOAT;
} else { } else {
// Convert integer // Convert integer
long nr; varnumber_T nr;
int num_len; int num_len;
vim_str2nr((char_u *) s, NULL, &num_len, 0, &nr, NULL, (int) (p - s)); vim_str2nr((char_u *) s, NULL, &num_len, 0, &nr, NULL, (int) (p - s));
if ((int) exp_num_len != num_len) { if ((int) exp_num_len != num_len) {
@@ -617,7 +617,7 @@ parse_json_number_check:
"to integer vim_str2nr consumed %i bytes in place of %zu"), "to integer vim_str2nr consumed %i bytes in place of %zu"),
(int) exp_num_len, s, num_len, exp_num_len); (int) exp_num_len, s, num_len, exp_num_len);
} }
tv.vval.v_number = (varnumber_T) nr; tv.vval.v_number = nr;
} }
if (json_decoder_pop(OBJ(tv, false, *didcomma, *didcolon), if (json_decoder_pop(OBJ(tv, false, *didcomma, *didcolon),
stack, container_stack, stack, container_stack,

View File

@@ -1,7 +1,7 @@
#ifndef NVIM_EVAL_TYPVAL_H #ifndef NVIM_EVAL_TYPVAL_H
#define NVIM_EVAL_TYPVAL_H #define NVIM_EVAL_TYPVAL_H
#include <limits.h> #include <inttypes.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@@ -20,20 +20,21 @@
#include "nvim/macros.h" #include "nvim/macros.h"
/// Type used for VimL VAR_NUMBER values /// Type used for VimL VAR_NUMBER values
typedef int varnumber_T; typedef int64_t varnumber_T;
typedef uint64_t uvarnumber_T;
/// Type used for VimL VAR_FLOAT values /// Type used for VimL VAR_FLOAT values
typedef double float_T; typedef double float_T;
/// Maximal possible value of varnumber_T variable /// Maximal possible value of varnumber_T variable
#define VARNUMBER_MAX INT_MAX #define VARNUMBER_MAX INT64_MAX
#define UVARNUMBER_MAX UINT64_MAX
/// Mimimal possible value of varnumber_T variable /// Mimimal possible value of varnumber_T variable
#define VARNUMBER_MIN INT_MIN #define VARNUMBER_MIN INT64_MIN
#define PRIdVARNUMBER "d"
/// %d printf format specifier for varnumber_T /// %d printf format specifier for varnumber_T
#define PRIdVARNUMBER "d" #define PRIdVARNUMBER PRId64
typedef struct listvar_S list_T; typedef struct listvar_S list_T;
typedef struct dictvar_S dict_T; typedef struct dictvar_S dict_T;

View File

@@ -318,14 +318,12 @@ static int sort_abort; ///< flag to indicate if sorting has been interrupted
/// Struct to store info to be sorted. /// Struct to store info to be sorted.
typedef struct { typedef struct {
linenr_T lnum; ///< line number linenr_T lnum; ///< line number
long start_col_nr; ///< starting column number or number
long end_col_nr; ///< ending column number
union { union {
struct { struct {
long start_col_nr; ///< starting column number varnumber_T start_col_nr; ///< starting column number
long end_col_nr; ///< ending column number varnumber_T end_col_nr; ///< ending column number
} line; } line;
long value; ///< value if sorting by integer varnumber_T value; ///< value if sorting by integer
float_T value_flt; ///< value if sorting by float float_T value_flt; ///< value if sorting by float
} st_u; } st_u;
} sorti_T; } sorti_T;

View File

@@ -5004,7 +5004,7 @@ int get_list_range(char_u **str, int *num1, int *num2)
{ {
int len; int len;
int first = false; int first = false;
long num; varnumber_T num;
*str = skipwhite(*str); *str = skipwhite(*str);
if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range

View File

@@ -6871,7 +6871,7 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io,
active_apc_list = &patcmd; active_apc_list = &patcmd;
/* set v:cmdarg (only when there is a matching pattern) */ /* set v:cmdarg (only when there is a matching pattern) */
save_cmdbang = get_vim_var_nr(VV_CMDBANG); save_cmdbang = (long)get_vim_var_nr(VV_CMDBANG);
if (eap != NULL) { if (eap != NULL) {
save_cmdarg = set_cmdarg(eap, NULL); save_cmdarg = set_cmdarg(eap, NULL);
set_vim_var_nr(VV_CMDBANG, (long)eap->forceit); set_vim_var_nr(VV_CMDBANG, (long)eap->forceit);

View File

@@ -2894,7 +2894,7 @@ static void foldlevelExpr(fline_T *flp)
/* KeyTyped may be reset to 0 when calling a function which invokes /* KeyTyped may be reset to 0 when calling a function which invokes
* do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. */ * do_cmdline(). To make 'foldopen' work correctly restore KeyTyped. */
save_keytyped = KeyTyped; save_keytyped = KeyTyped;
n = eval_foldexpr(flp->wp->w_p_fde, &c); n = (int)eval_foldexpr(flp->wp->w_p_fde, &c);
KeyTyped = save_keytyped; KeyTyped = save_keytyped;
switch (c) { switch (c) {

View File

@@ -1015,7 +1015,7 @@ EXTERN int did_cursorhold INIT(= false); // set when CursorHold t'gerd
// for CursorMoved event // for CursorMoved event
EXTERN pos_T last_cursormoved INIT(= INIT_POS_T(0, 0, 0)); EXTERN pos_T last_cursormoved INIT(= INIT_POS_T(0, 0, 0));
EXTERN int last_changedtick INIT(= 0); // for TextChanged event EXTERN varnumber_T last_changedtick INIT(= 0); // for TextChanged event
EXTERN buf_T *last_changedtick_buf INIT(= NULL); EXTERN buf_T *last_changedtick_buf INIT(= NULL);
EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */ EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */

View File

@@ -471,7 +471,7 @@ int get_breakindent_win(win_T *wp, char_u *line) {
|| prev_tick != wp->w_buffer->b_changedtick) { || prev_tick != wp->w_buffer->b_changedtick) {
prev_line = line; prev_line = line;
prev_ts = wp->w_buffer->b_p_ts; prev_ts = wp->w_buffer->b_p_ts;
prev_tick = wp->w_buffer->b_changedtick; prev_tick = (int)wp->w_buffer->b_changedtick;
prev_indent = get_indent_str(line, prev_indent = get_indent_str(line,
(int)wp->w_buffer->b_p_ts, wp->w_p_list); (int)wp->w_buffer->b_p_ts, wp->w_p_list);
} }
@@ -538,7 +538,7 @@ int get_expr_indent(void)
sandbox++; sandbox++;
} }
textlock++; textlock++;
indent = eval_to_number(curbuf->b_p_inde); indent = (int)eval_to_number(curbuf->b_p_inde);
if (use_sandbox) { if (use_sandbox) {
sandbox--; sandbox--;

View File

@@ -557,7 +557,7 @@ int find_special_key(const char_u **srcp, const size_t src_len, int *const modp,
int modifiers; int modifiers;
int bit; int bit;
int key; int key;
unsigned long n; uvarnumber_T n;
int l; int l;
if (src_len == 0) { if (src_len == 0) {

View File

@@ -939,9 +939,9 @@ static int stuff_yank(int regname, char_u *p)
static int execreg_lastc = NUL; static int execreg_lastc = NUL;
/* /*
* execute a yank register: copy it into the stuff buffer * Execute a yank register: copy it into the stuff buffer
* *
* return FAIL for failure, OK otherwise * Return FAIL for failure, OK otherwise
*/ */
int int
do_execreg ( do_execreg (
@@ -4439,8 +4439,8 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
char_u buf2[NUMBUFLEN]; char_u buf2[NUMBUFLEN];
int pre; // 'X' or 'x': hex; '0': octal; 'B' or 'b': bin int pre; // 'X' or 'x': hex; '0': octal; 'B' or 'b': bin
static bool hexupper = false; // 0xABC static bool hexupper = false; // 0xABC
unsigned long n; uvarnumber_T n;
unsigned long oldn; uvarnumber_T oldn;
char_u *ptr; char_u *ptr;
int c; int c;
int todel; int todel;
@@ -4635,20 +4635,20 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
oldn = n; oldn = n;
n = subtract ? n - (unsigned long) Prenum1 n = subtract ? n - (uvarnumber_T) Prenum1
: n + (unsigned long) Prenum1; : n + (uvarnumber_T) Prenum1;
// handle wraparound for decimal numbers // handle wraparound for decimal numbers
if (!pre) { if (!pre) {
if (subtract) { if (subtract) {
if (n > oldn) { if (n > oldn) {
n = 1 + (n ^ (unsigned long)-1); n = 1 + (n ^ (uvarnumber_T)-1);
negative ^= true; negative ^= true;
} }
} else { } else {
// add // add
if (n < oldn) { if (n < oldn) {
n = (n ^ (unsigned long)-1); n = (n ^ (uvarnumber_T)-1);
negative ^= true; negative ^= true;
} }
} }
@@ -5238,11 +5238,13 @@ void clear_oparg(oparg_T *oap)
* case, eol_size will be added to the character count to account for * case, eol_size will be added to the character count to account for
* the size of the EOL character. * the size of the EOL character.
*/ */
static long line_count_info(char_u *line, long *wc, long *cc, long limit, int eol_size) static varnumber_T line_count_info(char_u *line, varnumber_T *wc,
varnumber_T *cc, varnumber_T limit,
int eol_size)
{ {
long i; varnumber_T i;
long words = 0; varnumber_T words = 0;
long chars = 0; varnumber_T chars = 0;
int is_word = 0; int is_word = 0;
for (i = 0; i < limit && line[i] != NUL; ) { for (i = 0; i < limit && line[i] != NUL; ) {
@@ -5280,15 +5282,15 @@ void cursor_pos_info(dict_T *dict)
char_u buf1[50]; char_u buf1[50];
char_u buf2[40]; char_u buf2[40];
linenr_T lnum; linenr_T lnum;
long byte_count = 0; varnumber_T byte_count = 0;
long bom_count = 0; varnumber_T bom_count = 0;
long byte_count_cursor = 0; varnumber_T byte_count_cursor = 0;
long char_count = 0; varnumber_T char_count = 0;
long char_count_cursor = 0; varnumber_T char_count_cursor = 0;
long word_count = 0; varnumber_T word_count = 0;
long word_count_cursor = 0; varnumber_T word_count_cursor = 0;
int eol_size; int eol_size;
long last_check = 100000L; varnumber_T last_check = 100000L;
long line_count_selected = 0; long line_count_selected = 0;
pos_T min_pos, max_pos; pos_T min_pos, max_pos;
oparg_T oparg; oparg_T oparg;
@@ -5398,12 +5400,12 @@ void cursor_pos_info(dict_T *dict)
byte_count_cursor = byte_count + byte_count_cursor = byte_count +
line_count_info(ml_get(lnum), line_count_info(ml_get(lnum),
&word_count_cursor, &char_count_cursor, &word_count_cursor, &char_count_cursor,
(long)(curwin->w_cursor.col + 1), eol_size); (varnumber_T)(curwin->w_cursor.col + 1), eol_size);
} }
} }
/* Add to the running totals */ /* Add to the running totals */
byte_count += line_count_info(ml_get(lnum), &word_count, byte_count += line_count_info(ml_get(lnum), &word_count,
&char_count, (long)MAXCOL, eol_size); &char_count, (varnumber_T)MAXCOL, eol_size);
} }
// Correction for when last line doesn't have an EOL. // Correction for when last line doesn't have an EOL.

View File

@@ -1144,7 +1144,7 @@ do_set (
int afterchar; /* character just after option name */ int afterchar; /* character just after option name */
int len; int len;
int i; int i;
long value; varnumber_T value;
int key; int key;
uint32_t flags; /* flags for current option */ uint32_t flags; /* flags for current option */
char_u *varp = NULL; /* pointer to variable for current option */ char_u *varp = NULL; /* pointer to variable for current option */
@@ -4630,7 +4630,7 @@ get_option_value (
if ((int *)varp == &curbuf->b_changed) { if ((int *)varp == &curbuf->b_changed) {
*numval = curbufIsChanged(); *numval = curbufIsChanged();
} else { } else {
*numval = *(int *)varp; *numval = (long) *(varnumber_T *)varp;
} }
} }
return 1; return 1;

View File

@@ -4027,7 +4027,7 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
if ((di = tv_dict_find(what, S_LEN("nr"))) != NULL) { if ((di = tv_dict_find(what, S_LEN("nr"))) != NULL) {
// Use the specified quickfix/location list // Use the specified quickfix/location list
if (di->di_tv.v_type == VAR_NUMBER) { if (di->di_tv.v_type == VAR_NUMBER) {
qf_idx = di->di_tv.vval.v_number - 1; qf_idx = (int)di->di_tv.vval.v_number - 1;
if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { if (qf_idx < 0 || qf_idx >= qi->qf_listcount) {
return FAIL; return FAIL;
} }
@@ -4101,7 +4101,7 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title,
char *const filename = tv_dict_get_string(d, "filename", true); char *const filename = tv_dict_get_string(d, "filename", true);
int bufnum = (int)tv_dict_get_number(d, "bufnr"); int bufnum = (int)tv_dict_get_number(d, "bufnr");
long lnum = tv_dict_get_number(d, "lnum"); long lnum = (long)tv_dict_get_number(d, "lnum");
int col = (int)tv_dict_get_number(d, "col"); int col = (int)tv_dict_get_number(d, "col");
char_u vcol = (char_u)tv_dict_get_number(d, "vcol"); char_u vcol = (char_u)tv_dict_get_number(d, "vcol");
int nr = (int)tv_dict_get_number(d, "nr"); int nr = (int)tv_dict_get_number(d, "nr");
@@ -4183,7 +4183,7 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action)
if ((di = tv_dict_find(what, S_LEN("nr"))) != NULL) { if ((di = tv_dict_find(what, S_LEN("nr"))) != NULL) {
// Use the specified quickfix/location list // Use the specified quickfix/location list
if (di->di_tv.v_type == VAR_NUMBER) { if (di->di_tv.v_type == VAR_NUMBER) {
qf_idx = di->di_tv.vval.v_number - 1; qf_idx = (int)di->di_tv.vval.v_number - 1;
if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { if (qf_idx < 0 || qf_idx >= qi->qf_listcount) {
return FAIL; return FAIL;
} }

View File

@@ -1062,6 +1062,32 @@ func Test_echo_and_string()
call assert_equal(["{'a': [], 'b': []}", call assert_equal(["{'a': [], 'b': []}",
\ "{'a': [], 'b': []}"], l) \ "{'a': [], 'b': []}"], l)
"-------------------------------------------------------------------------------
" Test 94: 64-bit Numbers {{{1
"-------------------------------------------------------------------------------
func Test_num64()
if !has('num64')
return
endif
call assert_notequal( 4294967296, 0)
call assert_notequal(-4294967296, 0)
call assert_equal( 4294967296, 0xFFFFffff + 1)
call assert_equal(-4294967296, -0xFFFFffff - 1)
call assert_equal( 9223372036854775807, 1 / 0)
call assert_equal(-9223372036854775807, -1 / 0)
call assert_equal(-9223372036854775808, 0 / 0)
call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
let rng = range(0xFFFFffff, 0x100000001)
call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
call assert_equal(0x100000001, max(rng))
call assert_equal(0xFFFFffff, min(rng))
call assert_equal(rng, sort(range(0x100000001, 0xFFFFffff, -1), 'N'))
endfunc endfunc
"------------------------------------------------------------------------------- "-------------------------------------------------------------------------------

View File

@@ -468,7 +468,7 @@ static const int included_patches[] = {
// 1979, // 1979,
// 1978, // 1978,
// 1977, // 1977,
// 1976, 1976,
1975, 1975,
// 1974 NA // 1974 NA
1973, 1973,