aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/eval.txt23
-rw-r--r--runtime/doc/various.txt1
-rw-r--r--src/nvim/buffer.h6
-rw-r--r--src/nvim/charset.c16
-rw-r--r--src/nvim/eval.c59
-rw-r--r--src/nvim/eval/decode.c6
-rw-r--r--src/nvim/eval/typval.h13
-rw-r--r--src/nvim/ex_cmds.c8
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/fold.c2
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/indent.c4
-rw-r--r--src/nvim/keymap.c2
-rw-r--r--src/nvim/ops.c46
-rw-r--r--src/nvim/option.c4
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/testdir/test_viml.vim26
-rw-r--r--src/nvim/version.c2
19 files changed, 137 insertions, 93 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 11b42dd2e5..47f8414285 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -22,6 +22,8 @@ done, the features in this document are not available. See |+eval| and
There are six types of variables:
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
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)
(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.
None of these work for |Funcref|s.
@@ -3536,17 +3543,19 @@ float2nr({expr}) *float2nr()*
decimal point.
{expr} must evaluate to a |Float| or a Number.
When the value of {expr} is out of range for a |Number| the
- result is truncated to 0x7fffffff or -0x7fffffff. NaN results
- in -0x80000000.
+ result is truncated to 0x7fffffff or -0x7fffffff (or when
+ 64-bit Number support is enabled, 0x7fffffffffffffff or
+ -0x7fffffffffffffff. NaN results in -0x80000000 (or when
+ 64-bit Number support is enabled, -0x8000000000000000).
Examples: >
echo float2nr(3.95)
< 3 >
echo float2nr(-23.45)
< -23 >
echo float2nr(1.0e100)
-< 2147483647 >
+< 2147483647 (or 9223372036854775807) >
echo float2nr(-1.0e150)
-< -2147483647 >
+< -2147483647 (or -9223372036854775807) >
echo float2nr(1.0e-100)
< 0
@@ -7983,7 +7992,10 @@ winwidth({nr}) *winwidth()*
:if winwidth(0) <= 50
: exe "normal 50\<C-W>|"
:endif
-<
+< For getting the terminal or screen size, see the 'columns'
+ option.
+
+
wordcount() *wordcount()*
The result is a dictionary of byte/chars/word statistics for
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_encoding 'encoding' is set to a multi-byte encoding.
multi_lang Compiled with support for multiple languages.
+num64 Compiled with 64-bit |Number| support.
nvim This is Nvim. |has-patch|
path_extra Compiled with up/downwards search in 'path' and 'tags'
persistent_undo Compiled with support for persistent undo history.
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 2679c2dabb..8880b625e9 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -352,6 +352,7 @@ N *+mouseshape* |'mouseshape'|
N *+multi_byte* 16 and 32 bit characters |multibyte|
*+multi_byte_ime* Win32 input method for multibyte chars |multibyte-ime|
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 *+persistent_undo* Persistent undo |undo-persistence|
*+postscript* |:hardcopy| writes a PostScript file
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h
index 39b9faf8b1..609567fbcd 100644
--- a/src/nvim/buffer.h
+++ b/src/nvim/buffer.h
@@ -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;
/// Set b_changedtick and corresponding variable
///
/// @param[out] buf Buffer to set changedtick in.
/// @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
dictitem_T *const changedtick_di = tv_dict_find(
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 5a0590d075..bf4dc25efd 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -1621,13 +1621,13 @@ bool vim_isblankline(char_u *lbuf)
/// @param unptr Returns the unsigned result.
/// @param maxlen Max length of string to check.
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 maxlen)
+ const int what, varnumber_T *const nptr,
+ uvarnumber_T *const unptr, const int maxlen)
{
const char_u *ptr = start;
int pre = 0; // default is decimal
bool negative = false;
- unsigned long un = 0;
+ uvarnumber_T un = 0;
if (ptr[0] == '-') {
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"
}
while ('0' <= *ptr && *ptr <= '1') {
- un = 2 * un + (unsigned long)(*ptr - '0');
+ un = 2 * un + (uvarnumber_T)(*ptr - '0');
ptr++;
if (n++ == maxlen) {
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) {
// octal
while ('0' <= *ptr && *ptr <= '7') {
- un = 8 * un + (unsigned long)(*ptr - '0');
+ un = 8 * un + (uvarnumber_T)(*ptr - '0');
ptr++;
if (n++ == maxlen) {
break;
@@ -1705,7 +1705,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
n += 2; // skip over "0x"
}
while (ascii_isxdigit(*ptr)) {
- un = 16 * un + (unsigned long)hex2nr(*ptr);
+ un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
ptr++;
if (n++ == maxlen) {
break;
@@ -1733,9 +1733,9 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
if (nptr != NULL) {
if (negative) {
// account for leading '-' for decimal numbers
- *nptr = -(long)un;
+ *nptr = -(varnumber_T)un;
} else {
- *nptr = (long)un;
+ *nptr = (varnumber_T)un;
}
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c9da08acd0..19e23190b1 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -446,7 +446,7 @@ typedef struct {
bool rpc;
int refcount;
Callback on_stdout, on_stderr, on_exit;
- int *status_ptr;
+ varnumber_T *status_ptr;
uint64_t id;
MultiQueue *events;
} TerminalJobData;
@@ -970,7 +970,7 @@ eval_to_bool (
emsg_skip--;
}
- return retval;
+ return (int)retval;
}
/// 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.
* Returns -1 for an error.
*/
-int eval_to_number(char_u *expr)
+varnumber_T eval_to_number(char_u *expr)
{
typval_T rettv;
- int retval;
+ varnumber_T retval;
char_u *p = skipwhite(expr);
++emsg_off;
@@ -1203,7 +1203,7 @@ int call_vim_function(
typval_T *rettv
)
{
- long n;
+ varnumber_T n;
int len;
int doesrange;
void *save_funccalp = NULL;
@@ -1261,7 +1261,7 @@ int call_vim_function(
* Returns -1 when calling the function fails.
* Uses argv[argc] for the function arguments.
*/
-long
+varnumber_T
call_func_retnr (
char_u *func,
int argc,
@@ -1270,7 +1270,7 @@ call_func_retnr (
)
{
typval_T rettv;
- long retval;
+ varnumber_T retval;
/* All arguments are passed as strings, no conversion to number. */
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)
{
typval_T tv;
- int retval;
+ varnumber_T retval;
char_u *s;
int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
OPT_LOCAL);
@@ -1432,7 +1432,7 @@ int eval_foldexpr(char_u *arg, int *cp)
--sandbox;
--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) {
lp->ll_n1 = 0;
} 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);
}
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.
*/
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);
if (lp->ll_n2 < 0) {
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;
int type_is = FALSE; /* TRUE for "is" and "isnot" */
int len = 2;
- long n1, n2;
+ varnumber_T n1, n2;
int ic;
/*
@@ -3787,7 +3787,7 @@ static int eval5(char_u **arg, typval_T *rettv, int evaluate)
typval_T var2;
typval_T var3;
int op;
- long n1, n2;
+ varnumber_T n1, n2;
float_T f1 = 0, f2 = 0;
char_u *p;
@@ -3938,7 +3938,7 @@ eval6 (
{
typval_T var2;
int op;
- long n1, n2;
+ varnumber_T n1, n2;
int use_float = FALSE;
float_T f1 = 0, f2;
bool error = false;
@@ -4032,11 +4032,11 @@ eval6 (
else if (op == '/') {
if (n2 == 0) { /* give an error message? */
if (n1 == 0)
- n1 = -0x7fffffffL - 1L; /* similar to NaN */
+ n1 = -0x7fffffffffffffff - 1; /* similar to NaN */
else if (n1 < 0)
- n1 = -0x7fffffffL;
+ n1 = -0x7fffffffffffffff;
else
- n1 = 0x7fffffffL;
+ n1 = 0x7fffffffffffffff;
} else
n1 = n1 / n2;
} else {
@@ -4087,7 +4087,7 @@ static int eval7(
int want_string // after "." operator
)
{
- long n;
+ varnumber_T n;
int len;
char_u *s;
char_u *start_leader, *end_leader;
@@ -4285,7 +4285,7 @@ static int eval7(
// Apply logical NOT and unary '-', from right to left, ignore '+'.
if (ret == OK && evaluate && end_leader > start_leader) {
bool error = false;
- int val = 0;
+ varnumber_T val = 0;
float_T f = 0.0;
if (rettv->v_type == VAR_FLOAT) {
@@ -7614,9 +7614,9 @@ static void f_cursor(typval_T *argvars, typval_T *rettv, FunPtr fptr)
}
} else {
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) {
- coladd = tv_get_number_chk(&argvars[2], NULL);
+ coladd = (long)tv_get_number_chk(&argvars[2], NULL);
}
}
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)) {
listitem_T *item;
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) {
return; // Type error; errmsg already given.
}
@@ -10516,6 +10516,7 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
"mouse",
"multi_byte",
"multi_lang",
+ "num64",
"packages",
"path_extra",
"persistent_undo",
@@ -12945,7 +12946,7 @@ static void f_range(typval_T *argvars, typval_T *rettv, FunPtr fptr)
varnumber_T start;
varnumber_T end;
varnumber_T stride = 1;
- long i;
+ varnumber_T i;
bool error = false;
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
// values, now we combine them again.
union {
- struct { varnumber_T low, high; } split;
+ struct { int32_t low, high; } split;
proftime_T prof;
} 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
// are at least 32-bits wide. So we'll use two 32-bit values to store it.
union {
- struct { varnumber_T low, high; } split;
+ struct { int32_t low, high; } split;
proftime_T prof;
} u = { .prof = res };
@@ -15152,8 +15153,8 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero)
int res;
if (sortinfo->item_compare_numbers) {
- const long v1 = tv_get_number(tv1);
- const long v2 = tv_get_number(tv2);
+ const varnumber_T v1 = tv_get_number(tv1);
+ const varnumber_T v2 = tv_get_number(tv2);
res = v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
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)
{
int base = 10;
- long n;
+ varnumber_T n;
int what;
if (argvars[1].v_type != VAR_UNKNOWN) {
@@ -18108,7 +18109,7 @@ static int eval_isnamec1(int c)
/*
* 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;
}
diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c
index 935c98fb84..bf0abe04a3 100644
--- a/src/nvim/eval/decode.c
+++ b/src/nvim/eval/decode.c
@@ -435,7 +435,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
case 'u': {
const char ubuf[] = { t[1], t[2], t[3], t[4] };
t += 4;
- unsigned long ch;
+ uvarnumber_T ch;
vim_str2nr((char_u *) ubuf, NULL, NULL,
STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4);
if (ch == 0) {
@@ -609,7 +609,7 @@ parse_json_number_check:
tv.v_type = VAR_FLOAT;
} else {
// Convert integer
- long nr;
+ varnumber_T nr;
int num_len;
vim_str2nr((char_u *) s, NULL, &num_len, 0, &nr, NULL, (int) (p - s));
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"),
(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),
stack, container_stack,
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index 0f659727ee..3f8ed3b3f9 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -1,7 +1,7 @@
#ifndef NVIM_EVAL_TYPVAL_H
#define NVIM_EVAL_TYPVAL_H
-#include <limits.h>
+#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
@@ -20,20 +20,21 @@
#include "nvim/macros.h"
/// 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
typedef double float_T;
/// 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
-#define VARNUMBER_MIN INT_MIN
-#define PRIdVARNUMBER "d"
+#define VARNUMBER_MIN INT64_MIN
/// %d printf format specifier for varnumber_T
-#define PRIdVARNUMBER "d"
+#define PRIdVARNUMBER PRId64
typedef struct listvar_S list_T;
typedef struct dictvar_S dict_T;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index a528a65abb..008a44b43b 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -318,14 +318,12 @@ static int sort_abort; ///< flag to indicate if sorting has been interrupted
/// Struct to store info to be sorted.
typedef struct {
linenr_T lnum; ///< line number
- long start_col_nr; ///< starting column number or number
- long end_col_nr; ///< ending column number
union {
struct {
- long start_col_nr; ///< starting column number
- long end_col_nr; ///< ending column number
+ varnumber_T start_col_nr; ///< starting column number
+ varnumber_T end_col_nr; ///< ending column number
} 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
} st_u;
} sorti_T;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 2b4997928e..b27d778140 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -5004,7 +5004,7 @@ int get_list_range(char_u **str, int *num1, int *num2)
{
int len;
int first = false;
- long num;
+ varnumber_T num;
*str = skipwhite(*str);
if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 42cc42b844..031aca97ff 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -6871,7 +6871,7 @@ static bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io,
active_apc_list = &patcmd;
/* 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) {
save_cmdarg = set_cmdarg(eap, NULL);
set_vim_var_nr(VV_CMDBANG, (long)eap->forceit);
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 9c44e89eed..db88791967 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -2894,7 +2894,7 @@ static void foldlevelExpr(fline_T *flp)
/* KeyTyped may be reset to 0 when calling a function which invokes
* do_cmdline(). To make 'foldopen' work correctly restore 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;
switch (c) {
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 957ab6c9ce..785c9fade9 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -1015,7 +1015,7 @@ EXTERN int did_cursorhold INIT(= false); // set when CursorHold t'gerd
// for CursorMoved event
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 int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 5471b41b2c..efca739c2d 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -471,7 +471,7 @@ int get_breakindent_win(win_T *wp, char_u *line) {
|| prev_tick != wp->w_buffer->b_changedtick) {
prev_line = line;
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,
(int)wp->w_buffer->b_p_ts, wp->w_p_list);
}
@@ -538,7 +538,7 @@ int get_expr_indent(void)
sandbox++;
}
textlock++;
- indent = eval_to_number(curbuf->b_p_inde);
+ indent = (int)eval_to_number(curbuf->b_p_inde);
if (use_sandbox) {
sandbox--;
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 9c5fe78c7c..ee67b4c19d 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -557,7 +557,7 @@ int find_special_key(const char_u **srcp, const size_t src_len, int *const modp,
int modifiers;
int bit;
int key;
- unsigned long n;
+ uvarnumber_T n;
int l;
if (src_len == 0) {
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index e374686286..ce34e26994 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -939,9 +939,9 @@ static int stuff_yank(int regname, char_u *p)
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
do_execreg (
@@ -4439,8 +4439,8 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
char_u buf2[NUMBUFLEN];
int pre; // 'X' or 'x': hex; '0': octal; 'B' or 'b': bin
static bool hexupper = false; // 0xABC
- unsigned long n;
- unsigned long oldn;
+ uvarnumber_T n;
+ uvarnumber_T oldn;
char_u *ptr;
int c;
int todel;
@@ -4635,20 +4635,20 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
oldn = n;
- n = subtract ? n - (unsigned long) Prenum1
- : n + (unsigned long) Prenum1;
+ n = subtract ? n - (uvarnumber_T) Prenum1
+ : n + (uvarnumber_T) Prenum1;
// handle wraparound for decimal numbers
if (!pre) {
if (subtract) {
if (n > oldn) {
- n = 1 + (n ^ (unsigned long)-1);
+ n = 1 + (n ^ (uvarnumber_T)-1);
negative ^= true;
}
} else {
// add
if (n < oldn) {
- n = (n ^ (unsigned long)-1);
+ n = (n ^ (uvarnumber_T)-1);
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
* 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;
- long words = 0;
- long chars = 0;
+ varnumber_T i;
+ varnumber_T words = 0;
+ varnumber_T chars = 0;
int is_word = 0;
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 buf2[40];
linenr_T lnum;
- long byte_count = 0;
- long bom_count = 0;
- long byte_count_cursor = 0;
- long char_count = 0;
- long char_count_cursor = 0;
- long word_count = 0;
- long word_count_cursor = 0;
+ varnumber_T byte_count = 0;
+ varnumber_T bom_count = 0;
+ varnumber_T byte_count_cursor = 0;
+ varnumber_T char_count = 0;
+ varnumber_T char_count_cursor = 0;
+ varnumber_T word_count = 0;
+ varnumber_T word_count_cursor = 0;
int eol_size;
- long last_check = 100000L;
+ varnumber_T last_check = 100000L;
long line_count_selected = 0;
pos_T min_pos, max_pos;
oparg_T oparg;
@@ -5398,12 +5400,12 @@ void cursor_pos_info(dict_T *dict)
byte_count_cursor = byte_count +
line_count_info(ml_get(lnum),
&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 */
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.
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 392a2f3908..defe0ad246 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1144,7 +1144,7 @@ do_set (
int afterchar; /* character just after option name */
int len;
int i;
- long value;
+ varnumber_T value;
int key;
uint32_t flags; /* flags 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) {
*numval = curbufIsChanged();
} else {
- *numval = *(int *)varp;
+ *numval = (long) *(varnumber_T *)varp;
}
}
return 1;
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index ff51bf289e..b6878cbbf4 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -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) {
// Use the specified quickfix/location list
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) {
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);
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");
char_u vcol = (char_u)tv_dict_get_number(d, "vcol");
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) {
// Use the specified quickfix/location list
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) {
return FAIL;
}
diff --git a/src/nvim/testdir/test_viml.vim b/src/nvim/testdir/test_viml.vim
index a2997b6d4d..55d0dc21a3 100644
--- a/src/nvim/testdir/test_viml.vim
+++ b/src/nvim/testdir/test_viml.vim
@@ -1062,6 +1062,32 @@ func Test_echo_and_string()
call assert_equal(["{'a': [], 'b': []}",
\ "{'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
"-------------------------------------------------------------------------------
diff --git a/src/nvim/version.c b/src/nvim/version.c
index f48cd9f2a7..174ae2836c 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -468,7 +468,7 @@ static const int included_patches[] = {
// 1979,
// 1978,
// 1977,
- // 1976,
+ 1976,
1975,
// 1974 NA
1973,