comparison src/eval.c @ 271:8d34af900bae v7.0072

updated for version 7.0072
author vimboss
date Wed, 18 May 2005 22:24:46 +0000
parents e7904492cb75
children 8fa8d7964cf1
comparison
equal deleted inserted replaced
270:a20218704019 271:8d34af900bae
578 static win_T *find_win_by_nr __ARGS((typval_T *vp)); 578 static win_T *find_win_by_nr __ARGS((typval_T *vp));
579 static pos_T *var2fpos __ARGS((typval_T *varp, int lnum)); 579 static pos_T *var2fpos __ARGS((typval_T *varp, int lnum));
580 static int get_env_len __ARGS((char_u **arg)); 580 static int get_env_len __ARGS((char_u **arg));
581 static int get_id_len __ARGS((char_u **arg)); 581 static int get_id_len __ARGS((char_u **arg));
582 static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose)); 582 static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
583 static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end, int incl_br)); 583 static char_u *find_name_end __ARGS((char_u *arg, char_u **expr_start, char_u **expr_end, int flags));
584 #define FNE_INCL_BR 1 /* find_name_end(): include [] in name */
585 #define FNE_CHECK_START 2 /* find_name_end(): check name starts with
586 valid character */
584 static int eval_isnamec __ARGS((int c)); 587 static int eval_isnamec __ARGS((int c));
588 static int eval_isnamec1 __ARGS((int c));
585 static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose)); 589 static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose));
586 static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose)); 590 static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose));
587 static typval_T *alloc_tv __ARGS((void)); 591 static typval_T *alloc_tv __ARGS((void));
588 static typval_T *alloc_string_tv __ARGS((char_u *string)); 592 static typval_T *alloc_string_tv __ARGS((char_u *string));
589 static void free_tv __ARGS((typval_T *varp)); 593 static void free_tv __ARGS((typval_T *varp));
648 static void list_win_vars __ARGS((void)); 652 static void list_win_vars __ARGS((void));
649 static void list_vim_vars __ARGS((void)); 653 static void list_vim_vars __ARGS((void));
650 static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg)); 654 static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg));
651 static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op)); 655 static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
652 static int check_changedtick __ARGS((char_u *arg)); 656 static int check_changedtick __ARGS((char_u *arg));
653 static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int quiet)); 657 static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int quiet, int fne_flags));
654 static void clear_lval __ARGS((lval_T *lp)); 658 static void clear_lval __ARGS((lval_T *lp));
655 static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op)); 659 static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op));
656 static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u *op)); 660 static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u *op));
657 static void list_add_watch __ARGS((list_T *l, listwatch_T *lw)); 661 static void list_add_watch __ARGS((list_T *l, listwatch_T *lw));
658 static void list_rem_watch __ARGS((list_T *l, listwatch_T *lwrem)); 662 static void list_rem_watch __ARGS((list_T *l, listwatch_T *lwrem));
661 static int do_unlet_var __ARGS((lval_T *lp, char_u *name_end, int forceit)); 665 static int do_unlet_var __ARGS((lval_T *lp, char_u *name_end, int forceit));
662 static int do_lock_var __ARGS((lval_T *lp, char_u *name_end, int deep, int lock)); 666 static int do_lock_var __ARGS((lval_T *lp, char_u *name_end, int deep, int lock));
663 static void item_lock __ARGS((typval_T *tv, int deep, int lock)); 667 static void item_lock __ARGS((typval_T *tv, int deep, int lock));
664 static int tv_islocked __ARGS((typval_T *tv)); 668 static int tv_islocked __ARGS((typval_T *tv));
665 669
670 /* Character used as separated in autoload function/variable names. */
671 #define AUTOLOAD_CHAR '#'
672
666 /* 673 /*
667 * Initialize the global and v: variables. 674 * Initialize the global and v: variables.
668 */ 675 */
669 void 676 void
670 eval_init() 677 eval_init()
790 int save_emsg; 797 int save_emsg;
791 int err; 798 int err;
792 typval_T tv; 799 typval_T tv;
793 800
794 /* Make sure a valid variable name is specified */ 801 /* Make sure a valid variable name is specified */
795 if (!eval_isnamec(*name) || VIM_ISDIGIT(*name)) 802 if (!eval_isnamec1(*name))
796 { 803 {
797 EMSG(_(e_invarg)); 804 EMSG(_(e_invarg));
798 return FAIL; 805 return FAIL;
799 } 806 }
800 807
808 var_redir_stop(); 815 var_redir_stop();
809 return FAIL; 816 return FAIL;
810 } 817 }
811 818
812 /* Parse the variable name (can be a dict or list entry). */ 819 /* Parse the variable name (can be a dict or list entry). */
813 redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE); 820 redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE,
821 FNE_CHECK_START);
814 if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL) 822 if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL)
815 { 823 {
816 if (redir_endp != NULL && *redir_endp != NUL) 824 if (redir_endp != NULL && *redir_endp != NUL)
817 /* Trailing characters are present after the variable name */ 825 /* Trailing characters are present after the variable name */
818 EMSG(_(e_trailing)); 826 EMSG(_(e_trailing));
1549 skip_var_one(arg) 1557 skip_var_one(arg)
1550 char_u *arg; 1558 char_u *arg;
1551 { 1559 {
1552 if (vim_strchr((char_u *)"$@&", *arg) != NULL) 1560 if (vim_strchr((char_u *)"$@&", *arg) != NULL)
1553 ++arg; 1561 ++arg;
1554 return find_name_end(arg, NULL, NULL, TRUE); 1562 return find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
1555 } 1563 }
1556 1564
1557 /* 1565 /*
1558 * List variables for hashtab "ht" with prefix "prefix". 1566 * List variables for hashtab "ht" with prefix "prefix".
1559 * If "empty" is TRUE also list NULL strings as empty strings. 1567 * If "empty" is TRUE also list NULL strings as empty strings.
1641 1649
1642 while (!ends_excmd(*arg) && !got_int) 1650 while (!ends_excmd(*arg) && !got_int)
1643 { 1651 {
1644 if (error || eap->skip) 1652 if (error || eap->skip)
1645 { 1653 {
1646 arg = find_name_end(arg, NULL, NULL, TRUE); 1654 arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
1647 if (!vim_iswhite(*arg) && !ends_excmd(*arg)) 1655 if (!vim_iswhite(*arg) && !ends_excmd(*arg))
1648 { 1656 {
1649 emsg_severe = TRUE; 1657 emsg_severe = TRUE;
1650 EMSG(_(e_trailing)); 1658 EMSG(_(e_trailing));
1651 break; 1659 break;
1886 1894
1887 /* 1895 /*
1888 * ":let var = expr": Set internal variable. 1896 * ":let var = expr": Set internal variable.
1889 * ":let {expr} = expr": Idem, name made with curly braces 1897 * ":let {expr} = expr": Idem, name made with curly braces
1890 */ 1898 */
1891 else if ((eval_isnamec(*arg) && !VIM_ISDIGIT(*arg)) || *arg == '{') 1899 else if (eval_isnamec1(*arg) || *arg == '{')
1892 { 1900 {
1893 lval_T lv; 1901 lval_T lv;
1894 1902
1895 p = get_lval(arg, tv, &lv, FALSE, FALSE, FALSE); 1903 p = get_lval(arg, tv, &lv, FALSE, FALSE, FALSE, FNE_CHECK_START);
1896 if (p != NULL && lv.ll_name != NULL) 1904 if (p != NULL && lv.ll_name != NULL)
1897 { 1905 {
1898 if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL) 1906 if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL)
1899 EMSG(_(e_letunexp)); 1907 EMSG(_(e_letunexp));
1900 else 1908 else
1940 * Returns a pointer to just after the name, including indexes. 1948 * Returns a pointer to just after the name, including indexes.
1941 * When an evaluation error occurs "lp->ll_name" is NULL; 1949 * When an evaluation error occurs "lp->ll_name" is NULL;
1942 * Returns NULL for a parsing error. Still need to free items in "lp"! 1950 * Returns NULL for a parsing error. Still need to free items in "lp"!
1943 */ 1951 */
1944 static char_u * 1952 static char_u *
1945 get_lval(name, rettv, lp, unlet, skip, quiet) 1953 get_lval(name, rettv, lp, unlet, skip, quiet, fne_flags)
1946 char_u *name; 1954 char_u *name;
1947 typval_T *rettv; 1955 typval_T *rettv;
1948 lval_T *lp; 1956 lval_T *lp;
1949 int unlet; 1957 int unlet;
1950 int skip; 1958 int skip;
1951 int quiet; /* don't give error messages */ 1959 int quiet; /* don't give error messages */
1960 int fne_flags; /* flags for find_name_end() */
1952 { 1961 {
1953 char_u *p; 1962 char_u *p;
1954 char_u *expr_start, *expr_end; 1963 char_u *expr_start, *expr_end;
1955 int cc; 1964 int cc;
1956 dictitem_T *v; 1965 dictitem_T *v;
1967 1976
1968 if (skip) 1977 if (skip)
1969 { 1978 {
1970 /* When skipping just find the end of the name. */ 1979 /* When skipping just find the end of the name. */
1971 lp->ll_name = name; 1980 lp->ll_name = name;
1972 return find_name_end(name, NULL, NULL, TRUE); 1981 return find_name_end(name, NULL, NULL, FNE_INCL_BR | fne_flags);
1973 } 1982 }
1974 1983
1975 /* Find the end of the name. */ 1984 /* Find the end of the name. */
1976 p = find_name_end(name, &expr_start, &expr_end, FALSE); 1985 p = find_name_end(name, &expr_start, &expr_end, fne_flags);
1977 if (expr_start != NULL) 1986 if (expr_start != NULL)
1978 { 1987 {
1979 /* Don't expand the name when we already know there is an error. */ 1988 /* Don't expand the name when we already know there is an error. */
1980 if (unlet && !vim_iswhite(*p) && !ends_excmd(*p) 1989 if (unlet && !vim_iswhite(*p) && !ends_excmd(*p)
1981 && *p != '[' && *p != '.') 1990 && *p != '[' && *p != '.')
2840 lval_T lv; 2849 lval_T lv;
2841 2850
2842 do 2851 do
2843 { 2852 {
2844 /* Parse the name and find the end. */ 2853 /* Parse the name and find the end. */
2845 name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error, FALSE); 2854 name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error, FALSE,
2855 FNE_CHECK_START);
2846 if (lv.ll_name == NULL) 2856 if (lv.ll_name == NULL)
2847 error = TRUE; /* error but continue parsing */ 2857 error = TRUE; /* error but continue parsing */
2848 if (name_end == NULL || (!vim_iswhite(*name_end) 2858 if (name_end == NULL || (!vim_iswhite(*name_end)
2849 && !ends_excmd(*name_end))) 2859 && !ends_excmd(*name_end)))
2850 { 2860 {
10176 lval_T lv; 10186 lval_T lv;
10177 char_u *end; 10187 char_u *end;
10178 dictitem_T *di; 10188 dictitem_T *di;
10179 10189
10180 rettv->vval.v_number = -1; 10190 rettv->vval.v_number = -1;
10181 end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE, FALSE); 10191 end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE, FALSE,
10192 FNE_CHECK_START);
10182 if (end != NULL && lv.ll_name != NULL) 10193 if (end != NULL && lv.ll_name != NULL)
10183 { 10194 {
10184 if (*end != NUL) 10195 if (*end != NUL)
10185 EMSG(_(e_trailing)); 10196 EMSG(_(e_trailing));
10186 else 10197 else
13965 } 13976 }
13966 13977
13967 /* 13978 /*
13968 * Find the end of the name; check for {} construction. 13979 * Find the end of the name; check for {} construction.
13969 */ 13980 */
13970 p = find_name_end(*arg, &expr_start, &expr_end, FALSE); 13981 p = find_name_end(*arg, &expr_start, &expr_end,
13982 len > 0 ? 0 : FNE_CHECK_START);
13971 if (expr_start != NULL) 13983 if (expr_start != NULL)
13972 { 13984 {
13973 char_u *temp_string; 13985 char_u *temp_string;
13974 13986
13975 if (!evaluate) 13987 if (!evaluate)
14000 14012
14001 /* 14013 /*
14002 * Find the end of a variable or function name, taking care of magic braces. 14014 * Find the end of a variable or function name, taking care of magic braces.
14003 * If "expr_start" is not NULL then "expr_start" and "expr_end" are set to the 14015 * If "expr_start" is not NULL then "expr_start" and "expr_end" are set to the
14004 * start and end of the first magic braces item. 14016 * start and end of the first magic braces item.
14017 * "flags" can have FNE_INCL_BR and FNE_CHECK_START.
14005 * Return a pointer to just after the name. Equal to "arg" if there is no 14018 * Return a pointer to just after the name. Equal to "arg" if there is no
14006 * valid name. 14019 * valid name.
14007 */ 14020 */
14008 static char_u * 14021 static char_u *
14009 find_name_end(arg, expr_start, expr_end, incl_br) 14022 find_name_end(arg, expr_start, expr_end, flags)
14010 char_u *arg; 14023 char_u *arg;
14011 char_u **expr_start; 14024 char_u **expr_start;
14012 char_u **expr_end; 14025 char_u **expr_end;
14013 int incl_br; /* Include [] indexes and .name */ 14026 int flags;
14014 { 14027 {
14015 int mb_nest = 0; 14028 int mb_nest = 0;
14016 int br_nest = 0; 14029 int br_nest = 0;
14017 char_u *p; 14030 char_u *p;
14018 14031
14020 { 14033 {
14021 *expr_start = NULL; 14034 *expr_start = NULL;
14022 *expr_end = NULL; 14035 *expr_end = NULL;
14023 } 14036 }
14024 14037
14038 /* Quick check for valid starting character. */
14039 if ((flags & FNE_CHECK_START) && !eval_isnamec1(*arg) && *arg != '{')
14040 return arg;
14041
14025 for (p = arg; *p != NUL 14042 for (p = arg; *p != NUL
14026 && (eval_isnamec(*p) 14043 && (eval_isnamec(*p)
14027 || *p == '{' 14044 || *p == '{'
14028 || (incl_br && (*p == '[' || *p == '.')) 14045 || ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.'))
14029 || mb_nest != 0 14046 || mb_nest != 0
14030 || br_nest != 0); ++p) 14047 || br_nest != 0); ++p)
14031 { 14048 {
14032 if (mb_nest == 0) 14049 if (mb_nest == 0)
14033 { 14050 {
14106 *expr_start = '{'; 14123 *expr_start = '{';
14107 *expr_end = '}'; 14124 *expr_end = '}';
14108 14125
14109 if (retval != NULL) 14126 if (retval != NULL)
14110 { 14127 {
14111 temp_result = find_name_end(retval, &expr_start, &expr_end, FALSE); 14128 temp_result = find_name_end(retval, &expr_start, &expr_end, 0);
14112 if (expr_start != NULL) 14129 if (expr_start != NULL)
14113 { 14130 {
14114 /* Further expansion! */ 14131 /* Further expansion! */
14115 temp_result = make_expanded_name(retval, expr_start, 14132 temp_result = make_expanded_name(retval, expr_start,
14116 expr_end, temp_result); 14133 expr_end, temp_result);
14128 */ 14145 */
14129 static int 14146 static int
14130 eval_isnamec(c) 14147 eval_isnamec(c)
14131 int c; 14148 int c;
14132 { 14149 {
14133 return (ASCII_ISALNUM(c) || c == '_' || c == ':'); 14150 return (ASCII_ISALNUM(c) || c == '_' || c == ':' || c == AUTOLOAD_CHAR);
14151 }
14152
14153 /*
14154 * Return TRUE if character "c" can be used as the first character in a
14155 * variable or function name (excluding '{' and '}').
14156 */
14157 static int
14158 eval_isnamec1(c)
14159 int c;
14160 {
14161 return (ASCII_ISALPHA(c) || c == '_');
14134 } 14162 }
14135 14163
14136 /* 14164 /*
14137 * Set number v: variable to "val". 14165 * Set number v: variable to "val".
14138 */ 14166 */
14727 char_u *name; 14755 char_u *name;
14728 char_u **varname; 14756 char_u **varname;
14729 { 14757 {
14730 if (name[1] != ':') 14758 if (name[1] != ':')
14731 { 14759 {
14732 /* The name must not start with a colon. */ 14760 /* The name must not start with a colon or #. */
14733 if (name[0] == ':') 14761 if (name[0] == ':' || name[0] == AUTOLOAD_CHAR)
14734 return NULL; 14762 return NULL;
14735 *varname = name; 14763 *varname = name;
14736 14764
14737 /* "version" is "v:version" in all scopes */ 14765 /* "version" is "v:version" in all scopes */
14738 if (!HASHITEM_EMPTY(hash_find(&compat_hashtab, name))) 14766 if (!HASHITEM_EMPTY(hash_find(&compat_hashtab, name)))
14743 return &current_funccal->l_vars.dv_hashtab; /* l: variable */ 14771 return &current_funccal->l_vars.dv_hashtab; /* l: variable */
14744 } 14772 }
14745 *varname = name + 2; 14773 *varname = name + 2;
14746 if (*name == 'g') /* global variable */ 14774 if (*name == 'g') /* global variable */
14747 return &globvarht; 14775 return &globvarht;
14748 /* There must be no ':' in the rest of the name, unless g: is used */ 14776 /* There must be no ':' or '#' in the rest of the name, unless g: is used
14749 if (vim_strchr(name + 2, ':') != NULL) 14777 */
14778 if (vim_strchr(name + 2, ':') != NULL
14779 || vim_strchr(name + 2, AUTOLOAD_CHAR) != NULL)
14750 return NULL; 14780 return NULL;
14751 if (*name == 'b') /* buffer variable */ 14781 if (*name == 'b') /* buffer variable */
14752 return &curbuf->b_vars.dv_hashtab; 14782 return &curbuf->b_vars.dv_hashtab;
14753 if (*name == 'w') /* window variable */ 14783 if (*name == 'w') /* window variable */
14754 return &curwin->w_vars.dv_hashtab; 14784 return &curwin->w_vars.dv_hashtab;
15884 goto erret; 15914 goto erret;
15885 } 15915 }
15886 15916
15887 if (fp == NULL) 15917 if (fp == NULL)
15888 { 15918 {
15889 if (fudi.fd_dict == NULL && vim_strchr(name, ':') != NULL) 15919 if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL)
15890 { 15920 {
15891 int slen, plen; 15921 int slen, plen;
15892 char_u *scriptname; 15922 char_u *scriptname;
15893 15923
15894 /* Check that the autoload name matches the script name. */ 15924 /* Check that the autoload name matches the script name. */
16016 * don't skip over "s:", get_lval() needs it for "s:dict.func". */ 16046 * don't skip over "s:", get_lval() needs it for "s:dict.func". */
16017 lead = eval_fname_script(start); 16047 lead = eval_fname_script(start);
16018 if (lead > 2) 16048 if (lead > 2)
16019 start += lead; 16049 start += lead;
16020 16050
16021 end = get_lval(start, NULL, &lv, FALSE, skip, flags & TFN_QUIET); 16051 end = get_lval(start, NULL, &lv, FALSE, skip, flags & TFN_QUIET,
16052 lead > 2 ? 0 : FNE_CHECK_START);
16022 if (end == start) 16053 if (end == start)
16023 { 16054 {
16024 if (!skip) 16055 if (!skip)
16025 EMSG(_("E129: Function name required")); 16056 EMSG(_("E129: Function name required"));
16026 goto theend; 16057 goto theend;
16036 { 16067 {
16037 if (end != NULL) 16068 if (end != NULL)
16038 EMSG2(_(e_invarg2), start); 16069 EMSG2(_(e_invarg2), start);
16039 } 16070 }
16040 else 16071 else
16041 *pp = find_name_end(start, NULL, NULL, TRUE); 16072 *pp = find_name_end(start, NULL, NULL, FNE_INCL_BR);
16042 goto theend; 16073 goto theend;
16043 } 16074 }
16044 16075
16045 if (lv.ll_tv != NULL) 16076 if (lv.ll_tv != NULL)
16046 { 16077 {
16234 return n; 16265 return n;
16235 } 16266 }
16236 16267
16237 /* 16268 /*
16238 * Return TRUE if "name" looks like a builtin function name: starts with a 16269 * Return TRUE if "name" looks like a builtin function name: starts with a
16239 * lower case letter and doesn't contain a ':'. 16270 * lower case letter and doesn't contain a ':' or AUTOLOAD_CHAR.
16240 */ 16271 */
16241 static int 16272 static int
16242 builtin_function(name) 16273 builtin_function(name)
16243 char_u *name; 16274 char_u *name;
16244 { 16275 {
16245 return ASCII_ISLOWER(name[0]) && vim_strchr(name, ':') == NULL; 16276 return ASCII_ISLOWER(name[0]) && vim_strchr(name, ':') == NULL
16277 && vim_strchr(name, AUTOLOAD_CHAR) == NULL;
16246 } 16278 }
16247 16279
16248 #if defined(FEAT_PROFILE) || defined(PROTO) 16280 #if defined(FEAT_PROFILE) || defined(PROTO)
16249 /* 16281 /*
16250 * Start profiling function "fp". 16282 * Start profiling function "fp".
16438 char_u *p; 16470 char_u *p;
16439 char_u *scriptname; 16471 char_u *scriptname;
16440 int ret = FALSE; 16472 int ret = FALSE;
16441 16473
16442 /* If there is no colon after name[1] there is no package name. */ 16474 /* If there is no colon after name[1] there is no package name. */
16443 p = vim_strchr(name, ':'); 16475 p = vim_strchr(name, AUTOLOAD_CHAR);
16444 if (p == NULL || p <= name + 2) 16476 if (p == NULL || p <= name + 2)
16445 return FALSE; 16477 return FALSE;
16446 16478
16447 /* Try loading the package from $VIMRUNTIME/autoload/<name>.vim */ 16479 /* Try loading the package from $VIMRUNTIME/autoload/<name>.vim */
16448 scriptname = autoload_name(name); 16480 scriptname = autoload_name(name);
16462 char_u *name; 16494 char_u *name;
16463 { 16495 {
16464 char_u *p; 16496 char_u *p;
16465 char_u *scriptname; 16497 char_u *scriptname;
16466 16498
16467 /* Get the script file name: replace ':' with '/', append ".vim". */ 16499 /* Get the script file name: replace '#' with '/', append ".vim". */
16468 scriptname = alloc((unsigned)(STRLEN(name) + 14)); 16500 scriptname = alloc((unsigned)(STRLEN(name) + 14));
16469 if (scriptname == NULL) 16501 if (scriptname == NULL)
16470 return FALSE; 16502 return FALSE;
16471 STRCPY(scriptname, "autoload/"); 16503 STRCPY(scriptname, "autoload/");
16472 STRCAT(scriptname, name); 16504 STRCAT(scriptname, name);
16473 *vim_strrchr(scriptname, ':') = NUL; 16505 *vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
16474 STRCAT(scriptname, ".vim"); 16506 STRCAT(scriptname, ".vim");
16475 while ((p = vim_strchr(scriptname, ':')) != NULL) 16507 while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
16476 *p = '/'; 16508 *p = '/';
16477 return scriptname; 16509 return scriptname;
16478 } 16510 }
16479 16511
16480 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) 16512 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
16850 if (argvars[i].v_type == VAR_NUMBER) 16882 if (argvars[i].v_type == VAR_NUMBER)
16851 msg_outnum((long)argvars[i].vval.v_number); 16883 msg_outnum((long)argvars[i].vval.v_number);
16852 else 16884 else
16853 { 16885 {
16854 trunc_string(tv2string(&argvars[i], &tofree, numbuf), 16886 trunc_string(tv2string(&argvars[i], &tofree, numbuf),
16855 buf, MSG_BUF_LEN); 16887 buf, MSG_BUF_CLEN);
16856 msg_puts(buf); 16888 msg_puts(buf);
16857 vim_free(tofree); 16889 vim_free(tofree);
16858 } 16890 }
16859 } 16891 }
16860 msg_puts((char_u *)")"); 16892 msg_puts((char_u *)")");
16938 char_u buf[MSG_BUF_LEN]; 16970 char_u buf[MSG_BUF_LEN];
16939 char_u numbuf[NUMBUFLEN]; 16971 char_u numbuf[NUMBUFLEN];
16940 char_u *tofree; 16972 char_u *tofree;
16941 16973
16942 trunc_string(tv2string(fc.rettv, &tofree, numbuf), 16974 trunc_string(tv2string(fc.rettv, &tofree, numbuf),
16943 buf, MSG_BUF_LEN); 16975 buf, MSG_BUF_CLEN);
16944 smsg((char_u *)_("%s returning %s"), sn, buf); 16976 smsg((char_u *)_("%s returning %s"), sn, buf);
16945 vim_free(tofree); 16977 vim_free(tofree);
16946 } 16978 }
16947 msg_puts((char_u *)"\n"); /* don't overwrite this either */ 16979 msg_puts((char_u *)"\n"); /* don't overwrite this either */
16948 cmdline_row = msg_row; 16980 cmdline_row = msg_row;