comparison src/eval.c @ 4133:36fd800b8c6c v7.3.819

updated for version 7.3.819 Problem: Compiling without +eval and with Python isn't working. Solution: Add the eval feature when building with Python.
author Bram Moolenaar <bram@vim.org>
date Thu, 14 Feb 2013 22:11:39 +0100
parents 2b340e5c5baa
children f5ef9b9c18cd
comparison
equal deleted inserted replaced
4132:97c9942586a4 4133:36fd800b8c6c
915 hash_clear(&vimvarht); 915 hash_clear(&vimvarht);
916 hash_init(&vimvarht); /* garbage_collect() will access it */ 916 hash_init(&vimvarht); /* garbage_collect() will access it */
917 hash_clear(&compat_hashtab); 917 hash_clear(&compat_hashtab);
918 918
919 free_scriptnames(); 919 free_scriptnames();
920 # if defined(FEAT_CMDL_COMPL)
920 free_locales(); 921 free_locales();
922 # endif
921 923
922 /* global variables */ 924 /* global variables */
923 vars_clear(&globvarht); 925 vars_clear(&globvarht);
924 926
925 /* autoloaded script names */ 927 /* autoloaded script names */
1559 1561
1560 return tv; 1562 return tv;
1561 } 1563 }
1562 1564
1563 1565
1564 #if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) \
1565 || defined(FEAT_COMPL_FUNC) || defined(PROTO)
1566 /* 1566 /*
1567 * Call some vimL function and return the result in "*rettv". 1567 * Call some vimL function and return the result in "*rettv".
1568 * Uses argv[argc] for the function arguments. Only Number and String 1568 * Uses argv[argc] for the function arguments. Only Number and String
1569 * arguments are currently supported. 1569 * arguments are currently supported.
1570 * Returns OK or FAIL. 1570 * Returns OK or FAIL.
1638 clear_tv(rettv); 1638 clear_tv(rettv);
1639 1639
1640 return ret; 1640 return ret;
1641 } 1641 }
1642 1642
1643 /*
1644 * Call vimL function "func" and return the result as a number.
1645 * Returns -1 when calling the function fails.
1646 * Uses argv[argc] for the function arguments.
1647 */
1648 long
1649 call_func_retnr(func, argc, argv, safe)
1650 char_u *func;
1651 int argc;
1652 char_u **argv;
1653 int safe; /* use the sandbox */
1654 {
1655 typval_T rettv;
1656 long retval;
1657
1658 /* All arguments are passed as strings, no conversion to number. */
1659 if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
1660 return -1;
1661
1662 retval = get_tv_number_chk(&rettv, NULL);
1663 clear_tv(&rettv);
1664 return retval;
1665 }
1666
1667 #if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) \
1668 || defined(FEAT_COMPL_FUNC) || defined(PROTO)
1669
1643 # if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO) 1670 # if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
1644 /* 1671 /*
1645 * Call vimL function "func" and return the result as a string. 1672 * Call vimL function "func" and return the result as a string.
1646 * Returns NULL when calling the function fails. 1673 * Returns NULL when calling the function fails.
1647 * Uses argv[argc] for the function arguments. 1674 * Uses argv[argc] for the function arguments.
1664 clear_tv(&rettv); 1691 clear_tv(&rettv);
1665 return retval; 1692 return retval;
1666 } 1693 }
1667 # endif 1694 # endif
1668 1695
1669 # if defined(FEAT_COMPL_FUNC) || defined(PROTO)
1670 /*
1671 * Call vimL function "func" and return the result as a number.
1672 * Returns -1 when calling the function fails.
1673 * Uses argv[argc] for the function arguments.
1674 */
1675 long
1676 call_func_retnr(func, argc, argv, safe)
1677 char_u *func;
1678 int argc;
1679 char_u **argv;
1680 int safe; /* use the sandbox */
1681 {
1682 typval_T rettv;
1683 long retval;
1684
1685 /* All arguments are passed as strings, no conversion to number. */
1686 if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
1687 return -1;
1688
1689 retval = get_tv_number_chk(&rettv, NULL);
1690 clear_tv(&rettv);
1691 return retval;
1692 }
1693 # endif
1694
1695 /* 1696 /*
1696 * Call vimL function "func" and return the result as a List. 1697 * Call vimL function "func" and return the result as a List.
1697 * Uses argv[argc] for the function arguments. 1698 * Uses argv[argc] for the function arguments.
1698 * Returns NULL when there is something wrong. 1699 * Returns NULL when there is something wrong.
1699 */ 1700 */
1717 } 1718 }
1718 1719
1719 return rettv.vval.v_list; 1720 return rettv.vval.v_list;
1720 } 1721 }
1721 #endif 1722 #endif
1722
1723 1723
1724 /* 1724 /*
1725 * Save the current function call pointer, and set it to NULL. 1725 * Save the current function call pointer, and set it to NULL.
1726 * Used when executing autocommands and for ":source". 1726 * Used when executing autocommands and for ":source".
1727 */ 1727 */
9328 /* 9328 /*
9329 * "cindent(lnum)" function 9329 * "cindent(lnum)" function
9330 */ 9330 */
9331 static void 9331 static void
9332 f_cindent(argvars, rettv) 9332 f_cindent(argvars, rettv)
9333 typval_T *argvars; 9333 typval_T *argvars UNUSED;
9334 typval_T *rettv; 9334 typval_T *rettv;
9335 { 9335 {
9336 #ifdef FEAT_CINDENT 9336 #ifdef FEAT_CINDENT
9337 pos_T pos; 9337 pos_T pos;
9338 linenr_T lnum; 9338 linenr_T lnum;
10377 10377
10378 static void findfilendir __ARGS((typval_T *argvars, typval_T *rettv, int find_what)); 10378 static void findfilendir __ARGS((typval_T *argvars, typval_T *rettv, int find_what));
10379 10379
10380 static void 10380 static void
10381 findfilendir(argvars, rettv, find_what) 10381 findfilendir(argvars, rettv, find_what)
10382 typval_T *argvars; 10382 typval_T *argvars UNUSED;
10383 typval_T *rettv; 10383 typval_T *rettv;
10384 int find_what; 10384 int find_what UNUSED;
10385 { 10385 {
10386 #ifdef FEAT_SEARCHPATH 10386 #ifdef FEAT_SEARCHPATH
10387 char_u *fname; 10387 char_u *fname;
10388 char_u *fresult = NULL; 10388 char_u *fresult = NULL;
10389 char_u *path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path; 10389 char_u *path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path;
10749 /* 10749 /*
10750 * "foldclosed()" function 10750 * "foldclosed()" function
10751 */ 10751 */
10752 static void 10752 static void
10753 foldclosed_both(argvars, rettv, end) 10753 foldclosed_both(argvars, rettv, end)
10754 typval_T *argvars; 10754 typval_T *argvars UNUSED;
10755 typval_T *rettv; 10755 typval_T *rettv;
10756 int end; 10756 int end UNUSED;
10757 { 10757 {
10758 #ifdef FEAT_FOLDING 10758 #ifdef FEAT_FOLDING
10759 linenr_T lnum; 10759 linenr_T lnum;
10760 linenr_T first, last; 10760 linenr_T first, last;
10761 10761
10800 /* 10800 /*
10801 * "foldlevel()" function 10801 * "foldlevel()" function
10802 */ 10802 */
10803 static void 10803 static void
10804 f_foldlevel(argvars, rettv) 10804 f_foldlevel(argvars, rettv)
10805 typval_T *argvars; 10805 typval_T *argvars UNUSED;
10806 typval_T *rettv; 10806 typval_T *rettv UNUSED;
10807 { 10807 {
10808 #ifdef FEAT_FOLDING 10808 #ifdef FEAT_FOLDING
10809 linenr_T lnum; 10809 linenr_T lnum;
10810 10810
10811 lnum = get_tv_lnum(argvars); 10811 lnum = get_tv_lnum(argvars);
11581 * "getmatches()" function 11581 * "getmatches()" function
11582 */ 11582 */
11583 static void 11583 static void
11584 f_getmatches(argvars, rettv) 11584 f_getmatches(argvars, rettv)
11585 typval_T *argvars UNUSED; 11585 typval_T *argvars UNUSED;
11586 typval_T *rettv; 11586 typval_T *rettv UNUSED;
11587 { 11587 {
11588 #ifdef FEAT_SEARCH_EXTRA 11588 #ifdef FEAT_SEARCH_EXTRA
11589 dict_T *dict; 11589 dict_T *dict;
11590 matchitem_T *cur = curwin->w_match_head; 11590 matchitem_T *cur = curwin->w_match_head;
11591 11591
13587 /* 13587 /*
13588 * "lispindent(lnum)" function 13588 * "lispindent(lnum)" function
13589 */ 13589 */
13590 static void 13590 static void
13591 f_lispindent(argvars, rettv) 13591 f_lispindent(argvars, rettv)
13592 typval_T *argvars; 13592 typval_T *argvars UNUSED;
13593 typval_T *rettv; 13593 typval_T *rettv;
13594 { 13594 {
13595 #ifdef FEAT_LISP 13595 #ifdef FEAT_LISP
13596 pos_T pos; 13596 pos_T pos;
13597 linenr_T lnum; 13597 linenr_T lnum;
13981 /* 13981 /*
13982 * "matchadd()" function 13982 * "matchadd()" function
13983 */ 13983 */
13984 static void 13984 static void
13985 f_matchadd(argvars, rettv) 13985 f_matchadd(argvars, rettv)
13986 typval_T *argvars; 13986 typval_T *argvars UNUSED;
13987 typval_T *rettv; 13987 typval_T *rettv UNUSED;
13988 { 13988 {
13989 #ifdef FEAT_SEARCH_EXTRA 13989 #ifdef FEAT_SEARCH_EXTRA
13990 char_u buf[NUMBUFLEN]; 13990 char_u buf[NUMBUFLEN];
13991 char_u *grp = get_tv_string_buf_chk(&argvars[0], buf); /* group */ 13991 char_u *grp = get_tv_string_buf_chk(&argvars[0], buf); /* group */
13992 char_u *pat = get_tv_string_buf_chk(&argvars[1], buf); /* pattern */ 13992 char_u *pat = get_tv_string_buf_chk(&argvars[1], buf); /* pattern */
14019 /* 14019 /*
14020 * "matcharg()" function 14020 * "matcharg()" function
14021 */ 14021 */
14022 static void 14022 static void
14023 f_matcharg(argvars, rettv) 14023 f_matcharg(argvars, rettv)
14024 typval_T *argvars; 14024 typval_T *argvars UNUSED;
14025 typval_T *rettv; 14025 typval_T *rettv;
14026 { 14026 {
14027 if (rettv_list_alloc(rettv) == OK) 14027 if (rettv_list_alloc(rettv) == OK)
14028 { 14028 {
14029 #ifdef FEAT_SEARCH_EXTRA 14029 #ifdef FEAT_SEARCH_EXTRA
14051 /* 14051 /*
14052 * "matchdelete()" function 14052 * "matchdelete()" function
14053 */ 14053 */
14054 static void 14054 static void
14055 f_matchdelete(argvars, rettv) 14055 f_matchdelete(argvars, rettv)
14056 typval_T *argvars; 14056 typval_T *argvars UNUSED;
14057 typval_T *rettv; 14057 typval_T *rettv UNUSED;
14058 { 14058 {
14059 #ifdef FEAT_SEARCH_EXTRA 14059 #ifdef FEAT_SEARCH_EXTRA
14060 rettv->vval.v_number = match_delete(curwin, 14060 rettv->vval.v_number = match_delete(curwin,
14061 (int)get_tv_number(&argvars[0]), TRUE); 14061 (int)get_tv_number(&argvars[0]), TRUE);
14062 #endif 14062 #endif
14869 /* 14869 /*
14870 * "reltime()" function 14870 * "reltime()" function
14871 */ 14871 */
14872 static void 14872 static void
14873 f_reltime(argvars, rettv) 14873 f_reltime(argvars, rettv)
14874 typval_T *argvars; 14874 typval_T *argvars UNUSED;
14875 typval_T *rettv; 14875 typval_T *rettv UNUSED;
14876 { 14876 {
14877 #ifdef FEAT_RELTIME 14877 #ifdef FEAT_RELTIME
14878 proftime_T res; 14878 proftime_T res;
14879 proftime_T start; 14879 proftime_T start;
14880 14880
14918 /* 14918 /*
14919 * "reltimestr()" function 14919 * "reltimestr()" function
14920 */ 14920 */
14921 static void 14921 static void
14922 f_reltimestr(argvars, rettv) 14922 f_reltimestr(argvars, rettv)
14923 typval_T *argvars; 14923 typval_T *argvars UNUSED;
14924 typval_T *rettv; 14924 typval_T *rettv;
14925 { 14925 {
14926 #ifdef FEAT_RELTIME 14926 #ifdef FEAT_RELTIME
14927 proftime_T tm; 14927 proftime_T tm;
14928 #endif 14928 #endif
15963 int dir; /* BACKWARD or FORWARD */ 15963 int dir; /* BACKWARD or FORWARD */
15964 char_u *skip; /* skip expression */ 15964 char_u *skip; /* skip expression */
15965 int flags; /* SP_SETPCMARK and other SP_ values */ 15965 int flags; /* SP_SETPCMARK and other SP_ values */
15966 pos_T *match_pos; 15966 pos_T *match_pos;
15967 linenr_T lnum_stop; /* stop at this line if not zero */ 15967 linenr_T lnum_stop; /* stop at this line if not zero */
15968 long time_limit; /* stop after this many msec */ 15968 long time_limit UNUSED; /* stop after this many msec */
15969 { 15969 {
15970 char_u *save_cpo; 15970 char_u *save_cpo;
15971 char_u *pat, *pat2 = NULL, *pat3 = NULL; 15971 char_u *pat, *pat2 = NULL, *pat3 = NULL;
15972 long retval = 0; 15972 long retval = 0;
15973 pos_T pos; 15973 pos_T pos;
16388 /* 16388 /*
16389 * "setmatches()" function 16389 * "setmatches()" function
16390 */ 16390 */
16391 static void 16391 static void
16392 f_setmatches(argvars, rettv) 16392 f_setmatches(argvars, rettv)
16393 typval_T *argvars; 16393 typval_T *argvars UNUSED;
16394 typval_T *rettv; 16394 typval_T *rettv UNUSED;
16395 { 16395 {
16396 #ifdef FEAT_SEARCH_EXTRA 16396 #ifdef FEAT_SEARCH_EXTRA
16397 list_T *l; 16397 list_T *l;
16398 listitem_T *li; 16398 listitem_T *li;
16399 dict_T *d; 16399 dict_T *d;
18461 /* 18461 /*
18462 * "undofile(name)" function 18462 * "undofile(name)" function
18463 */ 18463 */
18464 static void 18464 static void
18465 f_undofile(argvars, rettv) 18465 f_undofile(argvars, rettv)
18466 typval_T *argvars; 18466 typval_T *argvars UNUSED;
18467 typval_T *rettv; 18467 typval_T *rettv;
18468 { 18468 {
18469 rettv->v_type = VAR_STRING; 18469 rettv->v_type = VAR_STRING;
18470 #ifdef FEAT_PERSISTENT_UNDO 18470 #ifdef FEAT_PERSISTENT_UNDO
18471 { 18471 {