int skip) /* only parse, don't execute */
{
typval_T tv;
- int retval = FALSE;
+ varnumber_T retval = FALSE;
if (skip)
++emsg_skip;
if (skip)
--emsg_skip;
- return retval;
+ return (int)retval;
}
/*
* 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;
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
typval_T *rettv)
{
typval_T *argvars;
- long n;
+ varnumber_T n;
int len;
int i;
int doesrange;
* 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,
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)
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);
--sandbox;
--textlock;
- return retval;
+ return (int)retval;
}
#endif
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 != '=')
{
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;
*/
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)
{
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;
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;
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
{
typval_T var2;
int op;
- long n1, n2;
+ varnumber_T n1, n2;
#ifdef FEAT_FLOAT
int use_float = FALSE;
float_T f1 = 0, f2;
{
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;
int evaluate,
int want_string UNUSED) /* after "." operator */
{
- long n;
+ varnumber_T n;
int len;
char_u *s;
char_u *start_leader, *end_leader;
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;
*errorp = TRUE;
return -1L;
}
- return get_tv_number_chk(&li->li_tv, errorp);
+ return (long)get_tv_number_chk(&li->li_tv, errorp);
}
/*
dict_add_nr_str(
dict_T *d,
char *key,
- long nr,
+ varnumber_T nr,
char_u *str)
{
dictitem_T *item;
* 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;
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
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);
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);
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]));
return;
}
- startcol = get_tv_number_chk(&argvars[0], NULL);
+ startcol = (int)get_tv_number_chk(&argvars[0], NULL);
if (startcol <= 0)
return;
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);
{
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);
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));
}
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
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
{
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 */
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);
}
}
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
}
}
{
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;
}
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
#endif
int nr;
- nr = get_tv_number_chk(vp, NULL);
+ nr = (int)get_tv_number_chk(vp, NULL);
#ifdef FEAT_WINDOWS
if (nr < 0)
{
if (tvp->v_type != VAR_UNKNOWN)
{
- n = get_tv_number(tvp);
+ n = (long)get_tv_number(tvp);
if (n >= 0)
tp = find_tabpage(n);
}
"mzscheme",
#endif
#endif
+#ifdef FEAT_NUM64
+ "num64",
+#endif
#ifdef FEAT_OLE
"ole",
#endif
{
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))
/* 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;
}
&& !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 */
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
{
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)
}
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;
}
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)
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)
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)
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)
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);
}
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
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);
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)
{
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)
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)
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)
/* 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;
}
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;
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;
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),
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;
}
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);
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);
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);
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;
}
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);
{
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)
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;
}
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- ]\\+";
{
int base = 10;
char_u *p;
- long n;
+ varnumber_T n;
int what;
if (argvars[1].v_type != VAR_UNKNOWN)
{
- base = get_tv_number(&argvars[1]);
+ base = (int)get_tv_number(&argvars[1]);
if (base != 2 && base != 8 && base != 10 && base != 16)
{
EMSG(_(e_invarg));
if (str == NULL)
return;
len = (int)STRLEN(str);
- charidx = get_tv_number_chk(&argvars[1], &error);
+ charidx = (int)get_tv_number_chk(&argvars[1], &error);
if (error)
return;
#ifdef FEAT_MBYTE
{
int error = FALSE;
- start_idx = get_tv_number_chk(&argvars[2], &error);
+ start_idx = (int)get_tv_number_chk(&argvars[2], &error);
if (error || start_idx >= (int)STRLEN(haystack))
return;
if (start_idx >= 0)
#endif
if (argvars[1].v_type != VAR_UNKNOWN)
- skipcc = get_tv_number_chk(&argvars[1], NULL);
+ skipcc = (int)get_tv_number_chk(&argvars[1], NULL);
if (skipcc < 0 || skipcc > 1)
EMSG(_(e_invarg));
else
int col = 0;
if (argvars[1].v_type != VAR_UNKNOWN)
- col = get_tv_number(&argvars[1]);
+ col = (int)get_tv_number(&argvars[1]);
rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s) - col);
}
p = get_tv_string(&argvars[0]);
slen = (int)STRLEN(p);
- nchar = get_tv_number_chk(&argvars[1], &error);
+ nchar = (int)get_tv_number_chk(&argvars[1], &error);
if (!error)
{
if (nchar > 0)
nbyte = nchar;
if (argvars[2].v_type != VAR_UNKNOWN)
{
- charlen = get_tv_number(&argvars[2]);
+ charlen = (int)get_tv_number(&argvars[2]);
while (charlen > 0 && nbyte + len < slen)
{
int off = nbyte + len;
p = get_tv_string(&argvars[0]);
slen = (int)STRLEN(p);
- n = get_tv_number_chk(&argvars[1], &error);
+ n = (int)get_tv_number_chk(&argvars[1], &error);
if (error)
len = 0;
else if (argvars[2].v_type != VAR_UNKNOWN)
- len = get_tv_number(&argvars[2]);
+ len = (int)get_tv_number(&argvars[2]);
else
len = slen - n; /* default len: all bytes that are available. */
if (argvars[2].v_type != VAR_UNKNOWN)
{
/* Third argument: upper limit for index */
- end_idx = get_tv_number_chk(&argvars[2], NULL);
+ end_idx = (int)get_tv_number_chk(&argvars[2], NULL);
if (end_idx < 0)
return; /* can never find a match */
}
return;
error = FALSE;
if (argvars[1].v_type != VAR_UNKNOWN)
- retList = get_tv_number_chk(&argvars[1], &error);
+ retList = (int)get_tv_number_chk(&argvars[1], &error);
if (error)
return;
{
int id = 0;
#ifdef FEAT_SYN_HL
- long lnum;
- long col;
+ linenr_T lnum;
+ colnr_T col;
int trans;
int transerr = FALSE;
lnum = get_tv_lnum(argvars); /* -1 on type error */
- col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */
- trans = get_tv_number_chk(&argvars[2], &transerr);
+ col = (linenr_T)get_tv_number(&argvars[1]) - 1; /* -1 on type error */
+ trans = (int)get_tv_number_chk(&argvars[2], &transerr);
if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
&& col >= 0 && col < (long)STRLEN(ml_get(lnum)))
char_u modebuf[NUMBUFLEN];
int modec;
- id = get_tv_number(&argvars[0]);
+ id = (int)get_tv_number(&argvars[0]);
what = get_tv_string(&argvars[1]);
if (argvars[2].v_type != VAR_UNKNOWN)
{
int id;
#ifdef FEAT_SYN_HL
- id = get_tv_number(&argvars[0]);
+ id = (int)get_tv_number(&argvars[0]);
if (id > 0)
id = syn_get_final_id(id);
f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv)
{
#if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
- long lnum;
- long col;
+ linenr_T lnum;
+ colnr_T col;
int syntax_flags = 0;
int cchar;
int matchid = 0;
#if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
lnum = get_tv_lnum(argvars); /* -1 on type error */
- col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */
+ col = (colnr_T)get_tv_number(&argvars[1]) - 1; /* -1 on type error */
vim_memset(str, NUL, sizeof(str));
f_synstack(typval_T *argvars UNUSED, typval_T *rettv)
{
#ifdef FEAT_SYN_HL
- long lnum;
- long col;
+ linenr_T lnum;
+ colnr_T col;
int i;
int id;
#endif
#ifdef FEAT_SYN_HL
lnum = get_tv_lnum(argvars); /* -1 on type error */
- col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */
+ col = (colnr_T)get_tv_number(&argvars[1]) - 1; /* -1 on type error */
if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
&& col >= 0 && col <= (long)STRLEN(ml_get(lnum))
static void
f_test_disable_char_avail(typval_T *argvars, typval_T *rettv UNUSED)
{
- disable_char_avail_for_testing = get_tv_number(&argvars[0]);
+ disable_char_avail_for_testing = (int)get_tv_number(&argvars[0]);
}
/*
static void
f_timer_start(typval_T *argvars, typval_T *rettv)
{
- long msec = get_tv_number(&argvars[0]);
+ long msec = (long)get_tv_number(&argvars[0]);
timer_T *timer;
int repeat = 0;
char_u *callback;
EMSG(_(e_number_exp));
return;
}
- timer = find_timer(get_tv_number(&argvars[0]));
+ timer = find_timer((int)get_tv_number(&argvars[0]));
if (timer != NULL)
stop_timer(timer);
}
else
{
if (dict_find(dict, (char_u *)"lnum", -1) != NULL)
- curwin->w_cursor.lnum = get_dict_number(dict, (char_u *)"lnum");
+ curwin->w_cursor.lnum = (linenr_T)get_dict_number(dict, (char_u *)"lnum");
if (dict_find(dict, (char_u *)"col", -1) != NULL)
- curwin->w_cursor.col = get_dict_number(dict, (char_u *)"col");
+ curwin->w_cursor.col = (colnr_T)get_dict_number(dict, (char_u *)"col");
#ifdef FEAT_VIRTUALEDIT
if (dict_find(dict, (char_u *)"coladd", -1) != NULL)
- curwin->w_cursor.coladd = get_dict_number(dict, (char_u *)"coladd");
+ curwin->w_cursor.coladd = (colnr_T)get_dict_number(dict, (char_u *)"coladd");
#endif
if (dict_find(dict, (char_u *)"curswant", -1) != NULL)
{
- curwin->w_curswant = get_dict_number(dict, (char_u *)"curswant");
+ curwin->w_curswant = (colnr_T)get_dict_number(dict, (char_u *)"curswant");
curwin->w_set_curswant = FALSE;
}
if (dict_find(dict, (char_u *)"topline", -1) != NULL)
- set_topline(curwin, get_dict_number(dict, (char_u *)"topline"));
+ set_topline(curwin, (linenr_T)get_dict_number(dict, (char_u *)"topline"));
#ifdef FEAT_DIFF
if (dict_find(dict, (char_u *)"topfill", -1) != NULL)
- curwin->w_topfill = get_dict_number(dict, (char_u *)"topfill");
+ curwin->w_topfill = (int)get_dict_number(dict, (char_u *)"topfill");
#endif
if (dict_find(dict, (char_u *)"leftcol", -1) != NULL)
- curwin->w_leftcol = get_dict_number(dict, (char_u *)"leftcol");
+ curwin->w_leftcol = (colnr_T)get_dict_number(dict, (char_u *)"leftcol");
if (dict_find(dict, (char_u *)"skipcol", -1) != NULL)
- curwin->w_skipcol = get_dict_number(dict, (char_u *)"skipcol");
+ curwin->w_skipcol = (colnr_T)get_dict_number(dict, (char_u *)"skipcol");
check_cursor();
win_new_height(curwin, curwin->w_height);
* Set number v: variable to "val".
*/
void
-set_vim_var_nr(int idx, long val)
+set_vim_var_nr(int idx, varnumber_T val)
{
vimvars[idx].vv_nr = val;
}
/*
* Get number v: variable value.
*/
- long
+ varnumber_T
get_vim_var_nr(int idx)
{
return vimvars[idx].vv_nr;
* caller of incompatible types: it sets *denote to TRUE if "denote"
* is not NULL or returns -1 otherwise.
*/
- long
+ varnumber_T
get_tv_number(typval_T *varp)
{
int error = FALSE;
return get_tv_number_chk(varp, &error); /* return 0L on error */
}
- long
+ varnumber_T
get_tv_number_chk(typval_T *varp, int *denote)
{
- long n = 0L;
+ varnumber_T n = 0L;
switch (varp->v_type)
{
case VAR_NUMBER:
- return (long)(varp->vval.v_number);
+ return varp->vval.v_number;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
EMSG(_("E805: Using a Float as a Number"));
typval_T rettv;
linenr_T lnum;
- lnum = get_tv_number_chk(&argvars[0], NULL);
+ lnum = (linenr_T)get_tv_number_chk(&argvars[0], NULL);
if (lnum == 0) /* no valid number, try using line() */
{
rettv.v_type = VAR_NUMBER;
f_line(argvars, &rettv);
- lnum = rettv.vval.v_number;
+ lnum = (linenr_T)rettv.vval.v_number;
clear_tv(&rettv);
}
return lnum;
&& argvars[0].vval.v_string[0] == '$'
&& buf != NULL)
return buf->b_ml.ml_line_count;
- return get_tv_number_chk(&argvars[0], NULL);
+ return (linenr_T)get_tv_number_chk(&argvars[0], NULL);
}
/*
switch (varp->v_type)
{
case VAR_NUMBER:
- sprintf((char *)buf, "%ld", (long)varp->vval.v_number);
+ vim_snprintf((char *)buf, NUMBUFLEN, "%lld",
+ (varnumber_T)varp->vval.v_number);
return buf;
case VAR_FUNC:
case VAR_PARTIAL:
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(
*/
if (use_sandbox)
++sandbox;
- r = eval_to_number(curbuf->b_p_fex);
+ r = (int)eval_to_number(curbuf->b_p_fex);
if (use_sandbox)
--sandbox;
char_u buf2[NUMBUFLEN];
int pre; /* 'X'/'x': hex; '0': octal; 'B'/'b': bin */
static int hexupper = FALSE; /* 0xABC */
- unsigned long n;
- long_u oldn;
+ uvarnumber_T n;
+ uvarnumber_T oldn;
char_u *ptr;
int c;
int todel;
oldn = n;
if (subtract)
- n -= (unsigned long)Prenum1;
+ n -= (uvarnumber_T)Prenum1;
else
- n += (unsigned long)Prenum1;
+ n += (uvarnumber_T)Prenum1;
/* handle wraparound for decimal numbers */
if (!pre)
{
{
if (n > oldn)
{
- n = 1 + (n ^ (unsigned long)-1);
+ n = 1 + (n ^ (uvarnumber_T)-1);
negative ^= TRUE;
}
}
/* add */
if (n < oldn)
{
- n = (n ^ (unsigned long)-1);
+ n = (n ^ (uvarnumber_T)-1);
negative ^= TRUE;
}
}
{
int i;
int bit = 0;
- int bits = sizeof(unsigned long) * 8;
+ int bits = sizeof(uvarnumber_T) * 8;
/* leading zeros */
for (bit = bits; bit > 0; bit--)
buf2[i] = '\0';
}
else if (pre == 0)
- sprintf((char *)buf2, "%lu", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", n);
else if (pre == '0')
- sprintf((char *)buf2, "%lo", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", n);
else if (pre && hexupper)
- sprintf((char *)buf2, "%lX", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", n);
else
- sprintf((char *)buf2, "%lx", n);
+ vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", n);
length -= (int)STRLEN(buf2);
/*
vim_memset(oap, 0, sizeof(oparg_T));
}
-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);
/*
* Count the number of bytes, characters and "words" in a line.
* case, eol_size will be added to the character count to account for
* the size of the EOL character.
*/
- static long
+ static varnumber_T
line_count_info(
char_u *line,
- long *wc,
- long *cc,
- long limit,
+ 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; )
char_u buf1[50];
char_u buf2[40];
linenr_T lnum;
- long byte_count = 0;
+ varnumber_T byte_count = 0;
#ifdef FEAT_MBYTE
- long bom_count = 0;
+ varnumber_T bom_count = 0;
#endif
- 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_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;
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. */
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count)
vim_snprintf((char *)IObuff, IOSIZE,
- _("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Bytes"),
+ _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
byte_count_cursor, byte_count);
else
vim_snprintf((char *)IObuff, IOSIZE,
- _("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Chars; %ld of %ld Bytes"),
+ _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count)
vim_snprintf((char *)IObuff, IOSIZE,
- _("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Byte %ld of %ld"),
+ _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"),
(char *)buf1, (char *)buf2,
(long)curwin->w_cursor.lnum,
(long)curbuf->b_ml.ml_line_count,
byte_count_cursor, byte_count);
else
vim_snprintf((char *)IObuff, IOSIZE,
- _("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Char %ld of %ld; Byte %ld of %ld"),
+ _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"),
(char *)buf1, (char *)buf2,
(long)curwin->w_cursor.lnum,
(long)curbuf->b_ml.ml_line_count,
#if defined(FEAT_EVAL)
if (dict != NULL)
{
- dict_add_nr_str(dict, "words", (long)word_count, NULL);
- dict_add_nr_str(dict, "chars", (long)char_count, NULL);
- dict_add_nr_str(dict, "bytes", (long)byte_count
+ dict_add_nr_str(dict, "words", word_count, NULL);
+ dict_add_nr_str(dict, "chars", char_count, NULL);
+ dict_add_nr_str(dict, "bytes", byte_count
# ifdef FEAT_MBYTE
+ bom_count
# endif
, NULL);
dict_add_nr_str(dict, VIsual_active ? "visual_bytes" : "cursor_bytes",
- (long)byte_count_cursor, NULL);
+ byte_count_cursor, NULL);
dict_add_nr_str(dict, VIsual_active ? "visual_chars" : "cursor_chars",
- (long)char_count_cursor, NULL);
+ char_count_cursor, NULL);
dict_add_nr_str(dict, VIsual_active ? "visual_words" : "cursor_words",
- (long)word_count_cursor, NULL);
+ word_count_cursor, NULL);
}
#endif
}