comparison src/eval.c @ 9389:32e34e574716 v7.4.1976

commit https://github.com/vim/vim/commit/22fcfad29276bd5f317faf516637dcd491b96a12 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 1 18:17:26 2016 +0200 patch 7.4.1976 Problem: Number variables are not 64 bits while they could be. Solution: Add the num64 feature. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Fri, 01 Jul 2016 18:30:07 +0200
parents f094d4085014
children cbf052ccb120
comparison
equal deleted inserted replaced
9388:404ac7af0e7e 9389:32e34e574716
1374 int *error, 1374 int *error,
1375 char_u **nextcmd, 1375 char_u **nextcmd,
1376 int skip) /* only parse, don't execute */ 1376 int skip) /* only parse, don't execute */
1377 { 1377 {
1378 typval_T tv; 1378 typval_T tv;
1379 int retval = FALSE; 1379 varnumber_T retval = FALSE;
1380 1380
1381 if (skip) 1381 if (skip)
1382 ++emsg_skip; 1382 ++emsg_skip;
1383 if (eval0(arg, &tv, nextcmd, !skip) == FAIL) 1383 if (eval0(arg, &tv, nextcmd, !skip) == FAIL)
1384 *error = TRUE; 1384 *error = TRUE;
1392 } 1392 }
1393 } 1393 }
1394 if (skip) 1394 if (skip)
1395 --emsg_skip; 1395 --emsg_skip;
1396 1396
1397 return retval; 1397 return (int)retval;
1398 } 1398 }
1399 1399
1400 /* 1400 /*
1401 * Top level evaluation function, returning a string. If "skip" is TRUE, 1401 * Top level evaluation function, returning a string. If "skip" is TRUE,
1402 * only parsing to "nextcmd" is done, without reporting errors. Return 1402 * only parsing to "nextcmd" is done, without reporting errors. Return
1517 /* 1517 /*
1518 * Top level evaluation function, returning a number. 1518 * Top level evaluation function, returning a number.
1519 * Evaluates "expr" silently. 1519 * Evaluates "expr" silently.
1520 * Returns -1 for an error. 1520 * Returns -1 for an error.
1521 */ 1521 */
1522 int 1522 varnumber_T
1523 eval_to_number(char_u *expr) 1523 eval_to_number(char_u *expr)
1524 { 1524 {
1525 typval_T rettv; 1525 typval_T rettv;
1526 int retval; 1526 varnumber_T retval;
1527 char_u *p = skipwhite(expr); 1527 char_u *p = skipwhite(expr);
1528 1528
1529 ++emsg_off; 1529 ++emsg_off;
1530 1530
1531 if (eval1(&p, &rettv, TRUE) == FAIL) 1531 if (eval1(&p, &rettv, TRUE) == FAIL)
1626 *pp = get_tv_string(&li->li_tv); 1626 *pp = get_tv_string(&li->li_tv);
1627 1627
1628 li = li->li_next; 1628 li = li->li_next;
1629 if (li == NULL) 1629 if (li == NULL)
1630 return -1; 1630 return -1;
1631 return get_tv_number(&li->li_tv); 1631 return (int)get_tv_number(&li->li_tv);
1632 } 1632 }
1633 #endif 1633 #endif
1634 1634
1635 /* 1635 /*
1636 * Top level evaluation function. 1636 * Top level evaluation function.
1667 int safe, /* use the sandbox */ 1667 int safe, /* use the sandbox */
1668 int str_arg_only, /* all arguments are strings */ 1668 int str_arg_only, /* all arguments are strings */
1669 typval_T *rettv) 1669 typval_T *rettv)
1670 { 1670 {
1671 typval_T *argvars; 1671 typval_T *argvars;
1672 long n; 1672 varnumber_T n;
1673 int len; 1673 int len;
1674 int i; 1674 int i;
1675 int doesrange; 1675 int doesrange;
1676 void *save_funccalp = NULL; 1676 void *save_funccalp = NULL;
1677 int ret; 1677 int ret;
1733 /* 1733 /*
1734 * Call vimL function "func" and return the result as a number. 1734 * Call vimL function "func" and return the result as a number.
1735 * Returns -1 when calling the function fails. 1735 * Returns -1 when calling the function fails.
1736 * Uses argv[argc] for the function arguments. 1736 * Uses argv[argc] for the function arguments.
1737 */ 1737 */
1738 long 1738 varnumber_T
1739 call_func_retnr( 1739 call_func_retnr(
1740 char_u *func, 1740 char_u *func,
1741 int argc, 1741 int argc,
1742 char_u **argv, 1742 char_u **argv,
1743 int safe) /* use the sandbox */ 1743 int safe) /* use the sandbox */
1744 { 1744 {
1745 typval_T rettv; 1745 typval_T rettv;
1746 long retval; 1746 varnumber_T retval;
1747 1747
1748 /* All arguments are passed as strings, no conversion to number. */ 1748 /* All arguments are passed as strings, no conversion to number. */
1749 if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL) 1749 if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
1750 return -1; 1750 return -1;
1751 1751
1878 */ 1878 */
1879 int 1879 int
1880 eval_foldexpr(char_u *arg, int *cp) 1880 eval_foldexpr(char_u *arg, int *cp)
1881 { 1881 {
1882 typval_T tv; 1882 typval_T tv;
1883 int retval; 1883 varnumber_T retval;
1884 char_u *s; 1884 char_u *s;
1885 int use_sandbox = was_set_insecurely((char_u *)"foldexpr", 1885 int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
1886 OPT_LOCAL); 1886 OPT_LOCAL);
1887 1887
1888 ++emsg_off; 1888 ++emsg_off;
1913 --emsg_off; 1913 --emsg_off;
1914 if (use_sandbox) 1914 if (use_sandbox)
1915 --sandbox; 1915 --sandbox;
1916 --textlock; 1916 --textlock;
1917 1917
1918 return retval; 1918 return (int)retval;
1919 } 1919 }
1920 #endif 1920 #endif
1921 1921
1922 /* 1922 /*
1923 * ":let" list all variable values 1923 * ":let" list all variable values
2478 char_u *s; 2478 char_u *s;
2479 2479
2480 c1 = *p; 2480 c1 = *p;
2481 *p = NUL; 2481 *p = NUL;
2482 2482
2483 n = get_tv_number(tv); 2483 n = (long)get_tv_number(tv);
2484 s = get_tv_string_chk(tv); /* != NULL if number or string */ 2484 s = get_tv_string_chk(tv); /* != NULL if number or string */
2485 if (s != NULL && op != NULL && *op != '=') 2485 if (s != NULL && op != NULL && *op != '=')
2486 { 2486 {
2487 opt_type = get_option_value(arg, &numval, 2487 opt_type = get_option_value(arg, &numval,
2488 &stringval, opt_flags); 2488 &stringval, opt_flags);
2886 */ 2886 */
2887 if (empty1) 2887 if (empty1)
2888 lp->ll_n1 = 0; 2888 lp->ll_n1 = 0;
2889 else 2889 else
2890 { 2890 {
2891 lp->ll_n1 = get_tv_number(&var1); /* is number or string */ 2891 lp->ll_n1 = (long)get_tv_number(&var1);
2892 /* is number or string */
2892 clear_tv(&var1); 2893 clear_tv(&var1);
2893 } 2894 }
2894 lp->ll_dict = NULL; 2895 lp->ll_dict = NULL;
2895 lp->ll_list = lp->ll_tv->vval.v_list; 2896 lp->ll_list = lp->ll_tv->vval.v_list;
2896 lp->ll_li = list_find(lp->ll_list, lp->ll_n1); 2897 lp->ll_li = list_find(lp->ll_list, lp->ll_n1);
2917 * When no index given: "lp->ll_empty2" is TRUE. 2918 * When no index given: "lp->ll_empty2" is TRUE.
2918 * Otherwise "lp->ll_n2" is set to the second index. 2919 * Otherwise "lp->ll_n2" is set to the second index.
2919 */ 2920 */
2920 if (lp->ll_range && !lp->ll_empty2) 2921 if (lp->ll_range && !lp->ll_empty2)
2921 { 2922 {
2922 lp->ll_n2 = get_tv_number(&var2); /* is number or string */ 2923 lp->ll_n2 = (long)get_tv_number(&var2);
2924 /* is number or string */
2923 clear_tv(&var2); 2925 clear_tv(&var2);
2924 if (lp->ll_n2 < 0) 2926 if (lp->ll_n2 < 0)
2925 { 2927 {
2926 ni = list_find(lp->ll_list, lp->ll_n2); 2928 ni = list_find(lp->ll_list, lp->ll_n2);
2927 if (ni == NULL) 2929 if (ni == NULL)
3115 * Returns OK or FAIL. 3117 * Returns OK or FAIL.
3116 */ 3118 */
3117 static int 3119 static int
3118 tv_op(typval_T *tv1, typval_T *tv2, char_u *op) 3120 tv_op(typval_T *tv1, typval_T *tv2, char_u *op)
3119 { 3121 {
3120 long n; 3122 varnumber_T n;
3121 char_u numbuf[NUMBUFLEN]; 3123 char_u numbuf[NUMBUFLEN];
3122 char_u *s; 3124 char_u *s;
3123 3125
3124 /* Can't do anything with a Funcref, Dict, v:true on the right. */ 3126 /* Can't do anything with a Funcref, Dict, v:true on the right. */
3125 if (tv2->v_type != VAR_FUNC && tv2->v_type != VAR_DICT 3127 if (tv2->v_type != VAR_FUNC && tv2->v_type != VAR_DICT
4466 char_u *p; 4468 char_u *p;
4467 int i; 4469 int i;
4468 exptype_T type = TYPE_UNKNOWN; 4470 exptype_T type = TYPE_UNKNOWN;
4469 int type_is = FALSE; /* TRUE for "is" and "isnot" */ 4471 int type_is = FALSE; /* TRUE for "is" and "isnot" */
4470 int len = 2; 4472 int len = 2;
4471 long n1, n2; 4473 varnumber_T n1, n2;
4472 char_u *s1, *s2; 4474 char_u *s1, *s2;
4473 char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN]; 4475 char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
4474 int ic; 4476 int ic;
4475 4477
4476 /* 4478 /*
4764 eval5(char_u **arg, typval_T *rettv, int evaluate) 4766 eval5(char_u **arg, typval_T *rettv, int evaluate)
4765 { 4767 {
4766 typval_T var2; 4768 typval_T var2;
4767 typval_T var3; 4769 typval_T var3;
4768 int op; 4770 int op;
4769 long n1, n2; 4771 varnumber_T n1, n2;
4770 #ifdef FEAT_FLOAT 4772 #ifdef FEAT_FLOAT
4771 float_T f1 = 0, f2 = 0; 4773 float_T f1 = 0, f2 = 0;
4772 #endif 4774 #endif
4773 char_u *s1, *s2; 4775 char_u *s1, *s2;
4774 char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN]; 4776 char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
4949 int evaluate, 4951 int evaluate,
4950 int want_string) /* after "." operator */ 4952 int want_string) /* after "." operator */
4951 { 4953 {
4952 typval_T var2; 4954 typval_T var2;
4953 int op; 4955 int op;
4954 long n1, n2; 4956 varnumber_T n1, n2;
4955 #ifdef FEAT_FLOAT 4957 #ifdef FEAT_FLOAT
4956 int use_float = FALSE; 4958 int use_float = FALSE;
4957 float_T f1 = 0, f2; 4959 float_T f1 = 0, f2;
4958 #endif 4960 #endif
4959 int error = FALSE; 4961 int error = FALSE;
5070 n1 = n1 * n2; 5072 n1 = n1 * n2;
5071 else if (op == '/') 5073 else if (op == '/')
5072 { 5074 {
5073 if (n2 == 0) /* give an error message? */ 5075 if (n2 == 0) /* give an error message? */
5074 { 5076 {
5077 #ifdef FEAT_NUM64
5078 if (n1 == 0)
5079 n1 = -0x7fffffffffffffff - 1; /* similar to NaN */
5080 else if (n1 < 0)
5081 n1 = -0x7fffffffffffffff;
5082 else
5083 n1 = 0x7fffffffffffffff;
5084 #else
5075 if (n1 == 0) 5085 if (n1 == 0)
5076 n1 = -0x7fffffffL - 1L; /* similar to NaN */ 5086 n1 = -0x7fffffffL - 1L; /* similar to NaN */
5077 else if (n1 < 0) 5087 else if (n1 < 0)
5078 n1 = -0x7fffffffL; 5088 n1 = -0x7fffffffL;
5079 else 5089 else
5080 n1 = 0x7fffffffL; 5090 n1 = 0x7fffffffL;
5091 #endif
5081 } 5092 }
5082 else 5093 else
5083 n1 = n1 / n2; 5094 n1 = n1 / n2;
5084 } 5095 }
5085 else 5096 else
5129 char_u **arg, 5140 char_u **arg,
5130 typval_T *rettv, 5141 typval_T *rettv,
5131 int evaluate, 5142 int evaluate,
5132 int want_string UNUSED) /* after "." operator */ 5143 int want_string UNUSED) /* after "." operator */
5133 { 5144 {
5134 long n; 5145 varnumber_T n;
5135 int len; 5146 int len;
5136 char_u *s; 5147 char_u *s;
5137 char_u *start_leader, *end_leader; 5148 char_u *start_leader, *end_leader;
5138 int ret = OK; 5149 int ret = OK;
5139 char_u *alias; 5150 char_u *alias;
5354 * Apply logical NOT and unary '-', from right to left, ignore '+'. 5365 * Apply logical NOT and unary '-', from right to left, ignore '+'.
5355 */ 5366 */
5356 if (ret == OK && evaluate && end_leader > start_leader) 5367 if (ret == OK && evaluate && end_leader > start_leader)
5357 { 5368 {
5358 int error = FALSE; 5369 int error = FALSE;
5359 int val = 0; 5370 varnumber_T val = 0;
5360 #ifdef FEAT_FLOAT 5371 #ifdef FEAT_FLOAT
5361 float_T f = 0.0; 5372 float_T f = 0.0;
5362 5373
5363 if (rettv->v_type == VAR_FLOAT) 5374 if (rettv->v_type == VAR_FLOAT)
5364 f = rettv->vval.v_float; 5375 f = rettv->vval.v_float;
6523 { 6534 {
6524 if (errorp != NULL) 6535 if (errorp != NULL)
6525 *errorp = TRUE; 6536 *errorp = TRUE;
6526 return -1L; 6537 return -1L;
6527 } 6538 }
6528 return get_tv_number_chk(&li->li_tv, errorp); 6539 return (long)get_tv_number_chk(&li->li_tv, errorp);
6529 } 6540 }
6530 6541
6531 /* 6542 /*
6532 * Get list item "l[idx - 1]" as a string. Returns NULL for failure. 6543 * Get list item "l[idx - 1]" as a string. Returns NULL for failure.
6533 */ 6544 */
7768 */ 7779 */
7769 int 7780 int
7770 dict_add_nr_str( 7781 dict_add_nr_str(
7771 dict_T *d, 7782 dict_T *d,
7772 char *key, 7783 char *key,
7773 long nr, 7784 varnumber_T nr,
7774 char_u *str) 7785 char_u *str)
7775 { 7786 {
7776 dictitem_T *item; 7787 dictitem_T *item;
7777 7788
7778 item = dictitem_alloc((char_u *)key); 7789 item = dictitem_alloc((char_u *)key);
7892 7903
7893 /* 7904 /*
7894 * Get a number item from a dictionary. 7905 * Get a number item from a dictionary.
7895 * Returns 0 if the entry doesn't exist. 7906 * Returns 0 if the entry doesn't exist.
7896 */ 7907 */
7897 long 7908 varnumber_T
7898 get_dict_number(dict_T *d, char_u *key) 7909 get_dict_number(dict_T *d, char_u *key)
7899 { 7910 {
7900 dictitem_T *di; 7911 dictitem_T *di;
7901 7912
7902 di = dict_find(d, key, -1); 7913 di = dict_find(d, key, -1);
9610 { 9621 {
9611 int idx; 9622 int idx;
9612 9623
9613 if (argvars[0].v_type != VAR_UNKNOWN) 9624 if (argvars[0].v_type != VAR_UNKNOWN)
9614 { 9625 {
9615 idx = get_tv_number_chk(&argvars[0], NULL); 9626 idx = (int)get_tv_number_chk(&argvars[0], NULL);
9616 if (idx >= 0 && idx < ARGCOUNT) 9627 if (idx >= 0 && idx < ARGCOUNT)
9617 rettv->vval.v_string = vim_strsave(alist_name(&ARGLIST[idx])); 9628 rettv->vval.v_string = vim_strsave(alist_name(&ARGLIST[idx]));
9618 else 9629 else
9619 rettv->vval.v_string = NULL; 9630 rettv->vval.v_string = NULL;
9620 rettv->v_type = VAR_STRING; 9631 rettv->v_type = VAR_STRING;
10010 char_u *defname; 10021 char_u *defname;
10011 char_u buf[NUMBUFLEN]; 10022 char_u buf[NUMBUFLEN];
10012 char_u buf2[NUMBUFLEN]; 10023 char_u buf2[NUMBUFLEN];
10013 int error = FALSE; 10024 int error = FALSE;
10014 10025
10015 save = get_tv_number_chk(&argvars[0], &error); 10026 save = (int)get_tv_number_chk(&argvars[0], &error);
10016 title = get_tv_string_chk(&argvars[1]); 10027 title = get_tv_string_chk(&argvars[1]);
10017 initdir = get_tv_string_buf_chk(&argvars[2], buf); 10028 initdir = get_tv_string_buf_chk(&argvars[2], buf);
10018 defname = get_tv_string_buf_chk(&argvars[3], buf2); 10029 defname = get_tv_string_buf_chk(&argvars[3], buf2);
10019 10030
10020 if (error || title == NULL || initdir == NULL || defname == NULL) 10031 if (error || title == NULL || initdir == NULL || defname == NULL)
10288 { 10299 {
10289 #ifdef FEAT_MBYTE 10300 #ifdef FEAT_MBYTE
10290 char_u *t; 10301 char_u *t;
10291 #endif 10302 #endif
10292 char_u *str; 10303 char_u *str;
10293 long idx; 10304 varnumber_T idx;
10294 10305
10295 str = get_tv_string_chk(&argvars[0]); 10306 str = get_tv_string_chk(&argvars[0]);
10296 idx = get_tv_number_chk(&argvars[1], NULL); 10307 idx = get_tv_number_chk(&argvars[1], NULL);
10297 rettv->vval.v_number = -1; 10308 rettv->vval.v_number = -1;
10298 if (str == NULL || idx < 0) 10309 if (str == NULL || idx < 0)
10658 if (has_mbyte) 10669 if (has_mbyte)
10659 { 10670 {
10660 int utf8 = 0; 10671 int utf8 = 0;
10661 10672
10662 if (argvars[1].v_type != VAR_UNKNOWN) 10673 if (argvars[1].v_type != VAR_UNKNOWN)
10663 utf8 = get_tv_number_chk(&argvars[1], NULL); 10674 utf8 = (int)get_tv_number_chk(&argvars[1], NULL);
10664 10675
10665 if (utf8) 10676 if (utf8)
10666 rettv->vval.v_number = (*utf_ptr2char)(get_tv_string(&argvars[0])); 10677 rettv->vval.v_number = (*utf_ptr2char)(get_tv_string(&argvars[0]));
10667 else 10678 else
10668 rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0])); 10679 rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0]));
10781 { 10792 {
10782 EMSG(_(e_invarg)); 10793 EMSG(_(e_invarg));
10783 return; 10794 return;
10784 } 10795 }
10785 10796
10786 startcol = get_tv_number_chk(&argvars[0], NULL); 10797 startcol = (int)get_tv_number_chk(&argvars[0], NULL);
10787 if (startcol <= 0) 10798 if (startcol <= 0)
10788 return; 10799 return;
10789 10800
10790 set_completion(startcol - 1, argvars[1].vval.v_list); 10801 set_completion(startcol - 1, argvars[1].vval.v_list);
10791 } 10802 }
10838 buttons = get_tv_string_buf_chk(&argvars[1], buf); 10849 buttons = get_tv_string_buf_chk(&argvars[1], buf);
10839 if (buttons == NULL) 10850 if (buttons == NULL)
10840 error = TRUE; 10851 error = TRUE;
10841 if (argvars[2].v_type != VAR_UNKNOWN) 10852 if (argvars[2].v_type != VAR_UNKNOWN)
10842 { 10853 {
10843 def = get_tv_number_chk(&argvars[2], &error); 10854 def = (int)get_tv_number_chk(&argvars[2], &error);
10844 if (argvars[3].v_type != VAR_UNKNOWN) 10855 if (argvars[3].v_type != VAR_UNKNOWN)
10845 { 10856 {
10846 typestr = get_tv_string_buf_chk(&argvars[3], buf2); 10857 typestr = get_tv_string_buf_chk(&argvars[3], buf2);
10847 if (typestr == NULL) 10858 if (typestr == NULL)
10848 error = TRUE; 10859 error = TRUE;
10931 li = l->lv_first; 10942 li = l->lv_first;
10932 if (argvars[2].v_type != VAR_UNKNOWN) 10943 if (argvars[2].v_type != VAR_UNKNOWN)
10933 { 10944 {
10934 int error = FALSE; 10945 int error = FALSE;
10935 10946
10936 ic = get_tv_number_chk(&argvars[2], &error); 10947 ic = (int)get_tv_number_chk(&argvars[2], &error);
10937 if (argvars[3].v_type != VAR_UNKNOWN) 10948 if (argvars[3].v_type != VAR_UNKNOWN)
10938 { 10949 {
10939 idx = get_tv_number_chk(&argvars[3], &error); 10950 idx = (long)get_tv_number_chk(&argvars[3], &error);
10940 if (!error) 10951 if (!error)
10941 { 10952 {
10942 li = list_find(l, idx); 10953 li = list_find(l, idx);
10943 if (li == NULL) 10954 if (li == NULL)
10944 EMSGN(_(e_listidx), idx); 10955 EMSGN(_(e_listidx), idx);
10963 { 10974 {
10964 int error = FALSE; 10975 int error = FALSE;
10965 10976
10966 if (argvars[2].v_type != VAR_UNKNOWN) 10977 if (argvars[2].v_type != VAR_UNKNOWN)
10967 { 10978 {
10968 ic = get_tv_number_chk(&argvars[2], &error); 10979 ic = (int)get_tv_number_chk(&argvars[2], &error);
10969 if (argvars[3].v_type != VAR_UNKNOWN) 10980 if (argvars[3].v_type != VAR_UNKNOWN)
10970 EMSG(_(e_invarg)); 10981 EMSG(_(e_invarg));
10971 } 10982 }
10972 10983
10973 todo = error ? 0 : (int)d->dv_hashtab.ht_used; 10984 todo = error ? 0 : (int)d->dv_hashtab.ht_used;
11053 } 11064 }
11054 } 11065 }
11055 else 11066 else
11056 { 11067 {
11057 line = get_tv_lnum(argvars); 11068 line = get_tv_lnum(argvars);
11058 col = get_tv_number_chk(&argvars[1], NULL); 11069 col = (long)get_tv_number_chk(&argvars[1], NULL);
11059 #ifdef FEAT_VIRTUALEDIT 11070 #ifdef FEAT_VIRTUALEDIT
11060 if (argvars[2].v_type != VAR_UNKNOWN) 11071 if (argvars[2].v_type != VAR_UNKNOWN)
11061 coladd = get_tv_number_chk(&argvars[2], NULL); 11072 coladd = (long)get_tv_number_chk(&argvars[2], NULL);
11062 #endif 11073 #endif
11063 } 11074 }
11064 if (line < 0 || col < 0 11075 if (line < 0 || col < 0
11065 #ifdef FEAT_VIRTUALEDIT 11076 #ifdef FEAT_VIRTUALEDIT
11066 || coladd < 0 11077 || coladd < 0
11094 f_deepcopy(typval_T *argvars, typval_T *rettv) 11105 f_deepcopy(typval_T *argvars, typval_T *rettv)
11095 { 11106 {
11096 int noref = 0; 11107 int noref = 0;
11097 11108
11098 if (argvars[1].v_type != VAR_UNKNOWN) 11109 if (argvars[1].v_type != VAR_UNKNOWN)
11099 noref = get_tv_number_chk(&argvars[1], NULL); 11110 noref = (int)get_tv_number_chk(&argvars[1], NULL);
11100 if (noref < 0 || noref > 1) 11111 if (noref < 0 || noref > 1)
11101 EMSG(_(e_invarg)); 11112 EMSG(_(e_invarg));
11102 else 11113 else
11103 { 11114 {
11104 current_copyID += COPYID_INC; 11115 current_copyID += COPYID_INC;
11602 if (l1 != NULL && !tv_check_lock(l1->lv_lock, arg_errmsg, TRUE) 11613 if (l1 != NULL && !tv_check_lock(l1->lv_lock, arg_errmsg, TRUE)
11603 && l2 != NULL) 11614 && l2 != NULL)
11604 { 11615 {
11605 if (argvars[2].v_type != VAR_UNKNOWN) 11616 if (argvars[2].v_type != VAR_UNKNOWN)
11606 { 11617 {
11607 before = get_tv_number_chk(&argvars[2], &error); 11618 before = (long)get_tv_number_chk(&argvars[2], &error);
11608 if (error) 11619 if (error)
11609 return; /* type error; errmsg already given */ 11620 return; /* type error; errmsg already given */
11610 11621
11611 if (before == l1->lv_len) 11622 if (before == l1->lv_len)
11612 item = NULL; 11623 item = NULL;
11805 { 11816 {
11806 if (*p != NUL) 11817 if (*p != NUL)
11807 path = p; 11818 path = p;
11808 11819
11809 if (argvars[2].v_type != VAR_UNKNOWN) 11820 if (argvars[2].v_type != VAR_UNKNOWN)
11810 count = get_tv_number_chk(&argvars[2], &error); 11821 count = (int)get_tv_number_chk(&argvars[2], &error);
11811 } 11822 }
11812 } 11823 }
11813 11824
11814 if (count < 0 && rettv_list_alloc(rettv) == FAIL) 11825 if (count < 0 && rettv_list_alloc(rettv) == FAIL)
11815 error = TRUE; 11826 error = TRUE;
12041 { 12052 {
12042 float_T f = 0.0; 12053 float_T f = 0.0;
12043 12054
12044 if (get_float_arg(argvars, &f) == OK) 12055 if (get_float_arg(argvars, &f) == OK)
12045 { 12056 {
12057 # ifdef FEAT_NUM64
12058 if (f < -0x7fffffffffffffff)
12059 rettv->vval.v_number = -0x7fffffffffffffff;
12060 else if (f > 0x7fffffffffffffff)
12061 rettv->vval.v_number = 0x7fffffffffffffff;
12062 else
12063 rettv->vval.v_number = (varnumber_T)f;
12064 # else
12046 if (f < -0x7fffffff) 12065 if (f < -0x7fffffff)
12047 rettv->vval.v_number = -0x7fffffff; 12066 rettv->vval.v_number = -0x7fffffff;
12048 else if (f > 0x7fffffff) 12067 else if (f > 0x7fffffff)
12049 rettv->vval.v_number = 0x7fffffff; 12068 rettv->vval.v_number = 0x7fffffff;
12050 else 12069 else
12051 rettv->vval.v_number = (varnumber_T)f; 12070 rettv->vval.v_number = (varnumber_T)f;
12071 # endif
12052 } 12072 }
12053 } 12073 }
12054 12074
12055 /* 12075 /*
12056 * "floor({float})" function 12076 * "floor({float})" function
12509 { 12529 {
12510 if ((l = argvars[0].vval.v_list) != NULL) 12530 if ((l = argvars[0].vval.v_list) != NULL)
12511 { 12531 {
12512 int error = FALSE; 12532 int error = FALSE;
12513 12533
12514 li = list_find(l, get_tv_number_chk(&argvars[1], &error)); 12534 li = list_find(l, (long)get_tv_number_chk(&argvars[1], &error));
12515 if (!error && li != NULL) 12535 if (!error && li != NULL)
12516 tv = &li->li_tv; 12536 tv = &li->li_tv;
12517 } 12537 }
12518 } 12538 }
12519 else if (argvars[0].v_type == VAR_DICT) 12539 else if (argvars[0].v_type == VAR_DICT)
13331 { 13351 {
13332 strregname = get_tv_string_chk(&argvars[0]); 13352 strregname = get_tv_string_chk(&argvars[0]);
13333 error = strregname == NULL; 13353 error = strregname == NULL;
13334 if (argvars[1].v_type != VAR_UNKNOWN) 13354 if (argvars[1].v_type != VAR_UNKNOWN)
13335 { 13355 {
13336 arg2 = get_tv_number_chk(&argvars[1], &error); 13356 arg2 = (int)get_tv_number_chk(&argvars[1], &error);
13337 if (!error && argvars[2].v_type != VAR_UNKNOWN) 13357 if (!error && argvars[2].v_type != VAR_UNKNOWN)
13338 return_list = get_tv_number_chk(&argvars[2], &error); 13358 return_list = (int)get_tv_number_chk(&argvars[2], &error);
13339 } 13359 }
13340 } 13360 }
13341 else 13361 else
13342 strregname = vimvars[VV_REG].vv_str; 13362 strregname = vimvars[VV_REG].vv_str;
13343 13363
13556 #ifdef FEAT_WINDOWS 13576 #ifdef FEAT_WINDOWS
13557 win_T *wp; 13577 win_T *wp;
13558 #endif 13578 #endif
13559 int nr; 13579 int nr;
13560 13580
13561 nr = get_tv_number_chk(vp, NULL); 13581 nr = (int)get_tv_number_chk(vp, NULL);
13562 13582
13563 #ifdef FEAT_WINDOWS 13583 #ifdef FEAT_WINDOWS
13564 if (nr < 0) 13584 if (nr < 0)
13565 return NULL; 13585 return NULL;
13566 if (nr == 0) 13586 if (nr == 0)
13599 13619
13600 if (wvp->v_type != VAR_UNKNOWN) 13620 if (wvp->v_type != VAR_UNKNOWN)
13601 { 13621 {
13602 if (tvp->v_type != VAR_UNKNOWN) 13622 if (tvp->v_type != VAR_UNKNOWN)
13603 { 13623 {
13604 n = get_tv_number(tvp); 13624 n = (long)get_tv_number(tvp);
13605 if (n >= 0) 13625 if (n >= 0)
13606 tp = find_tabpage(n); 13626 tp = find_tabpage(n);
13607 } 13627 }
13608 else 13628 else
13609 tp = curtab; 13629 tp = curtab;
14124 #ifdef FEAT_MZSCHEME 14144 #ifdef FEAT_MZSCHEME
14125 #ifndef DYNAMIC_MZSCHEME 14145 #ifndef DYNAMIC_MZSCHEME
14126 "mzscheme", 14146 "mzscheme",
14127 #endif 14147 #endif
14128 #endif 14148 #endif
14149 #ifdef FEAT_NUM64
14150 "num64",
14151 #endif
14129 #ifdef FEAT_OLE 14152 #ifdef FEAT_OLE
14130 "ole", 14153 "ole",
14131 #endif 14154 #endif
14132 "packages", 14155 "packages",
14133 #ifdef FEAT_PATH_EXTRA 14156 #ifdef FEAT_PATH_EXTRA
14466 mode = (char_u *)"nvo"; 14489 mode = (char_u *)"nvo";
14467 else 14490 else
14468 { 14491 {
14469 mode = get_tv_string_buf(&argvars[1], buf); 14492 mode = get_tv_string_buf(&argvars[1], buf);
14470 if (argvars[2].v_type != VAR_UNKNOWN) 14493 if (argvars[2].v_type != VAR_UNKNOWN)
14471 abbr = get_tv_number(&argvars[2]); 14494 abbr = (int)get_tv_number(&argvars[2]);
14472 } 14495 }
14473 14496
14474 if (map_to_exists(name, mode, abbr)) 14497 if (map_to_exists(name, mode, abbr))
14475 rettv->vval.v_number = TRUE; 14498 rettv->vval.v_number = TRUE;
14476 else 14499 else
14694 { 14717 {
14695 int error = FALSE; 14718 int error = FALSE;
14696 14719
14697 /* Start at specified item. Use the cached index that list_find() 14720 /* Start at specified item. Use the cached index that list_find()
14698 * sets, so that a negative number also works. */ 14721 * sets, so that a negative number also works. */
14699 item = list_find(l, get_tv_number_chk(&argvars[2], &error)); 14722 item = list_find(l, (long)get_tv_number_chk(&argvars[2], &error));
14700 idx = l->lv_idx; 14723 idx = l->lv_idx;
14701 if (argvars[3].v_type != VAR_UNKNOWN) 14724 if (argvars[3].v_type != VAR_UNKNOWN)
14702 ic = get_tv_number_chk(&argvars[3], &error); 14725 ic = (int)get_tv_number_chk(&argvars[3], &error);
14703 if (error) 14726 if (error)
14704 item = NULL; 14727 item = NULL;
14705 } 14728 }
14706 14729
14707 for ( ; item != NULL; item = item->li_next, ++idx) 14730 for ( ; item != NULL; item = item->li_next, ++idx)
14981 EMSG2(_(e_listarg), "insert()"); 15004 EMSG2(_(e_listarg), "insert()");
14982 else if ((l = argvars[0].vval.v_list) != NULL 15005 else if ((l = argvars[0].vval.v_list) != NULL
14983 && !tv_check_lock(l->lv_lock, (char_u *)N_("insert() argument"), TRUE)) 15006 && !tv_check_lock(l->lv_lock, (char_u *)N_("insert() argument"), TRUE))
14984 { 15007 {
14985 if (argvars[2].v_type != VAR_UNKNOWN) 15008 if (argvars[2].v_type != VAR_UNKNOWN)
14986 before = get_tv_number_chk(&argvars[2], &error); 15009 before = (long)get_tv_number_chk(&argvars[2], &error);
14987 if (error) 15010 if (error)
14988 return; /* type error; errmsg already given */ 15011 return; /* type error; errmsg already given */
14989 15012
14990 if (before == l->lv_len) 15013 if (before == l->lv_len)
14991 item = NULL; 15014 item = NULL;
15586 if (argvars[1].v_type != VAR_UNKNOWN) 15609 if (argvars[1].v_type != VAR_UNKNOWN)
15587 { 15610 {
15588 which = get_tv_string_buf_chk(&argvars[1], buf); 15611 which = get_tv_string_buf_chk(&argvars[1], buf);
15589 if (argvars[2].v_type != VAR_UNKNOWN) 15612 if (argvars[2].v_type != VAR_UNKNOWN)
15590 { 15613 {
15591 abbr = get_tv_number(&argvars[2]); 15614 abbr = (int)get_tv_number(&argvars[2]);
15592 if (argvars[3].v_type != VAR_UNKNOWN) 15615 if (argvars[3].v_type != VAR_UNKNOWN)
15593 get_dict = get_tv_number(&argvars[3]); 15616 get_dict = (int)get_tv_number(&argvars[3]);
15594 } 15617 }
15595 } 15618 }
15596 else 15619 else
15597 which = (char_u *)""; 15620 which = (char_u *)"";
15598 if (which == NULL) 15621 if (which == NULL)
15779 15802
15780 if (argvars[2].v_type != VAR_UNKNOWN) 15803 if (argvars[2].v_type != VAR_UNKNOWN)
15781 { 15804 {
15782 int error = FALSE; 15805 int error = FALSE;
15783 15806
15784 start = get_tv_number_chk(&argvars[2], &error); 15807 start = (long)get_tv_number_chk(&argvars[2], &error);
15785 if (error) 15808 if (error)
15786 goto theend; 15809 goto theend;
15787 if (l != NULL) 15810 if (l != NULL)
15788 { 15811 {
15789 li = list_find(l, start); 15812 li = list_find(l, start);
15808 len -= start; 15831 len -= start;
15809 } 15832 }
15810 } 15833 }
15811 15834
15812 if (argvars[3].v_type != VAR_UNKNOWN) 15835 if (argvars[3].v_type != VAR_UNKNOWN)
15813 nth = get_tv_number_chk(&argvars[3], &error); 15836 nth = (long)get_tv_number_chk(&argvars[3], &error);
15814 if (error) 15837 if (error)
15815 goto theend; 15838 goto theend;
15816 } 15839 }
15817 15840
15818 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); 15841 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
15967 15990
15968 if (grp == NULL || pat == NULL) 15991 if (grp == NULL || pat == NULL)
15969 return; 15992 return;
15970 if (argvars[2].v_type != VAR_UNKNOWN) 15993 if (argvars[2].v_type != VAR_UNKNOWN)
15971 { 15994 {
15972 prio = get_tv_number_chk(&argvars[2], &error); 15995 prio = (int)get_tv_number_chk(&argvars[2], &error);
15973 if (argvars[3].v_type != VAR_UNKNOWN) 15996 if (argvars[3].v_type != VAR_UNKNOWN)
15974 { 15997 {
15975 id = get_tv_number_chk(&argvars[3], &error); 15998 id = (int)get_tv_number_chk(&argvars[3], &error);
15976 if (argvars[4].v_type != VAR_UNKNOWN) 15999 if (argvars[4].v_type != VAR_UNKNOWN)
15977 { 16000 {
15978 if (argvars[4].v_type != VAR_DICT) 16001 if (argvars[4].v_type != VAR_DICT)
15979 { 16002 {
15980 EMSG(_(e_dictreq)); 16003 EMSG(_(e_dictreq));
16030 if (l == NULL) 16053 if (l == NULL)
16031 return; 16054 return;
16032 16055
16033 if (argvars[2].v_type != VAR_UNKNOWN) 16056 if (argvars[2].v_type != VAR_UNKNOWN)
16034 { 16057 {
16035 prio = get_tv_number_chk(&argvars[2], &error); 16058 prio = (int)get_tv_number_chk(&argvars[2], &error);
16036 if (argvars[3].v_type != VAR_UNKNOWN) 16059 if (argvars[3].v_type != VAR_UNKNOWN)
16037 { 16060 {
16038 id = get_tv_number_chk(&argvars[3], &error); 16061 id = (int)get_tv_number_chk(&argvars[3], &error);
16039 if (argvars[4].v_type != VAR_UNKNOWN) 16062 if (argvars[4].v_type != VAR_UNKNOWN)
16040 { 16063 {
16041 if (argvars[4].v_type != VAR_DICT) 16064 if (argvars[4].v_type != VAR_DICT)
16042 { 16065 {
16043 EMSG(_(e_dictreq)); 16066 EMSG(_(e_dictreq));
16072 f_matcharg(typval_T *argvars UNUSED, typval_T *rettv) 16095 f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
16073 { 16096 {
16074 if (rettv_list_alloc(rettv) == OK) 16097 if (rettv_list_alloc(rettv) == OK)
16075 { 16098 {
16076 #ifdef FEAT_SEARCH_EXTRA 16099 #ifdef FEAT_SEARCH_EXTRA
16077 int id = get_tv_number(&argvars[0]); 16100 int id = (int)get_tv_number(&argvars[0]);
16078 matchitem_T *m; 16101 matchitem_T *m;
16079 16102
16080 if (id >= 1 && id <= 3) 16103 if (id >= 1 && id <= 3)
16081 { 16104 {
16082 if ((m = (matchitem_T *)get_match(curwin, id)) != NULL) 16105 if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
16146 static void max_min(typval_T *argvars, typval_T *rettv, int domax); 16169 static void max_min(typval_T *argvars, typval_T *rettv, int domax);
16147 16170
16148 static void 16171 static void
16149 max_min(typval_T *argvars, typval_T *rettv, int domax) 16172 max_min(typval_T *argvars, typval_T *rettv, int domax)
16150 { 16173 {
16151 long n = 0; 16174 varnumber_T n = 0;
16152 long i; 16175 varnumber_T i;
16153 int error = FALSE; 16176 int error = FALSE;
16154 16177
16155 if (argvars[0].v_type == VAR_LIST) 16178 if (argvars[0].v_type == VAR_LIST)
16156 { 16179 {
16157 list_T *l; 16180 list_T *l;
16283 *gettail_sep(dir) = NUL; 16306 *gettail_sep(dir) = NUL;
16284 16307
16285 if (argvars[1].v_type != VAR_UNKNOWN) 16308 if (argvars[1].v_type != VAR_UNKNOWN)
16286 { 16309 {
16287 if (argvars[2].v_type != VAR_UNKNOWN) 16310 if (argvars[2].v_type != VAR_UNKNOWN)
16288 prot = get_tv_number_chk(&argvars[2], NULL); 16311 prot = (int)get_tv_number_chk(&argvars[2], NULL);
16289 if (prot != -1 && STRCMP(get_tv_string(&argvars[1]), "p") == 0) 16312 if (prot != -1 && STRCMP(get_tv_string(&argvars[1]), "p") == 0)
16290 mkdir_recurse(dir, prot); 16313 mkdir_recurse(dir, prot);
16291 } 16314 }
16292 rettv->vval.v_number = prot == -1 ? FAIL : vim_mkdir_emsg(dir, prot); 16315 rettv->vval.v_number = prot == -1 ? FAIL : vim_mkdir_emsg(dir, prot);
16293 } 16316 }
16426 if (has_mbyte) 16449 if (has_mbyte)
16427 { 16450 {
16428 int utf8 = 0; 16451 int utf8 = 0;
16429 16452
16430 if (argvars[1].v_type != VAR_UNKNOWN) 16453 if (argvars[1].v_type != VAR_UNKNOWN)
16431 utf8 = get_tv_number_chk(&argvars[1], NULL); 16454 utf8 = (int)get_tv_number_chk(&argvars[1], NULL);
16432 if (utf8) 16455 if (utf8)
16433 buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL; 16456 buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
16434 else 16457 else
16435 buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL; 16458 buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
16436 } 16459 }
16608 * "range()" function 16631 * "range()" function
16609 */ 16632 */
16610 static void 16633 static void
16611 f_range(typval_T *argvars, typval_T *rettv) 16634 f_range(typval_T *argvars, typval_T *rettv)
16612 { 16635 {
16613 long start; 16636 varnumber_T start;
16614 long end; 16637 varnumber_T end;
16615 long stride = 1; 16638 varnumber_T stride = 1;
16616 long i; 16639 varnumber_T i;
16617 int error = FALSE; 16640 int error = FALSE;
16618 16641
16619 start = get_tv_number_chk(&argvars[0], &error); 16642 start = get_tv_number_chk(&argvars[0], &error);
16620 if (argvars[1].v_type == VAR_UNKNOWN) 16643 if (argvars[1].v_type == VAR_UNKNOWN)
16621 { 16644 {
16669 if (argvars[1].v_type != VAR_UNKNOWN) 16692 if (argvars[1].v_type != VAR_UNKNOWN)
16670 { 16693 {
16671 if (STRCMP(get_tv_string(&argvars[1]), "b") == 0) 16694 if (STRCMP(get_tv_string(&argvars[1]), "b") == 0)
16672 binary = TRUE; 16695 binary = TRUE;
16673 if (argvars[2].v_type != VAR_UNKNOWN) 16696 if (argvars[2].v_type != VAR_UNKNOWN)
16674 maxline = get_tv_number(&argvars[2]); 16697 maxline = (long)get_tv_number(&argvars[2]);
16675 } 16698 }
16676 16699
16677 if (rettv_list_alloc(rettv) == FAIL) 16700 if (rettv_list_alloc(rettv) == FAIL)
16678 return; 16701 return;
16679 16702
17242 else if ((l = argvars[0].vval.v_list) != NULL 17265 else if ((l = argvars[0].vval.v_list) != NULL
17243 && !tv_check_lock(l->lv_lock, arg_errmsg, TRUE)) 17266 && !tv_check_lock(l->lv_lock, arg_errmsg, TRUE))
17244 { 17267 {
17245 int error = FALSE; 17268 int error = FALSE;
17246 17269
17247 idx = get_tv_number_chk(&argvars[1], &error); 17270 idx = (long)get_tv_number_chk(&argvars[1], &error);
17248 if (error) 17271 if (error)
17249 ; /* type error: do nothing, errmsg already given */ 17272 ; /* type error: do nothing, errmsg already given */
17250 else if ((item = list_find(l, idx)) == NULL) 17273 else if ((item = list_find(l, idx)) == NULL)
17251 EMSGN(_(e_listidx), idx); 17274 EMSGN(_(e_listidx), idx);
17252 else 17275 else
17259 vim_free(item); 17282 vim_free(item);
17260 } 17283 }
17261 else 17284 else
17262 { 17285 {
17263 /* Remove range of items, return list with values. */ 17286 /* Remove range of items, return list with values. */
17264 end = get_tv_number_chk(&argvars[2], &error); 17287 end = (long)get_tv_number_chk(&argvars[2], &error);
17265 if (error) 17288 if (error)
17266 ; /* type error: do nothing */ 17289 ; /* type error: do nothing */
17267 else if ((item2 = list_find(l, end)) == NULL) 17290 else if ((item2 = list_find(l, end)) == NULL)
17268 EMSGN(_(e_listidx), end); 17291 EMSGN(_(e_listidx), end);
17269 else 17292 else
17323 int slen; 17346 int slen;
17324 int len; 17347 int len;
17325 char_u *r; 17348 char_u *r;
17326 int i; 17349 int i;
17327 17350
17328 n = get_tv_number(&argvars[1]); 17351 n = (int)get_tv_number(&argvars[1]);
17329 if (argvars[0].v_type == VAR_LIST) 17352 if (argvars[0].v_type == VAR_LIST)
17330 { 17353 {
17331 if (rettv_list_alloc(rettv) == OK && argvars[0].vval.v_list != NULL) 17354 if (rettv_list_alloc(rettv) == OK && argvars[0].vval.v_list != NULL)
17332 while (n-- > 0) 17355 while (n-- > 0)
17333 if (list_extend(rettv->vval.v_list, 17356 if (list_extend(rettv->vval.v_list,
17694 options |= SEARCH_COL; 17717 options |= SEARCH_COL;
17695 17718
17696 /* Optional arguments: line number to stop searching and timeout. */ 17719 /* Optional arguments: line number to stop searching and timeout. */
17697 if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) 17720 if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN)
17698 { 17721 {
17699 lnum_stop = get_tv_number_chk(&argvars[2], NULL); 17722 lnum_stop = (long)get_tv_number_chk(&argvars[2], NULL);
17700 if (lnum_stop < 0) 17723 if (lnum_stop < 0)
17701 goto theend; 17724 goto theend;
17702 #ifdef FEAT_RELTIME 17725 #ifdef FEAT_RELTIME
17703 if (argvars[3].v_type != VAR_UNKNOWN) 17726 if (argvars[3].v_type != VAR_UNKNOWN)
17704 { 17727 {
17705 time_limit = get_tv_number_chk(&argvars[3], NULL); 17728 time_limit = (long)get_tv_number_chk(&argvars[3], NULL);
17706 if (time_limit < 0) 17729 if (time_limit < 0)
17707 goto theend; 17730 goto theend;
17708 } 17731 }
17709 #endif 17732 #endif
17710 } 17733 }
17796 { 17819 {
17797 int row; 17820 int row;
17798 int col; 17821 int col;
17799 int c; 17822 int c;
17800 17823
17801 row = get_tv_number_chk(&argvars[0], NULL) - 1; 17824 row = (int)get_tv_number_chk(&argvars[0], NULL) - 1;
17802 col = get_tv_number_chk(&argvars[1], NULL) - 1; 17825 col = (int)get_tv_number_chk(&argvars[1], NULL) - 1;
17803 if (row < 0 || row >= screen_Rows 17826 if (row < 0 || row >= screen_Rows
17804 || col < 0 || col >= screen_Columns) 17827 || col < 0 || col >= screen_Columns)
17805 c = -1; 17828 c = -1;
17806 else 17829 else
17807 c = ScreenAttrs[LineOffset[row] + col]; 17830 c = ScreenAttrs[LineOffset[row] + col];
17817 int row; 17840 int row;
17818 int col; 17841 int col;
17819 int off; 17842 int off;
17820 int c; 17843 int c;
17821 17844
17822 row = get_tv_number_chk(&argvars[0], NULL) - 1; 17845 row = (int)get_tv_number_chk(&argvars[0], NULL) - 1;
17823 col = get_tv_number_chk(&argvars[1], NULL) - 1; 17846 col = (int)get_tv_number_chk(&argvars[1], NULL) - 1;
17824 if (row < 0 || row >= screen_Rows 17847 if (row < 0 || row >= screen_Rows
17825 || col < 0 || col >= screen_Columns) 17848 || col < 0 || col >= screen_Columns)
17826 c = -1; 17849 c = -1;
17827 else 17850 else
17828 { 17851 {
17882 rettv->vval.v_number = 1; /* default: FAIL */ 17905 rettv->vval.v_number = 1; /* default: FAIL */
17883 17906
17884 name = get_tv_string_chk(&argvars[0]); 17907 name = get_tv_string_chk(&argvars[0]);
17885 if (argvars[1].v_type != VAR_UNKNOWN) 17908 if (argvars[1].v_type != VAR_UNKNOWN)
17886 { 17909 {
17887 locally = get_tv_number_chk(&argvars[1], &error) == 0; 17910 locally = (int)get_tv_number_chk(&argvars[1], &error) == 0;
17888 if (!error && argvars[2].v_type != VAR_UNKNOWN) 17911 if (!error && argvars[2].v_type != VAR_UNKNOWN)
17889 thisblock = get_tv_number_chk(&argvars[2], &error) != 0; 17912 thisblock = (int)get_tv_number_chk(&argvars[2], &error) != 0;
17890 } 17913 }
17891 if (!error && name != NULL) 17914 if (!error && name != NULL)
17892 rettv->vval.v_number = find_decl(name, (int)STRLEN(name), 17915 rettv->vval.v_number = find_decl(name, (int)STRLEN(name),
17893 locally, thisblock, SEARCH_KEEP) == FAIL; 17916 locally, thisblock, SEARCH_KEEP) == FAIL;
17894 } 17917 }
17944 else 17967 else
17945 { 17968 {
17946 skip = get_tv_string_buf_chk(&argvars[4], nbuf3); 17969 skip = get_tv_string_buf_chk(&argvars[4], nbuf3);
17947 if (argvars[5].v_type != VAR_UNKNOWN) 17970 if (argvars[5].v_type != VAR_UNKNOWN)
17948 { 17971 {
17949 lnum_stop = get_tv_number_chk(&argvars[5], NULL); 17972 lnum_stop = (long)get_tv_number_chk(&argvars[5], NULL);
17950 if (lnum_stop < 0) 17973 if (lnum_stop < 0)
17951 goto theend; 17974 goto theend;
17952 #ifdef FEAT_RELTIME 17975 #ifdef FEAT_RELTIME
17953 if (argvars[6].v_type != VAR_UNKNOWN) 17976 if (argvars[6].v_type != VAR_UNKNOWN)
17954 { 17977 {
17955 time_limit = get_tv_number_chk(&argvars[6], NULL); 17978 time_limit = (long)get_tv_number_chk(&argvars[6], NULL);
17956 if (time_limit < 0) 17979 if (time_limit < 0)
17957 goto theend; 17980 goto theend;
17958 } 17981 }
17959 #endif 17982 #endif
17960 } 17983 }
18265 long numval; 18288 long numval;
18266 char_u *strval; 18289 char_u *strval;
18267 int error = FALSE; 18290 int error = FALSE;
18268 18291
18269 ++varname; 18292 ++varname;
18270 numval = get_tv_number_chk(varp, &error); 18293 numval = (long)get_tv_number_chk(varp, &error);
18271 strval = get_tv_string_buf_chk(varp, nbuf); 18294 strval = get_tv_string_buf_chk(varp, nbuf);
18272 if (!error && strval != NULL) 18295 if (!error && strval != NULL)
18273 set_option_value(varname, numval, strval, OPT_LOCAL); 18296 set_option_value(varname, numval, strval, OPT_LOCAL);
18274 } 18297 }
18275 else 18298 else
18321 csearch, MB_PTR2LEN(csearch)); 18344 csearch, MB_PTR2LEN(csearch));
18322 } 18345 }
18323 18346
18324 di = dict_find(d, (char_u *)"forward", -1); 18347 di = dict_find(d, (char_u *)"forward", -1);
18325 if (di != NULL) 18348 if (di != NULL)
18326 set_csearch_direction(get_tv_number(&di->di_tv) 18349 set_csearch_direction((int)get_tv_number(&di->di_tv)
18327 ? FORWARD : BACKWARD); 18350 ? FORWARD : BACKWARD);
18328 18351
18329 di = dict_find(d, (char_u *)"until", -1); 18352 di = dict_find(d, (char_u *)"until", -1);
18330 if (di != NULL) 18353 if (di != NULL)
18331 set_csearch_until(!!get_tv_number(&di->di_tv)); 18354 set_csearch_until(!!get_tv_number(&di->di_tv));
18914 long numval; 18937 long numval;
18915 char_u *strval; 18938 char_u *strval;
18916 int error = FALSE; 18939 int error = FALSE;
18917 18940
18918 ++varname; 18941 ++varname;
18919 numval = get_tv_number_chk(varp, &error); 18942 numval = (long)get_tv_number_chk(varp, &error);
18920 strval = get_tv_string_buf_chk(varp, nbuf); 18943 strval = get_tv_string_buf_chk(varp, nbuf);
18921 if (!error && strval != NULL) 18944 if (!error && strval != NULL)
18922 set_option_value(varname, numval, strval, OPT_LOCAL); 18945 set_option_value(varname, numval, strval, OPT_LOCAL);
18923 } 18946 }
18924 else 18947 else
19081 tv1 = &si1->item->li_tv; 19104 tv1 = &si1->item->li_tv;
19082 tv2 = &si2->item->li_tv; 19105 tv2 = &si2->item->li_tv;
19083 19106
19084 if (sortinfo->item_compare_numbers) 19107 if (sortinfo->item_compare_numbers)
19085 { 19108 {
19086 long v1 = get_tv_number(tv1); 19109 varnumber_T v1 = get_tv_number(tv1);
19087 long v2 = get_tv_number(tv2); 19110 varnumber_T v2 = get_tv_number(tv2);
19088 19111
19089 return v1 == v2 ? 0 : v1 > v2 ? 1 : -1; 19112 return v1 == v2 ? 0 : v1 > v2 ? 1 : -1;
19090 } 19113 }
19091 19114
19092 #ifdef FEAT_FLOAT 19115 #ifdef FEAT_FLOAT
19188 clear_tv(&argv[1]); 19211 clear_tv(&argv[1]);
19189 19212
19190 if (res == FAIL) 19213 if (res == FAIL)
19191 res = ITEM_COMPARE_FAIL; 19214 res = ITEM_COMPARE_FAIL;
19192 else 19215 else
19193 res = get_tv_number_chk(&rettv, &sortinfo->item_compare_func_err); 19216 res = (int)get_tv_number_chk(&rettv, &sortinfo->item_compare_func_err);
19194 if (sortinfo->item_compare_func_err) 19217 if (sortinfo->item_compare_func_err)
19195 res = ITEM_COMPARE_FAIL; /* return value has wrong type */ 19218 res = ITEM_COMPARE_FAIL; /* return value has wrong type */
19196 clear_tv(&rettv); 19219 clear_tv(&rettv);
19197 19220
19198 /* When the result would be zero, compare the pointers themselves. Makes 19221 /* When the result would be zero, compare the pointers themselves. Makes
19257 info.item_compare_partial = argvars[1].vval.v_partial; 19280 info.item_compare_partial = argvars[1].vval.v_partial;
19258 else 19281 else
19259 { 19282 {
19260 int error = FALSE; 19283 int error = FALSE;
19261 19284
19262 i = get_tv_number_chk(&argvars[1], &error); 19285 i = (long)get_tv_number_chk(&argvars[1], &error);
19263 if (error) 19286 if (error)
19264 goto theend; /* type error; errmsg already given */ 19287 goto theend; /* type error; errmsg already given */
19265 if (i == 1) 19288 if (i == 1)
19266 info.item_compare_ic = TRUE; 19289 info.item_compare_ic = TRUE;
19267 else if (argvars[1].v_type != VAR_NUMBER) 19290 else if (argvars[1].v_type != VAR_NUMBER)
19514 if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) 19537 if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL)
19515 { 19538 {
19516 str = get_tv_string(&argvars[0]); 19539 str = get_tv_string(&argvars[0]);
19517 if (argvars[1].v_type != VAR_UNKNOWN) 19540 if (argvars[1].v_type != VAR_UNKNOWN)
19518 { 19541 {
19519 maxcount = get_tv_number_chk(&argvars[1], &typeerr); 19542 maxcount = (int)get_tv_number_chk(&argvars[1], &typeerr);
19520 if (maxcount <= 0) 19543 if (maxcount <= 0)
19521 return; 19544 return;
19522 if (argvars[2].v_type != VAR_UNKNOWN) 19545 if (argvars[2].v_type != VAR_UNKNOWN)
19523 { 19546 {
19524 need_capital = get_tv_number_chk(&argvars[2], &typeerr); 19547 need_capital = (int)get_tv_number_chk(&argvars[2], &typeerr);
19525 if (typeerr) 19548 if (typeerr)
19526 return; 19549 return;
19527 } 19550 }
19528 } 19551 }
19529 else 19552 else
19574 { 19597 {
19575 pat = get_tv_string_buf_chk(&argvars[1], patbuf); 19598 pat = get_tv_string_buf_chk(&argvars[1], patbuf);
19576 if (pat == NULL) 19599 if (pat == NULL)
19577 typeerr = TRUE; 19600 typeerr = TRUE;
19578 if (argvars[2].v_type != VAR_UNKNOWN) 19601 if (argvars[2].v_type != VAR_UNKNOWN)
19579 keepempty = get_tv_number_chk(&argvars[2], &typeerr); 19602 keepempty = (int)get_tv_number_chk(&argvars[2], &typeerr);
19580 } 19603 }
19581 if (pat == NULL || *pat == NUL) 19604 if (pat == NULL || *pat == NUL)
19582 pat = (char_u *)"[\\x01- ]\\+"; 19605 pat = (char_u *)"[\\x01- ]\\+";
19583 19606
19584 if (rettv_list_alloc(rettv) == FAIL) 19607 if (rettv_list_alloc(rettv) == FAIL)
19667 static void 19690 static void
19668 f_str2nr(typval_T *argvars, typval_T *rettv) 19691 f_str2nr(typval_T *argvars, typval_T *rettv)
19669 { 19692 {
19670 int base = 10; 19693 int base = 10;
19671 char_u *p; 19694 char_u *p;
19672 long n; 19695 varnumber_T n;
19673 int what; 19696 int what;
19674 19697
19675 if (argvars[1].v_type != VAR_UNKNOWN) 19698 if (argvars[1].v_type != VAR_UNKNOWN)
19676 { 19699 {
19677 base = get_tv_number(&argvars[1]); 19700 base = (int)get_tv_number(&argvars[1]);
19678 if (base != 2 && base != 8 && base != 10 && base != 16) 19701 if (base != 2 && base != 8 && base != 10 && base != 16)
19679 { 19702 {
19680 EMSG(_(e_invarg)); 19703 EMSG(_(e_invarg));
19681 return; 19704 return;
19682 } 19705 }
19770 rettv->vval.v_number = -1; 19793 rettv->vval.v_number = -1;
19771 str = get_tv_string_chk(&argvars[0]); 19794 str = get_tv_string_chk(&argvars[0]);
19772 if (str == NULL) 19795 if (str == NULL)
19773 return; 19796 return;
19774 len = (int)STRLEN(str); 19797 len = (int)STRLEN(str);
19775 charidx = get_tv_number_chk(&argvars[1], &error); 19798 charidx = (int)get_tv_number_chk(&argvars[1], &error);
19776 if (error) 19799 if (error)
19777 return; 19800 return;
19778 #ifdef FEAT_MBYTE 19801 #ifdef FEAT_MBYTE
19779 { 19802 {
19780 int byteidx = 0; 19803 int byteidx = 0;
19817 19840
19818 if (argvars[2].v_type != VAR_UNKNOWN) 19841 if (argvars[2].v_type != VAR_UNKNOWN)
19819 { 19842 {
19820 int error = FALSE; 19843 int error = FALSE;
19821 19844
19822 start_idx = get_tv_number_chk(&argvars[2], &error); 19845 start_idx = (int)get_tv_number_chk(&argvars[2], &error);
19823 if (error || start_idx >= (int)STRLEN(haystack)) 19846 if (error || start_idx >= (int)STRLEN(haystack))
19824 return; 19847 return;
19825 if (start_idx >= 0) 19848 if (start_idx >= 0)
19826 haystack += start_idx; 19849 haystack += start_idx;
19827 } 19850 }
19870 varnumber_T len = 0; 19893 varnumber_T len = 0;
19871 int (*func_mb_ptr2char_adv)(char_u **pp); 19894 int (*func_mb_ptr2char_adv)(char_u **pp);
19872 #endif 19895 #endif
19873 19896
19874 if (argvars[1].v_type != VAR_UNKNOWN) 19897 if (argvars[1].v_type != VAR_UNKNOWN)
19875 skipcc = get_tv_number_chk(&argvars[1], NULL); 19898 skipcc = (int)get_tv_number_chk(&argvars[1], NULL);
19876 if (skipcc < 0 || skipcc > 1) 19899 if (skipcc < 0 || skipcc > 1)
19877 EMSG(_(e_invarg)); 19900 EMSG(_(e_invarg));
19878 else 19901 else
19879 { 19902 {
19880 #ifdef FEAT_MBYTE 19903 #ifdef FEAT_MBYTE
19899 { 19922 {
19900 char_u *s = get_tv_string(&argvars[0]); 19923 char_u *s = get_tv_string(&argvars[0]);
19901 int col = 0; 19924 int col = 0;
19902 19925
19903 if (argvars[1].v_type != VAR_UNKNOWN) 19926 if (argvars[1].v_type != VAR_UNKNOWN)
19904 col = get_tv_number(&argvars[1]); 19927 col = (int)get_tv_number(&argvars[1]);
19905 19928
19906 rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s) - col); 19929 rettv->vval.v_number = (varnumber_T)(linetabsize_col(col, s) - col);
19907 } 19930 }
19908 19931
19909 /* 19932 /*
19939 int error = FALSE; 19962 int error = FALSE;
19940 19963
19941 p = get_tv_string(&argvars[0]); 19964 p = get_tv_string(&argvars[0]);
19942 slen = (int)STRLEN(p); 19965 slen = (int)STRLEN(p);
19943 19966
19944 nchar = get_tv_number_chk(&argvars[1], &error); 19967 nchar = (int)get_tv_number_chk(&argvars[1], &error);
19945 if (!error) 19968 if (!error)
19946 { 19969 {
19947 if (nchar > 0) 19970 if (nchar > 0)
19948 while (nchar > 0 && nbyte < slen) 19971 while (nchar > 0 && nbyte < slen)
19949 { 19972 {
19952 } 19975 }
19953 else 19976 else
19954 nbyte = nchar; 19977 nbyte = nchar;
19955 if (argvars[2].v_type != VAR_UNKNOWN) 19978 if (argvars[2].v_type != VAR_UNKNOWN)
19956 { 19979 {
19957 charlen = get_tv_number(&argvars[2]); 19980 charlen = (int)get_tv_number(&argvars[2]);
19958 while (charlen > 0 && nbyte + len < slen) 19981 while (charlen > 0 && nbyte + len < slen)
19959 { 19982 {
19960 int off = nbyte + len; 19983 int off = nbyte + len;
19961 19984
19962 if (off < 0) 19985 if (off < 0)
20006 int error = FALSE; 20029 int error = FALSE;
20007 20030
20008 p = get_tv_string(&argvars[0]); 20031 p = get_tv_string(&argvars[0]);
20009 slen = (int)STRLEN(p); 20032 slen = (int)STRLEN(p);
20010 20033
20011 n = get_tv_number_chk(&argvars[1], &error); 20034 n = (int)get_tv_number_chk(&argvars[1], &error);
20012 if (error) 20035 if (error)
20013 len = 0; 20036 len = 0;
20014 else if (argvars[2].v_type != VAR_UNKNOWN) 20037 else if (argvars[2].v_type != VAR_UNKNOWN)
20015 len = get_tv_number(&argvars[2]); 20038 len = (int)get_tv_number(&argvars[2]);
20016 else 20039 else
20017 len = slen - n; /* default len: all bytes that are available. */ 20040 len = slen - n; /* default len: all bytes that are available. */
20018 20041
20019 /* 20042 /*
20020 * Only return the overlap between the specified part and the actual 20043 * Only return the overlap between the specified part and the actual
20058 20081
20059 haystack_len = (int)STRLEN(haystack); 20082 haystack_len = (int)STRLEN(haystack);
20060 if (argvars[2].v_type != VAR_UNKNOWN) 20083 if (argvars[2].v_type != VAR_UNKNOWN)
20061 { 20084 {
20062 /* Third argument: upper limit for index */ 20085 /* Third argument: upper limit for index */
20063 end_idx = get_tv_number_chk(&argvars[2], NULL); 20086 end_idx = (int)get_tv_number_chk(&argvars[2], NULL);
20064 if (end_idx < 0) 20087 if (end_idx < 0)
20065 return; /* can never find a match */ 20088 return; /* can never find a match */
20066 } 20089 }
20067 else 20090 else
20068 end_idx = haystack_len; 20091 end_idx = haystack_len;
20112 no = (int)get_tv_number_chk(&argvars[0], &error); 20135 no = (int)get_tv_number_chk(&argvars[0], &error);
20113 if (error) 20136 if (error)
20114 return; 20137 return;
20115 error = FALSE; 20138 error = FALSE;
20116 if (argvars[1].v_type != VAR_UNKNOWN) 20139 if (argvars[1].v_type != VAR_UNKNOWN)
20117 retList = get_tv_number_chk(&argvars[1], &error); 20140 retList = (int)get_tv_number_chk(&argvars[1], &error);
20118 if (error) 20141 if (error)
20119 return; 20142 return;
20120 20143
20121 if (retList == 0) 20144 if (retList == 0)
20122 { 20145 {
20158 static void 20181 static void
20159 f_synID(typval_T *argvars UNUSED, typval_T *rettv) 20182 f_synID(typval_T *argvars UNUSED, typval_T *rettv)
20160 { 20183 {
20161 int id = 0; 20184 int id = 0;
20162 #ifdef FEAT_SYN_HL 20185 #ifdef FEAT_SYN_HL
20163 long lnum; 20186 linenr_T lnum;
20164 long col; 20187 colnr_T col;
20165 int trans; 20188 int trans;
20166 int transerr = FALSE; 20189 int transerr = FALSE;
20167 20190
20168 lnum = get_tv_lnum(argvars); /* -1 on type error */ 20191 lnum = get_tv_lnum(argvars); /* -1 on type error */
20169 col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ 20192 col = (linenr_T)get_tv_number(&argvars[1]) - 1; /* -1 on type error */
20170 trans = get_tv_number_chk(&argvars[2], &transerr); 20193 trans = (int)get_tv_number_chk(&argvars[2], &transerr);
20171 20194
20172 if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count 20195 if (!transerr && lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
20173 && col >= 0 && col < (long)STRLEN(ml_get(lnum))) 20196 && col >= 0 && col < (long)STRLEN(ml_get(lnum)))
20174 id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE); 20197 id = syn_get_id(curwin, lnum, (colnr_T)col, trans, NULL, FALSE);
20175 #endif 20198 #endif
20189 char_u *what; 20212 char_u *what;
20190 char_u *mode; 20213 char_u *mode;
20191 char_u modebuf[NUMBUFLEN]; 20214 char_u modebuf[NUMBUFLEN];
20192 int modec; 20215 int modec;
20193 20216
20194 id = get_tv_number(&argvars[0]); 20217 id = (int)get_tv_number(&argvars[0]);
20195 what = get_tv_string(&argvars[1]); 20218 what = get_tv_string(&argvars[1]);
20196 if (argvars[2].v_type != VAR_UNKNOWN) 20219 if (argvars[2].v_type != VAR_UNKNOWN)
20197 { 20220 {
20198 mode = get_tv_string_buf(&argvars[2], modebuf); 20221 mode = get_tv_string_buf(&argvars[2], modebuf);
20199 modec = TOLOWER_ASC(mode[0]); 20222 modec = TOLOWER_ASC(mode[0]);
20273 f_synIDtrans(typval_T *argvars UNUSED, typval_T *rettv) 20296 f_synIDtrans(typval_T *argvars UNUSED, typval_T *rettv)
20274 { 20297 {
20275 int id; 20298 int id;
20276 20299
20277 #ifdef FEAT_SYN_HL 20300 #ifdef FEAT_SYN_HL
20278 id = get_tv_number(&argvars[0]); 20301 id = (int)get_tv_number(&argvars[0]);
20279 20302
20280 if (id > 0) 20303 if (id > 0)
20281 id = syn_get_final_id(id); 20304 id = syn_get_final_id(id);
20282 else 20305 else
20283 #endif 20306 #endif
20291 */ 20314 */
20292 static void 20315 static void
20293 f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv) 20316 f_synconcealed(typval_T *argvars UNUSED, typval_T *rettv)
20294 { 20317 {
20295 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL) 20318 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
20296 long lnum; 20319 linenr_T lnum;
20297 long col; 20320 colnr_T col;
20298 int syntax_flags = 0; 20321 int syntax_flags = 0;
20299 int cchar; 20322 int cchar;
20300 int matchid = 0; 20323 int matchid = 0;
20301 char_u str[NUMBUFLEN]; 20324 char_u str[NUMBUFLEN];
20302 #endif 20325 #endif
20304 rettv->v_type = VAR_LIST; 20327 rettv->v_type = VAR_LIST;
20305 rettv->vval.v_list = NULL; 20328 rettv->vval.v_list = NULL;
20306 20329
20307 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL) 20330 #if defined(FEAT_SYN_HL) && defined(FEAT_CONCEAL)
20308 lnum = get_tv_lnum(argvars); /* -1 on type error */ 20331 lnum = get_tv_lnum(argvars); /* -1 on type error */
20309 col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ 20332 col = (colnr_T)get_tv_number(&argvars[1]) - 1; /* -1 on type error */
20310 20333
20311 vim_memset(str, NUL, sizeof(str)); 20334 vim_memset(str, NUL, sizeof(str));
20312 20335
20313 if (rettv_list_alloc(rettv) != FAIL) 20336 if (rettv_list_alloc(rettv) != FAIL)
20314 { 20337 {
20351 */ 20374 */
20352 static void 20375 static void
20353 f_synstack(typval_T *argvars UNUSED, typval_T *rettv) 20376 f_synstack(typval_T *argvars UNUSED, typval_T *rettv)
20354 { 20377 {
20355 #ifdef FEAT_SYN_HL 20378 #ifdef FEAT_SYN_HL
20356 long lnum; 20379 linenr_T lnum;
20357 long col; 20380 colnr_T col;
20358 int i; 20381 int i;
20359 int id; 20382 int id;
20360 #endif 20383 #endif
20361 20384
20362 rettv->v_type = VAR_LIST; 20385 rettv->v_type = VAR_LIST;
20363 rettv->vval.v_list = NULL; 20386 rettv->vval.v_list = NULL;
20364 20387
20365 #ifdef FEAT_SYN_HL 20388 #ifdef FEAT_SYN_HL
20366 lnum = get_tv_lnum(argvars); /* -1 on type error */ 20389 lnum = get_tv_lnum(argvars); /* -1 on type error */
20367 col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ 20390 col = (colnr_T)get_tv_number(&argvars[1]) - 1; /* -1 on type error */
20368 20391
20369 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count 20392 if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
20370 && col >= 0 && col <= (long)STRLEN(ml_get(lnum)) 20393 && col >= 0 && col <= (long)STRLEN(ml_get(lnum))
20371 && rettv_list_alloc(rettv) != FAIL) 20394 && rettv_list_alloc(rettv) != FAIL)
20372 { 20395 {
20833 * "test_disable_char_avail({expr})" function 20856 * "test_disable_char_avail({expr})" function
20834 */ 20857 */
20835 static void 20858 static void
20836 f_test_disable_char_avail(typval_T *argvars, typval_T *rettv UNUSED) 20859 f_test_disable_char_avail(typval_T *argvars, typval_T *rettv UNUSED)
20837 { 20860 {
20838 disable_char_avail_for_testing = get_tv_number(&argvars[0]); 20861 disable_char_avail_for_testing = (int)get_tv_number(&argvars[0]);
20839 } 20862 }
20840 20863
20841 /* 20864 /*
20842 * "test_garbagecollect_now()" function 20865 * "test_garbagecollect_now()" function
20843 */ 20866 */
20931 * "timer_start(time, callback [, options])" function 20954 * "timer_start(time, callback [, options])" function
20932 */ 20955 */
20933 static void 20956 static void
20934 f_timer_start(typval_T *argvars, typval_T *rettv) 20957 f_timer_start(typval_T *argvars, typval_T *rettv)
20935 { 20958 {
20936 long msec = get_tv_number(&argvars[0]); 20959 long msec = (long)get_tv_number(&argvars[0]);
20937 timer_T *timer; 20960 timer_T *timer;
20938 int repeat = 0; 20961 int repeat = 0;
20939 char_u *callback; 20962 char_u *callback;
20940 dict_T *dict; 20963 dict_T *dict;
20941 20964
20978 if (argvars[0].v_type != VAR_NUMBER) 21001 if (argvars[0].v_type != VAR_NUMBER)
20979 { 21002 {
20980 EMSG(_(e_number_exp)); 21003 EMSG(_(e_number_exp));
20981 return; 21004 return;
20982 } 21005 }
20983 timer = find_timer(get_tv_number(&argvars[0])); 21006 timer = find_timer((int)get_tv_number(&argvars[0]));
20984 if (timer != NULL) 21007 if (timer != NULL)
20985 stop_timer(timer); 21008 stop_timer(timer);
20986 } 21009 }
20987 #endif 21010 #endif
20988 21011
21434 || (dict = argvars[0].vval.v_dict) == NULL) 21457 || (dict = argvars[0].vval.v_dict) == NULL)
21435 EMSG(_(e_invarg)); 21458 EMSG(_(e_invarg));
21436 else 21459 else
21437 { 21460 {
21438 if (dict_find(dict, (char_u *)"lnum", -1) != NULL) 21461 if (dict_find(dict, (char_u *)"lnum", -1) != NULL)
21439 curwin->w_cursor.lnum = get_dict_number(dict, (char_u *)"lnum"); 21462 curwin->w_cursor.lnum = (linenr_T)get_dict_number(dict, (char_u *)"lnum");
21440 if (dict_find(dict, (char_u *)"col", -1) != NULL) 21463 if (dict_find(dict, (char_u *)"col", -1) != NULL)
21441 curwin->w_cursor.col = get_dict_number(dict, (char_u *)"col"); 21464 curwin->w_cursor.col = (colnr_T)get_dict_number(dict, (char_u *)"col");
21442 #ifdef FEAT_VIRTUALEDIT 21465 #ifdef FEAT_VIRTUALEDIT
21443 if (dict_find(dict, (char_u *)"coladd", -1) != NULL) 21466 if (dict_find(dict, (char_u *)"coladd", -1) != NULL)
21444 curwin->w_cursor.coladd = get_dict_number(dict, (char_u *)"coladd"); 21467 curwin->w_cursor.coladd = (colnr_T)get_dict_number(dict, (char_u *)"coladd");
21445 #endif 21468 #endif
21446 if (dict_find(dict, (char_u *)"curswant", -1) != NULL) 21469 if (dict_find(dict, (char_u *)"curswant", -1) != NULL)
21447 { 21470 {
21448 curwin->w_curswant = get_dict_number(dict, (char_u *)"curswant"); 21471 curwin->w_curswant = (colnr_T)get_dict_number(dict, (char_u *)"curswant");
21449 curwin->w_set_curswant = FALSE; 21472 curwin->w_set_curswant = FALSE;
21450 } 21473 }
21451 21474
21452 if (dict_find(dict, (char_u *)"topline", -1) != NULL) 21475 if (dict_find(dict, (char_u *)"topline", -1) != NULL)
21453 set_topline(curwin, get_dict_number(dict, (char_u *)"topline")); 21476 set_topline(curwin, (linenr_T)get_dict_number(dict, (char_u *)"topline"));
21454 #ifdef FEAT_DIFF 21477 #ifdef FEAT_DIFF
21455 if (dict_find(dict, (char_u *)"topfill", -1) != NULL) 21478 if (dict_find(dict, (char_u *)"topfill", -1) != NULL)
21456 curwin->w_topfill = get_dict_number(dict, (char_u *)"topfill"); 21479 curwin->w_topfill = (int)get_dict_number(dict, (char_u *)"topfill");
21457 #endif 21480 #endif
21458 if (dict_find(dict, (char_u *)"leftcol", -1) != NULL) 21481 if (dict_find(dict, (char_u *)"leftcol", -1) != NULL)
21459 curwin->w_leftcol = get_dict_number(dict, (char_u *)"leftcol"); 21482 curwin->w_leftcol = (colnr_T)get_dict_number(dict, (char_u *)"leftcol");
21460 if (dict_find(dict, (char_u *)"skipcol", -1) != NULL) 21483 if (dict_find(dict, (char_u *)"skipcol", -1) != NULL)
21461 curwin->w_skipcol = get_dict_number(dict, (char_u *)"skipcol"); 21484 curwin->w_skipcol = (colnr_T)get_dict_number(dict, (char_u *)"skipcol");
21462 21485
21463 check_cursor(); 21486 check_cursor();
21464 win_new_height(curwin, curwin->w_height); 21487 win_new_height(curwin, curwin->w_height);
21465 # ifdef FEAT_WINDOWS 21488 # ifdef FEAT_WINDOWS
21466 win_new_width(curwin, W_WIDTH(curwin)); 21489 win_new_width(curwin, W_WIDTH(curwin));
22118 22141
22119 /* 22142 /*
22120 * Set number v: variable to "val". 22143 * Set number v: variable to "val".
22121 */ 22144 */
22122 void 22145 void
22123 set_vim_var_nr(int idx, long val) 22146 set_vim_var_nr(int idx, varnumber_T val)
22124 { 22147 {
22125 vimvars[idx].vv_nr = val; 22148 vimvars[idx].vv_nr = val;
22126 } 22149 }
22127 22150
22128 /* 22151 /*
22129 * Get number v: variable value. 22152 * Get number v: variable value.
22130 */ 22153 */
22131 long 22154 varnumber_T
22132 get_vim_var_nr(int idx) 22155 get_vim_var_nr(int idx)
22133 { 22156 {
22134 return vimvars[idx].vv_nr; 22157 return vimvars[idx].vv_nr;
22135 } 22158 }
22136 22159
22740 * For incompatible types, return 0. 22763 * For incompatible types, return 0.
22741 * get_tv_number_chk() is similar to get_tv_number(), but informs the 22764 * get_tv_number_chk() is similar to get_tv_number(), but informs the
22742 * caller of incompatible types: it sets *denote to TRUE if "denote" 22765 * caller of incompatible types: it sets *denote to TRUE if "denote"
22743 * is not NULL or returns -1 otherwise. 22766 * is not NULL or returns -1 otherwise.
22744 */ 22767 */
22745 long 22768 varnumber_T
22746 get_tv_number(typval_T *varp) 22769 get_tv_number(typval_T *varp)
22747 { 22770 {
22748 int error = FALSE; 22771 int error = FALSE;
22749 22772
22750 return get_tv_number_chk(varp, &error); /* return 0L on error */ 22773 return get_tv_number_chk(varp, &error); /* return 0L on error */
22751 } 22774 }
22752 22775
22753 long 22776 varnumber_T
22754 get_tv_number_chk(typval_T *varp, int *denote) 22777 get_tv_number_chk(typval_T *varp, int *denote)
22755 { 22778 {
22756 long n = 0L; 22779 varnumber_T n = 0L;
22757 22780
22758 switch (varp->v_type) 22781 switch (varp->v_type)
22759 { 22782 {
22760 case VAR_NUMBER: 22783 case VAR_NUMBER:
22761 return (long)(varp->vval.v_number); 22784 return varp->vval.v_number;
22762 case VAR_FLOAT: 22785 case VAR_FLOAT:
22763 #ifdef FEAT_FLOAT 22786 #ifdef FEAT_FLOAT
22764 EMSG(_("E805: Using a Float as a Number")); 22787 EMSG(_("E805: Using a Float as a Number"));
22765 break; 22788 break;
22766 #endif 22789 #endif
22856 get_tv_lnum(typval_T *argvars) 22879 get_tv_lnum(typval_T *argvars)
22857 { 22880 {
22858 typval_T rettv; 22881 typval_T rettv;
22859 linenr_T lnum; 22882 linenr_T lnum;
22860 22883
22861 lnum = get_tv_number_chk(&argvars[0], NULL); 22884 lnum = (linenr_T)get_tv_number_chk(&argvars[0], NULL);
22862 if (lnum == 0) /* no valid number, try using line() */ 22885 if (lnum == 0) /* no valid number, try using line() */
22863 { 22886 {
22864 rettv.v_type = VAR_NUMBER; 22887 rettv.v_type = VAR_NUMBER;
22865 f_line(argvars, &rettv); 22888 f_line(argvars, &rettv);
22866 lnum = rettv.vval.v_number; 22889 lnum = (linenr_T)rettv.vval.v_number;
22867 clear_tv(&rettv); 22890 clear_tv(&rettv);
22868 } 22891 }
22869 return lnum; 22892 return lnum;
22870 } 22893 }
22871 22894
22880 if (argvars[0].v_type == VAR_STRING 22903 if (argvars[0].v_type == VAR_STRING
22881 && argvars[0].vval.v_string != NULL 22904 && argvars[0].vval.v_string != NULL
22882 && argvars[0].vval.v_string[0] == '$' 22905 && argvars[0].vval.v_string[0] == '$'
22883 && buf != NULL) 22906 && buf != NULL)
22884 return buf->b_ml.ml_line_count; 22907 return buf->b_ml.ml_line_count;
22885 return get_tv_number_chk(&argvars[0], NULL); 22908 return (linenr_T)get_tv_number_chk(&argvars[0], NULL);
22886 } 22909 }
22887 22910
22888 /* 22911 /*
22889 * Get the string value of a variable. 22912 * Get the string value of a variable.
22890 * If it is a Number variable, the number is converted into a string. 22913 * If it is a Number variable, the number is converted into a string.
22926 get_tv_string_buf_chk(typval_T *varp, char_u *buf) 22949 get_tv_string_buf_chk(typval_T *varp, char_u *buf)
22927 { 22950 {
22928 switch (varp->v_type) 22951 switch (varp->v_type)
22929 { 22952 {
22930 case VAR_NUMBER: 22953 case VAR_NUMBER:
22931 sprintf((char *)buf, "%ld", (long)varp->vval.v_number); 22954 vim_snprintf((char *)buf, NUMBUFLEN, "%lld",
22955 (varnumber_T)varp->vval.v_number);
22932 return buf; 22956 return buf;
22933 case VAR_FUNC: 22957 case VAR_FUNC:
22934 case VAR_PARTIAL: 22958 case VAR_PARTIAL:
22935 EMSG(_("E729: using Funcref as a String")); 22959 EMSG(_("E729: using Funcref as a String"));
22936 break; 22960 break;