summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-01 18:17:26 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-01 18:17:26 +0200
commit22fcfad29276bd5f317faf516637dcd491b96a12 (patch)
tree5787f5e2134b066406fd0d222c4f2f0d18e28024
parent8767f52fbfd4f053ce00a978227c95f1d7d323fe (diff)
patch 7.4.1976v7.4.1976
Problem: Number variables are not 64 bits while they could be. Solution: Add the num64 feature. (Ken Takata)
-rw-r--r--runtime/doc/eval.txt25
-rw-r--r--runtime/doc/various.txt1
-rw-r--r--src/Make_cyg_ming.mak2
-rw-r--r--src/Make_mvc.mak5
-rw-r--r--src/charset.c16
-rw-r--r--src/eval.c286
-rw-r--r--src/ex_cmds.c6
-rw-r--r--src/ex_getln.c2
-rw-r--r--src/feature.h4
-rw-r--r--src/fileio.c2
-rw-r--r--src/fold.c2
-rw-r--r--src/json.c12
-rw-r--r--src/message.c67
-rw-r--r--src/misc1.c2
-rw-r--r--src/misc2.c2
-rw-r--r--src/ops.c86
-rw-r--r--src/option.c4
-rw-r--r--src/proto/charset.pro2
-rw-r--r--src/proto/eval.pro16
-rw-r--r--src/quickfix.c10
-rw-r--r--src/structs.h24
-rw-r--r--src/testdir/test_viml.vim28
-rw-r--r--src/version.c7
23 files changed, 384 insertions, 227 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 4d9df8936a..8be5ee49ad 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.4. Last change: 2016 Jun 06
+*eval.txt* For Vim version 7.4. Last change: 2016 Jul 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -40,6 +40,8 @@ done, the features in this document are not available. See |+eval| and
There are nine 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
Float A floating point number. |floating-point-format| *Float*
@@ -888,6 +890,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.
@@ -3566,17 +3573,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
{only available when compiled with the |+float| feature}
@@ -7655,7 +7664,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
@@ -7842,6 +7854,7 @@ multi_lang Compiled with support for multiple languages.
mzscheme Compiled with MzScheme interface |mzscheme|.
netbeans_enabled Compiled with support for |netbeans| and connected.
netbeans_intg Compiled with support for |netbeans|.
+num64 Compiled with 64-bit |Number| support.
ole Compiled with OLE automation support for Win32.
os2 OS/2 version of Vim.
packages Compiled with |packages| support.
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 067ae6e6ff..31f1a1bd7c 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -390,6 +390,7 @@ N *+multi_lang* non-English language support |multi-lang|
m *+mzscheme* Mzscheme interface |mzscheme|
m *+mzscheme/dyn* Mzscheme interface |mzscheme-dynamic| |/dyn|
m *+netbeans_intg* |netbeans|
+ *+num64* 64-bit Number support |Number|
m *+ole* Win32 GUI only: |ole-interface|
N *+packages* Loading |packages|
N *+path_extra* Up/downwards search in 'path' and 'tags'
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index 86bbc3e586..490ae0b78a 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -379,7 +379,7 @@ endif # RUBY
# Any other defines can be included here.
DEF_GUI=-DFEAT_GUI_W32 -DFEAT_CLIPBOARD
DEFINES=-DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \
- -DHAVE_PATHDEF -DFEAT_$(FEATURES)
+ -DHAVE_PATHDEF -DFEAT_$(FEATURES) -DHAVE_STDINT_H
ifeq ($(ARCH),x86-64)
DEFINES+=-DMS_WIN64
endif
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index 5687f0999f..b1a643c426 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -501,6 +501,11 @@ OPTFLAG = $(OPTFLAG) /GL
CFLAGS=$(CFLAGS) $(WP64CHECK)
!endif
+# VC10 or later has stdint.h.
+!if $(MSVC_MAJOR) >= 10
+CFLAGS = $(CFLAGS) -DHAVE_STDINT_H
+!endif
+
# Static code analysis generally available starting with VS2012 (VC11) or
# Windows SDK 7.1 (VC10)
!if ("$(ANALYZE)" == "yes") && ($(MSVC_MAJOR) >= 10)
diff --git a/src/charset.c b/src/charset.c
index e008399e15..9fcd88cb9e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1836,14 +1836,14 @@ vim_str2nr(
is bin */
int *len, /* return: detected length of number */
int what, /* what numbers to recognize */
- long *nptr, /* return: signed result */
- unsigned long *unptr, /* return: unsigned result */
+ varnumber_T *nptr, /* return: signed result */
+ uvarnumber_T *unptr, /* return: unsigned result */
int maxlen) /* max length of string to check */
{
char_u *ptr = start;
int pre = 0; /* default is decimal */
int negative = FALSE;
- unsigned long un = 0;
+ uvarnumber_T un = 0;
int n;
if (ptr[0] == '-')
@@ -1912,7 +1912,7 @@ vim_str2nr(
/* 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;
@@ -1925,7 +1925,7 @@ vim_str2nr(
n += 2; /* skip over "0x" */
while (vim_isxdigit(*ptr))
{
- un = 16 * un + (unsigned long)hex2nr(*ptr);
+ un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
++ptr;
if (n++ == maxlen)
break;
@@ -1936,7 +1936,7 @@ vim_str2nr(
/* decimal */
while (VIM_ISDIGIT(*ptr))
{
- un = 10 * un + (unsigned long)(*ptr - '0');
+ un = 10 * un + (uvarnumber_T)(*ptr - '0');
++ptr;
if (n++ == maxlen)
break;
@@ -1950,9 +1950,9 @@ vim_str2nr(
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;
}
if (unptr != NULL)
*unptr = un;
diff --git a/src/eval.c b/src/eval.c
index 59a767a0c3..41abe37d9f 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1376,7 +1376,7 @@ eval_to_bool(
int skip) /* only parse, don't execute */
{
typval_T tv;
- int retval = FALSE;
+ varnumber_T retval = FALSE;
if (skip)
++emsg_skip;
@@ -1394,7 +1394,7 @@ eval_to_bool(
if (skip)
--emsg_skip;
- return retval;
+ return (int)retval;
}
/*
@@ -1519,11 +1519,11 @@ eval_to_string_safe(
* Evaluates "expr" silently.
* Returns -1 for an error.
*/
- int
+ varnumber_T
eval_to_number(char_u *expr)
{
typval_T rettv;
- int retval;
+ varnumber_T retval;
char_u *p = skipwhite(expr);
++emsg_off;
@@ -1628,7 +1628,7 @@ get_spellword(list_T *list, char_u **pp)
li = li->li_next;
if (li == NULL)
return -1;
- return get_tv_number(&li->li_tv);
+ return (int)get_tv_number(&li->li_tv);
}
#endif
@@ -1669,7 +1669,7 @@ call_vim_function(
typval_T *rettv)
{
typval_T *argvars;
- long n;
+ varnumber_T n;
int len;
int i;
int doesrange;
@@ -1735,7 +1735,7 @@ 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,
@@ -1743,7 +1743,7 @@ call_func_retnr(
int safe) /* use the sandbox */
{
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)
@@ -1880,7 +1880,7 @@ prof_child_exit(
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);
@@ -1915,7 +1915,7 @@ eval_foldexpr(char_u *arg, int *cp)
--sandbox;
--textlock;
- return retval;
+ return (int)retval;
}
#endif
@@ -2480,7 +2480,7 @@ ex_let_one(
c1 = *p;
*p = NUL;
- n = get_tv_number(tv);
+ n = (long)get_tv_number(tv);
s = get_tv_string_chk(tv); /* != NULL if number or string */
if (s != NULL && op != NULL && *op != '=')
{
@@ -2888,7 +2888,8 @@ get_lval(
lp->ll_n1 = 0;
else
{
- lp->ll_n1 = get_tv_number(&var1); /* is number or string */
+ lp->ll_n1 = (long)get_tv_number(&var1);
+ /* is number or string */
clear_tv(&var1);
}
lp->ll_dict = NULL;
@@ -2919,7 +2920,8 @@ get_lval(
*/
if (lp->ll_range && !lp->ll_empty2)
{
- lp->ll_n2 = get_tv_number(&var2); /* is number or string */
+ lp->ll_n2 = (long)get_tv_number(&var2);
+ /* is number or string */
clear_tv(&var2);
if (lp->ll_n2 < 0)
{
@@ -3117,7 +3119,7 @@ set_var_lval(
static int
tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
{
- long n;
+ varnumber_T n;
char_u numbuf[NUMBUFLEN];
char_u *s;
@@ -4468,7 +4470,7 @@ 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;
char_u *s1, *s2;
char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
int ic;
@@ -4766,7 +4768,7 @@ eval5(char_u **arg, typval_T *rettv, int evaluate)
typval_T var2;
typval_T var3;
int op;
- long n1, n2;
+ varnumber_T n1, n2;
#ifdef FEAT_FLOAT
float_T f1 = 0, f2 = 0;
#endif
@@ -4951,7 +4953,7 @@ eval6(
{
typval_T var2;
int op;
- long n1, n2;
+ varnumber_T n1, n2;
#ifdef FEAT_FLOAT
int use_float = FALSE;
float_T f1 = 0, f2;
@@ -5072,12 +5074,21 @@ eval6(
{
if (n2 == 0) /* give an error message? */
{
+#ifdef FEAT_NUM64
+ if (n1 == 0)
+ n1 = -0x7fffffffffffffff - 1; /* similar to NaN */
+ else if (n1 < 0)
+ n1 = -0x7fffffffffffffff;
+ else
+ n1 = 0x7fffffffffffffff;
+#else
if (n1 == 0)
n1 = -0x7fffffffL - 1L; /* similar to NaN */
else if (n1 < 0)
n1 = -0x7fffffffL;
else
n1 = 0x7fffffffL;
+#endif
}
else
n1 = n1 / n2;
@@ -5131,7 +5142,7 @@ eval7(
int evaluate,
int want_string UNUSED) /* after "." operator */
{
- long n;
+ varnumber_T n;
int len;
char_u *s;
char_u *start_leader, *end_leader;
@@ -5356,7 +5367,7 @@ eval7(
if (ret == OK && evaluate && end_leader > start_leader)
{
int error = FALSE;
- int val = 0;
+ varnumber_T val = 0;
#ifdef FEAT_FLOAT
float_T f = 0.0;
@@ -6525,7 +6536,7 @@ list_find_nr(
*errorp = TRUE;
return -1L;
}
- return get_tv_number_chk(&li->li_tv, errorp);
+ return (long)get_tv_number_chk(&li->li_tv, errorp);
}
/*
@@ -7770,7 +7781,7 @@ dict_add(dict_T *d, dictitem_T *item)
dict_add_nr_str(
dict_T *d,
char *key,
- long nr,
+ varnumber_T nr,
char_u *str)
{
dictitem_T *item;
@@ -7894,7 +7905,7 @@ get_dict_string(dict_T *d, char_u *key, int save)
* Get a number item from a dictionary.
* Returns 0 if the entry doesn't exist.
*/
- long
+ varnumber_T
get_dict_number(dict_T *d, char_u *key)
{
dictitem_T *di;
@@ -9612,7 +9623,7 @@ f_argv(typval_T *argvars, typval_T *rettv)
if (argvars[0].v_type != VAR_UNKNOWN)
{
- idx = get_tv_number_chk(&argvars[0], NULL);
+ idx = (int)get_tv_number_chk(&argvars[0], NULL);
if (idx >= 0 && idx < ARGCOUNT)
rettv->vval.v_string = vim_strsave(alist_name(&ARGLIST[idx]));
else
@@ -10012,7 +10023,7 @@ f_browse(typval_T *argvars UNUSED, typval_T *rettv)
char_u buf2[NUMBUFLEN];
int error = FALSE;
- save = get_tv_number_chk(&argvars[0], &error);
+ save = (int)get_tv_number_chk(&argvars[0], &error);
title = get_tv_string_chk(&argvars[1]);
initdir = get_tv_string_buf_chk(&argvars[2], buf);
defname = get_tv_string_buf_chk(&argvars[3], buf2);
@@ -10290,7 +10301,7 @@ byteidx(typval_T *argvars, typval_T *rettv, int comp UNUSED)
char_u *t;
#endif
char_u *str;
- long idx;
+ varnumber_T idx;
str = get_tv_string_chk(&argvars[0]);
idx = get_tv_number_chk(&argvars[1], NULL);
@@ -10660,7 +10671,7 @@ f_char2nr(typval_T *argvars, typval_T *rettv)
int utf8 = 0;
if (argvars[1].v_type != VAR_UNKNOWN)
- utf8 = get_tv_number_chk(&argvars[1], NULL);
+ utf8 = (int)get_tv_number_chk(&argvars[1], NULL);
if (utf8)
rettv->vval.v_number = (*utf_ptr2char)(get_tv_string(&argvars[0]));
@@ -10783,7 +10794,7 @@ f_complete(typval_T *argvars, typval_T *rettv UNUSED)
return;
}
- startcol = get_tv_number_chk(&argvars[0], NULL);
+ startcol = (int)get_tv_number_chk(&argvars[0], NULL);
if (startcol <= 0)
return;
@@ -10840,7 +10851,7 @@ f_confirm(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
error = TRUE;
if (argvars[2].v_type != VAR_UNKNOWN)
{
- def = get_tv_number_chk(&argvars[2], &error);
+ def = (int)get_tv_number_chk(&argvars[2], &error);
if (argvars[3].v_type != VAR_UNKNOWN)
{
typestr = get_tv_string_buf_chk(&argvars[3], buf2);
@@ -10933,10 +10944,10 @@ f_count(typval_T *argvars, typval_T *rettv)
{
int error = FALSE;
- ic = get_tv_number_chk(&argvars[2], &error);
+ ic = (int)get_tv_number_chk(&argvars[2], &error);
if (argvars[3].v_type != VAR_UNKNOWN)
{
- idx = get_tv_number_chk(&argvars[3], &error);
+ idx = (long)get_tv_number_chk(&argvars[3], &error);
if (!error)
{
li = list_find(l, idx);
@@ -10965,7 +10976,7 @@ f_count(typval_T *argvars, typval_T *rettv)
if (argvars[2].v_type != VAR_UNKNOWN)
{
- ic = get_tv_number_chk(&argvars[2], &error);
+ ic = (int)get_tv_number_chk(&argvars[2], &error);
if (argvars[3].v_type != VAR_UNKNOWN)
EMSG(_(e_invarg));
}
@@ -11055,10 +11066,10 @@ f_cursor(typval_T *argvars, typval_T *rettv)
else
{
line = get_tv_lnum(argvars);
- col = get_tv_number_chk(&argvars[1], NULL);
+ col = (long)get_tv_number_chk(&argvars[1], NULL);
#ifdef FEAT_VIRTUALEDIT
if (argvars[2].v_type != VAR_UNKNOWN)
- coladd = get_tv_number_chk(&argvars[2], NULL);
+ coladd = (long)get_tv_number_chk(&argvars[2], NULL);
#endif
}
if (line < 0 || col < 0
@@ -11096,7 +11107,7 @@ f_deepcopy(typval_T *argvars, typval_T *rettv)
int noref = 0;
if (argvars[1].v_type != VAR_UNKNOWN)
- noref = get_tv_number_chk(&argvars[1], NULL);
+ noref = (int)get_tv_number_chk(&argvars[1], NULL);
if (noref < 0 || noref > 1)
EMSG(_(e_invarg));
else
@@ -11604,7 +11615,7 @@ f_extend(typval_T *argvars, typval_T *rettv)
{
if (argvars[2].v_type != VAR_UNKNOWN)
{
- before = get_tv_number_chk(&argvars[2], &error);
+ before = (long)get_tv_number_chk(&argvars[2], &error);
if (error)
return; /* type error; errmsg already given */
@@ -11807,7 +11818,7 @@ findfilendir(
path = p;
if (argvars[2].v_type != VAR_UNKNOWN)
- count = get_tv_number_chk(&argvars[2], &error);
+ count = (int)get_tv_number_chk(&argvars[2], &error);
}
}
@@ -12043,12 +12054,21 @@ f_float2nr(typval_T *argvars, typval_T *rettv)
if (get_float_arg(argvars, &f) == OK)
{
+# ifdef FEAT_NUM64
+ if (f < -0x7fffffffffffffff)
+ rettv->vval.v_number = -0x7fffffffffffffff;
+ else if (f > 0x7fffffffffffffff)
+ rettv->vval.v_number = 0x7fffffffffffffff;
+ else
+ rettv->vval.v_number = (varnumber_T)f;
+# else
if (f < -0x7fffffff)
rettv->vval.v_number = -0x7fffffff;
else if (f > 0x7fffffff)
rettv->vval.v_number = 0x7fffffff;
else
rettv->vval.v_number = (varnumber_T)f;
+# endif
}
}
@@ -12511,7 +12531,7 @@ f_get(typval_T *argvars, typval_T *rettv)
{
int error = FALSE;
- li = list_find(l, get_tv_number_chk(&argvars[1], &error));
+ li = list_find(l, (long)get_tv_number_chk(&argvars[1], &error));
if (!error && li != NULL)
tv = &li->li_tv;
}
@@ -13333,9 +13353,9 @@ f_getreg(typval_T *argvars, typval_T *rettv)
error = strregname == NULL;
if (argvars[1].v_type != VAR_UNKNOWN)
{
- arg2 = get_tv_number_chk(&argvars[1], &error);
+ arg2 = (int)get_tv_number_chk(&argvars[1], &error);
if (!error && argvars[2].v_type != VAR_UNKNOWN)
- return_list = get_tv_number_chk(&argvars[2], &error);
+ return_list = (int)get_tv_number_chk(&argvars[2], &error);
}
}
else
@@ -13558,7 +13578,7 @@ find_win_by_nr(
#endif
int nr;
- nr = get_tv_number_chk(vp, NULL);
+ nr = (int)get_tv_number_chk(vp, NULL);
#ifdef FEAT_WINDOWS
if (nr < 0)
@@ -13601,7 +13621,7 @@ find_tabwin(
{
if (tvp->v_type != VAR_UNKNOWN)
{
- n = get_tv_number(tvp);
+ n = (long)get_tv_number(tvp);
if (n >= 0)
tp = find_tabpage(n);
}
@@ -14126,6 +14146,9 @@ f_has(typval_T *argvars, typval_T *rettv)
"mzscheme",
#endif
#endif
+#ifdef FEAT_NUM64
+ "num64",
+#endif
#ifdef FEAT_OLE
"ole",
#endif
@@ -14468,7 +14491,7 @@ f_hasmapto(typval_T *argvars, typval_T *rettv)
{
mode = get_tv_string_buf(&argvars[1], buf);
if (argvars[2].v_type != VAR_UNKNOWN)
- abbr = get_tv_number(&argvars[2]);
+ abbr = (int)get_tv_number(&argvars[2]);
}
if (map_to_exists(name, mode, abbr))
@@ -14696,10 +14719,10 @@ f_index(typval_T *argvars, typval_T *rettv)
/* Start at specified item. Use the cached index that list_find()
* sets, so that a negative number also works. */
- item = list_find(l, get_tv_number_chk(&argvars[2], &error));
+ item = list_find(l, (long)get_tv_number_chk(&argvars[2], &error));
idx = l->lv_idx;
if (argvars[3].v_type != VAR_UNKNOWN)
- ic = get_tv_number_chk(&argvars[3], &error);
+ ic = (int)get_tv_number_chk(&argvars[3], &error);
if (error)
item = NULL;
}
@@ -14983,7 +15006,7 @@ f_insert(typval_T *argvars, typval_T *rettv)
&& !tv_check_lock(l->lv_lock, (char_u *)N_("insert() argument"), TRUE))
{
if (argvars[2].v_type != VAR_UNKNOWN)
- before = get_tv_number_chk(&argvars[2], &error);
+ before = (long)get_tv_number_chk(&argvars[2], &error);
if (error)
return; /* type error; errmsg already given */
@@ -15588,9 +15611,9 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
which = get_tv_string_buf_chk(&argvars[1], buf);
if (argvars[2].v_type != VAR_UNKNOWN)
{
- abbr = get_tv_number(&argvars[2]);
+ abbr = (int)get_tv_number(&argvars[2]);
if (argvars[3].v_type != VAR_UNKNOWN)
- get_dict = get_tv_number(&argvars[3]);
+ get_dict = (int)get_tv_number(&argvars[3]);
}
}
else
@@ -15781,7 +15804,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, int type)
{
int error = FALSE;
- start = get_tv_number_chk(&argvars[2], &error);
+ start = (long)get_tv_number_chk(&argvars[2], &error);
if (error)
goto theend;
if (l != NULL)
@@ -15810,7 +15833,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, int type)
}
if (argvars[3].v_type != VAR_UNKNOWN)
- nth = get_tv_number_chk(&argvars[3], &error);
+ nth = (long)get_tv_number_chk(&argvars[3], &error);
if (error)
goto theend;
}
@@ -15969,10 +15992,10 @@ f_matchadd(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
return;
if (argvars[2].v_type != VAR_UNKNOWN)
{
- prio = get_tv_number_chk(&argvars[2], &error);
+ prio = (int)get_tv_number_chk(&argvars[2], &error);
if (argvars[3].v_type != VAR_UNKNOWN)
{
- id = get_tv_number_chk(&argvars[3], &error);
+ id = (int)get_tv_number_chk(&argvars[3], &error);
if (argvars[4].v_type != VAR_UNKNOWN)
{
if (argvars[4].v_type != VAR_DICT)
@@ -16032,10 +16055,10 @@ f_matchaddpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
if (argvars[2].v_type != VAR_UNKNOWN)
{
- prio = get_tv_number_chk(&argvars[2], &error);
+ prio = (int)get_tv_number_chk(&argvars[2], &error);
if (argvars[3].v_type != VAR_UNKNOWN)
{
- id = get_tv_number_chk(&argvars[3], &error);
+ id = (int)get_tv_number_chk(&argvars[3], &error);
if (argvars[4].v_type != VAR_UNKNOWN)
{
if (argvars[4].v_type != VAR_DICT)
@@ -16074,7 +16097,7 @@ f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
if (rettv_list_alloc(rettv) == OK)
{
#ifdef FEAT_SEARCH_EXTRA
- int id = get_tv_number(&argvars[0]);
+ int id = (int)get_tv_number(&argvars[0]);
matchitem_T *m;
if (id >= 1 && id <= 3)
@@ -16148,8 +16171,8 @@ static void max_min(typval_T *argvars, typval_T *rettv, int domax);
static void
max_min(typval_T *argvars, typval_T *rettv, int domax)
{
- long n = 0;
- long i;
+ varnumber_T n = 0;
+ varnumber_T i;
int error = FALSE;
if (argvars[0].v_type == VAR_LIST)
@@ -16285,7 +16308,7 @@ f_mkdir(typval_T *argvars, typval_T *rettv)
if (argvars[1].v_type != VAR_UNKNOWN)
{
if (argvars[2].v_type != VAR_UNKNOWN)
- prot = get_tv_number_chk(&argvars[2], NULL);
+ prot = (int)get_tv_number_chk(&argvars[2], NULL);
if (prot != -1 && STRCMP(get_tv_string(&argvars[1]), "p") == 0)
mkdir_recurse(dir, prot);
}
@@ -16428,7 +16451,7 @@ f_nr2char(typval_T *argvars, typval_T *rettv)
int utf8 = 0;
if (argvars[1].v_type != VAR_UNKNOWN)
- utf8 = get_tv_number_chk(&argvars[1], NULL);
+ utf8 = (int)get_tv_number_chk(&argvars[1], NULL);
if (utf8)
buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
else
@@ -16610,10 +16633,10 @@ f_pyeval(typval_T *argvars, typval_T *rettv)
static void
f_range(typval_T *argvars, typval_T *rettv)
{
- long start;
- long end;
- long stride = 1;
- long i;
+ varnumber_T start;
+ varnumber_T end;
+ varnumber_T stride = 1;
+ varnumber_T i;
int error = FALSE;
start = get_tv_number_chk(&argvars[0], &error);
@@ -16671,7 +16694,7 @@ f_readfile(typval_T *argvars, typval_T *rettv)
if (STRCMP(get_tv_string(&argvars[1]), "b") == 0)
binary = TRUE;
if (argvars[2].v_type != VAR_UNKNOWN)
- maxline = get_tv_number(&argvars[2]);
+ maxline = (long)get_tv_number(&argvars[2]);
}
if (rettv_list_alloc(rettv) == FAIL)
@@ -17244,7 +17267,7 @@ f_remove(typval_T *argvars, typval_T *rettv)
{
int error = FALSE;
- idx = get_tv_number_chk(&argvars[1], &error);
+ idx = (long)get_tv_number_chk(&argvars[1], &error);
if (error)
; /* type error: do nothing, errmsg already given */
else if ((item = list_find(l, idx)) == NULL)
@@ -17261,7 +17284,7 @@ f_remove(typval_T *argvars, typval_T *rettv)
else
{
/* Remove range of items, return list with values. */
- end = get_tv_number_chk(&argvars[2], &error);
+ end = (long)get_tv_number_chk(&argvars[2], &error);
if (error)
; /* type error: do nothing */
else if ((item2 = list_find(l, end)) == NULL)
@@ -17325,7 +17348,7 @@ f_repeat(typval_T *argvars, typval_T *rettv)
char_u *r;
int i;
- n = get_tv_number(&argvars[1]);
+ n = (int)get_tv_number(&argvars[1]);
if (argvars[0].v_type == VAR_LIST)
{
if (rettv_list_alloc(rettv) == OK && argvars[0].vval.v_list != NULL)
@@ -17696,13 +17719,13 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
/* Optional arguments: line number to stop searching and timeout. */
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN)
{
- lnum_stop = get_tv_number_chk(&argvars[2], NULL);
+ lnum_stop = (long)get_tv_number_chk(&argvars[2], NULL);
if (lnum_stop < 0)
goto theend;
#ifdef FEAT_RELTIME
if (argvars[3].v_type != VAR_UNKNOWN)
{
- time_limit = get_tv_number_chk(&argvars[3], NULL);
+ time_limit = (long)get_tv_number_chk(&argvars[3], NULL);
if (time_limit < 0)
goto theend;
}
@@ -17798,8 +17821,8 @@ f_screenattr(typval_T *argvars, typval_T *rettv)
int col;
int c;
- row = get_tv_number_chk(&argvars[0], NULL) - 1;
- col = get_tv_number_chk(&argvars[1], NULL) - 1;
+ row = (int)get_tv_number_chk(&argvars[0], NULL) - 1;
+ col = (int)get_tv_number_chk(&argvars[1], NULL) - 1;
if (row < 0 || row >= screen_Rows
|| col < 0 || col >= screen_Columns)
c = -1;
@@ -17819,8 +17842,8 @@ f_screenchar(typval_T *argvars, typval_T *rettv)
int off;
int c;
- row = get_tv_number_chk(&argvars[0], NULL) - 1;
- col = get_tv_number_chk(&argvars[1], NULL) - 1;
+ row = (int)get_tv_number_chk(&argvars[0], NULL) - 1;
+ col = (int)get_tv_number_chk(&argvars[1], NULL) - 1;
if (row < 0 || row >= screen_Rows
|| col < 0 || col >= screen_Columns)
c = -1;
@@ -17884,9 +17907,9 @@ f_searchdecl(typval_T *argvars, typval_T *rettv)
name = get_tv_string_chk(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
- locally = get_tv_number_chk(&argvars[1], &error) == 0;
+ locally = (int)get_tv_number_chk(&argvars[1], &error) == 0;
if (!error && argvars[2].v_type != VAR_UNKNOWN)
- thisblock = get_tv_number_chk(&argvars[2], &error) != 0;
+ thisblock = (int)get_tv_number_chk(&argvars[2], &error) != 0;
}
if (!error && name != NULL)
rettv->vval.v_number = find_decl(name, (int)STRLEN(name),
@@ -17946,13 +17969,13 @@ searchpair_cmn(typval_T *argvars, pos_T *match_pos)
skip = get_tv_string_buf_chk(&argvars[4], nbuf3);
if (argvars[5].v_type != VAR_UNKNOWN)
{
- lnum_stop = get_tv_number_chk(&argvars[5], NULL);
+ lnum_stop = (long)get_tv_number_chk(&argvars[5], NULL);
if (lnum_stop < 0)
goto theend;
#ifdef FEAT_RELTIME
if (argvars[6].v_type != VAR_UNKNOWN)
{
- time_limit = get_tv_number_chk(&argvars[6], NULL);
+ time_limit = (long)get_tv_number_chk(&argvars[6], NULL);
if (time_limit < 0)
goto theend;
}
@@ -18267,7 +18290,7 @@ f_setbufvar(typval_T *argvars, typval_T *rettv UNUSED)
int error = FALSE;
++varname;
- numval = get_tv_number_chk(varp, &error);
+ numval = (long)get_tv_number_chk(varp, &error);
strval = get_tv_string_buf_chk(varp, nbuf);
if (!error && strval != NULL)
set_option_value(varname, numval, strval, OPT_LOCAL);
@@ -18323,7 +18346,7 @@ f_setcharsearch(typval_T *argvars, typval_T *rettv UNUSED)
di = dict_find(d, (char_u *)"forward", -1);
if (di != NULL)
- set_csearch_direction(get_tv_number(&di->di_tv)
+ set_csearch_direction((int)get_tv_number(&di->di_tv)
? FORWARD : BACKWARD);
di = dict_find(d, (char_u *)"until", -1);
@@ -18916,7 +18939,7 @@ setwinvar(typval_T *argvars, typval_T *rettv UNUSED, int off)
int error = FALSE;
++varname;
- numval = get_tv_number_chk(varp, &error);
+ numval = (long)get_tv_number_chk(varp, &error);
strval = get_tv_string_buf_chk(varp, nbuf);
if (!error && strval != NULL)
set_option_value(varname, numval, strval, OPT_LOCAL);
@@ -19083,8 +19106,8 @@ item_compare(const void *s1, const void *s2)
if (sortinfo->item_compare_numbers)
{
- long v1 = get_tv_number(tv1);
- long v2 = get_tv_number(tv2);
+ varnumber_T v1 = get_tv_number(tv1);
+ varnumber_T v2 = get_tv_number(tv2);
return v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
}
@@ -19190,7 +19213,7 @@ item_compare2(const void *s1, const void *s2)
if (res == FAIL)
res = ITEM_COMPARE_FAIL;
else
- res = get_tv_number_chk(&rettv, &sortinfo->item_compare_func_err);
+ res = (int)get_tv_number_chk(&rettv, &sortinfo->item_compare_func_err);
if (sortinfo->item_compare_func_err)
res = ITEM_COMPARE_FAIL; /* return value has wrong type */
clear_tv(&rettv);
@@ -19259,7 +19282,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
{
int error = FALSE;
- i = get_tv_number_chk(&argvars[1], &error);
+ i = (long)get_tv_number_chk(&argvars[1], &error);
if (error)
goto theend; /* type error; errmsg already given */
if (i == 1)
@@ -19516,12 +19539,12 @@ f_spellsuggest(typval_T *argvars UNUSED, typval_T *rettv)
str = get_tv_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
- maxcount = get_tv_number_chk(&argvars[1], &typeerr);
+ maxcount = (int)get_tv_number_chk(&argvars[1], &typeerr);
if (maxcount <= 0)
return;
if (argvars[2].v_type != VAR_UNKNOWN)
{
- need_capital = get_tv_number_chk(&argvars[2], &typeerr);
+ need_capital = (int)get_tv_number_chk(&argvars[2], &typeerr);
if (typeerr)
return;
}
@@ -19576,7 +19599,7 @@ f_split(typval_T *argvars, typval_T *rettv)
if (pat == NULL)
typeerr = TRUE;
if (argvars[2].v_type != VAR_UNKNOWN)
- keepempty = get_tv_number_chk(&argvars[2], &typeerr);
+ keepempty = (int)get_tv_number_chk(&argvars[2], &typeerr);
}
if (pat == NULL || *pat == NUL)
pat = (char_u *)"[\\x01- ]\\+";
@@ -19669,12 +19692,12 @@ f_str2nr(typval_T *argvars, typval_T *rettv)
{
int base = 10;
char_u *p;
- long n;
+ varnumber_T n;
int