1
0
forked from aniani/vim

patch 8.2.1111: inconsistent naming of get_list_tv() and eval_dict()

Problem:    Inconsistent naming of get_list_tv() and eval_dict().
Solution:   Rename get_list_tv() to eval_list().  Similarly for eval_number(),
            eval_string(), eval_lit_string() and a few others.
This commit is contained in:
Bram Moolenaar
2020-07-01 18:29:55 +02:00
parent e6b5324e3a
commit 9a78e6df17
12 changed files with 55 additions and 50 deletions

View File

@@ -1224,7 +1224,7 @@ set_var_lval(
// handle +=, -=, *=, /=, %= and .=
di = NULL;
if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
if (eval_variable(lp->ll_name, (int)STRLEN(lp->ll_name),
&tv, &di, TRUE, FALSE) == OK)
{
if ((di == NULL
@@ -2901,7 +2901,7 @@ eval7(
case '7':
case '8':
case '9':
case '.': ret = get_number_tv(arg, rettv, evaluate, want_string);
case '.': ret = eval_number(arg, rettv, evaluate, want_string);
// Apply prefixed "-" and "+" now. Matters especially when
// "->" follows.
@@ -2912,19 +2912,19 @@ eval7(
/*
* String constant: "string".
*/
case '"': ret = get_string_tv(arg, rettv, evaluate);
case '"': ret = eval_string(arg, rettv, evaluate);
break;
/*
* Literal string constant: 'str''ing'.
*/
case '\'': ret = get_lit_string_tv(arg, rettv, evaluate);
case '\'': ret = eval_lit_string(arg, rettv, evaluate);
break;
/*
* List: [expr, expr]
*/
case '[': ret = get_list_tv(arg, rettv, evalarg, TRUE);
case '[': ret = eval_list(arg, rettv, evalarg, TRUE);
break;
/*
@@ -2951,13 +2951,13 @@ eval7(
/*
* Option value: &name
*/
case '&': ret = get_option_tv(arg, rettv, evaluate);
case '&': ret = eval_option(arg, rettv, evaluate);
break;
/*
* Environment variable: $VAR.
*/
case '$': ret = get_env_tv(arg, rettv, evaluate);
case '$': ret = eval_env_var(arg, rettv, evaluate);
break;
/*
@@ -3012,14 +3012,17 @@ eval7(
ret = FAIL;
else
{
if (**arg == '(') // recursive!
if (**arg == '(')
// "name(..." recursive!
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
else if (flags & EVAL_CONSTANT)
ret = FAIL;
else if (evaluate)
ret = get_var_tv(s, len, rettv, NULL, TRUE, FALSE);
// get value of variable
ret = eval_variable(s, len, rettv, NULL, TRUE, FALSE);
else
{
// skip the name
check_vars(s, len);
ret = OK;
}

View File

@@ -2324,7 +2324,7 @@ f_exists(typval_T *argvars, typval_T *rettv)
}
else if (*p == '&' || *p == '+') // option
{
n = (get_option_tv(&p, NULL, TRUE) == OK);
n = (eval_option(&p, NULL, TRUE) == OK);
if (*skipwhite(p) != NUL)
n = FALSE; // trailing garbage
}

View File

@@ -1124,7 +1124,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first)
{
if (tofree != NULL)
name = tofree;
if (get_var_tv(name, len, &tv, NULL, TRUE, FALSE) == FAIL)
if (eval_variable(name, len, &tv, NULL, TRUE, FALSE) == FAIL)
error = TRUE;
else
{
@@ -2365,7 +2365,7 @@ set_cmdarg(exarg_T *eap, char_u *oldarg)
* Return OK or FAIL. If OK is returned "rettv" must be cleared.
*/
int
get_var_tv(
eval_variable(
char_u *name,
int len, // length of "name"
typval_T *rettv, // NULL when only checking existence
@@ -3206,7 +3206,7 @@ getwinvar(
done = TRUE;
}
}
else if (get_option_tv(&varname, rettv, 1) == OK)
else if (eval_option(&varname, rettv, 1) == OK)
// window-local-option
done = TRUE;
}
@@ -3342,7 +3342,7 @@ var_exists(char_u *var)
{
if (tofree != NULL)
name = tofree;
n = (get_var_tv(name, len, &tv, NULL, FALSE, TRUE) == OK);
n = (eval_variable(name, len, &tv, NULL, FALSE, TRUE) == OK);
if (n)
{
// handle d.key, l[idx], f(expr)
@@ -3609,7 +3609,7 @@ f_getbufvar(typval_T *argvars, typval_T *rettv)
done = TRUE;
}
}
else if (get_option_tv(&varname, rettv, TRUE) == OK)
else if (eval_option(&varname, rettv, TRUE) == OK)
// buffer-local-option
done = TRUE;

View File

@@ -1160,7 +1160,7 @@ f_join(typval_T *argvars, typval_T *rettv)
* Return OK or FAIL.
*/
int
get_list_tv(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
{
int evaluate = evalarg == NULL ? FALSE
: evalarg->eval_flags & EVAL_EVALUATE;

View File

@@ -52,7 +52,7 @@ void set_reg_var(int c);
char_u *v_exception(char_u *oldval);
char_u *v_throwpoint(char_u *oldval);
char_u *set_cmdarg(exarg_T *eap, char_u *oldarg);
int get_var_tv(char_u *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload);
int eval_variable(char_u *name, int len, typval_T *rettv, dictitem_T **dip, int verbose, int no_autoload);
void check_vars(char_u *name, int len);
dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload);
dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, int no_autoload);

View File

@@ -39,7 +39,7 @@ void vimlist_remove(list_T *l, listitem_T *item, listitem_T *item2);
char_u *list2string(typval_T *tv, int copyID, int restore_copyID);
int list_join(garray_T *gap, list_T *l, char_u *sep, int echo_style, int restore_copyID, int copyID);
void f_join(typval_T *argvars, typval_T *rettv);
int get_list_tv(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error);
int eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error);
int write_list(FILE *fd, list_T *list, int binary);
void init_static_list(staticList10_T *sl);
void f_list2str(typval_T *argvars, typval_T *rettv);

View File

@@ -4,18 +4,6 @@ typval_T *alloc_string_tv(char_u *s);
void free_tv(typval_T *varp);
void clear_tv(typval_T *varp);
void init_tv(typval_T *varp);
int tv_check_lock(typval_T *tv, char_u *name, int use_gettext);
void copy_tv(typval_T *from, typval_T *to);
int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int ic);
char_u *typval_tostring(typval_T *arg);
int tv_islocked(typval_T *tv);
int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
int get_option_tv(char_u **arg, typval_T *rettv, int evaluate);
int get_number_tv(char_u **arg, typval_T *rettv, int evaluate, int want_string);
int get_string_tv(char_u **arg, typval_T *rettv, int evaluate);
int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate);
char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
int get_env_tv(char_u **arg, typval_T *rettv, int evaluate);
varnumber_T tv_get_number(typval_T *varp);
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
float_T tv_get_float(typval_T *varp);
@@ -23,8 +11,20 @@ char_u *tv_get_string(typval_T *varp);
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
char_u *tv_get_string_chk(typval_T *varp);
char_u *tv_get_string_buf_chk(typval_T *varp, char_u *buf);
char_u *tv_stringify(typval_T *varp, char_u *buf);
int tv_check_lock(typval_T *tv, char_u *name, int use_gettext);
void copy_tv(typval_T *from, typval_T *to);
int typval_compare(typval_T *typ1, typval_T *typ2, exptype_T type, int ic);
char_u *typval_tostring(typval_T *arg);
int tv_islocked(typval_T *tv);
int tv_equal(typval_T *tv1, typval_T *tv2, int ic, int recursive);
int eval_option(char_u **arg, typval_T *rettv, int evaluate);
int eval_number(char_u **arg, typval_T *rettv, int evaluate, int want_string);
int eval_string(char_u **arg, typval_T *rettv, int evaluate);
int eval_lit_string(char_u **arg, typval_T *rettv, int evaluate);
char_u *tv2string(typval_T *tv, char_u **tofree, char_u *numbuf, int copyID);
int eval_env_var(char_u **arg, typval_T *rettv, int evaluate);
linenr_T tv_get_lnum(typval_T *argvars);
linenr_T tv_get_lnum_buf(typval_T *argvars, buf_T *buf);
buf_T *tv_get_buf(typval_T *tv, int curtab_only);
char_u *tv_stringify(typval_T *varp, char_u *buf);
/* vim: set ft=c : */

View File

@@ -992,7 +992,7 @@ tv_equal(
* Return OK or FAIL.
*/
int
get_option_tv(
eval_option(
char_u **arg,
typval_T *rettv, // when NULL, only check if option exists
int evaluate)
@@ -1069,7 +1069,7 @@ get_option_tv(
* Return OK or FAIL.
*/
int
get_number_tv(
eval_number(
char_u **arg,
typval_T *rettv,
int evaluate,
@@ -1179,7 +1179,7 @@ get_number_tv(
* Return OK or FAIL.
*/
int
get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
eval_string(char_u **arg, typval_T *rettv, int evaluate)
{
char_u *p;
char_u *end;
@@ -1297,7 +1297,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
{
end += extra;
if (end >= rettv->vval.v_string + len)
iemsg("get_string_tv() used more space than allocated");
iemsg("eval_string() used more space than allocated");
break;
}
}
@@ -1323,7 +1323,7 @@ get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
* Return OK or FAIL.
*/
int
get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
eval_lit_string(char_u **arg, typval_T *rettv, int evaluate)
{
char_u *p;
char_u *str;
@@ -1401,7 +1401,7 @@ tv2string(
* Return FAIL if the name is invalid.
*/
int
get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
eval_env_var(char_u **arg, typval_T *rettv, int evaluate)
{
char_u *string = NULL;
int len;

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1111,
/**/
1110,
/**/

View File

@@ -2868,9 +2868,9 @@ compile_call(
argvars[0].v_type = VAR_UNKNOWN;
if (*s == '"')
(void)get_string_tv(&s, &argvars[0], TRUE);
(void)eval_string(&s, &argvars[0], TRUE);
else if (*s == '\'')
(void)get_lit_string_tv(&s, &argvars[0], TRUE);
(void)eval_lit_string(&s, &argvars[0], TRUE);
s = skipwhite(s);
if (*s == ')' && argvars[0].v_type == VAR_STRING)
{
@@ -2992,7 +2992,7 @@ to_name_const_end(char_u *arg)
{
// Can be "[1, 2, 3]->Func()".
if (get_list_tv(&p, &rettv, NULL, FALSE) == FAIL)
if (eval_list(&p, &rettv, NULL, FALSE) == FAIL)
p = arg;
}
else if (p == arg && *arg == '#' && arg[1] == '{')
@@ -3270,10 +3270,10 @@ compile_get_option(char_u **arg, cctx_T *cctx)
// parse the option and get the current value to get the type.
rettv.v_type = VAR_UNKNOWN;
ret = get_option_tv(arg, &rettv, TRUE);
ret = eval_option(arg, &rettv, TRUE);
if (ret == OK)
{
// include the '&' in the name, get_option_tv() expects it.
// include the '&' in the name, eval_option() expects it.
char_u *name = vim_strnsave(start, *arg - start);
type_T *type = rettv.v_type == VAR_NUMBER ? &t_number : &t_string;
@@ -3304,7 +3304,7 @@ compile_get_env(char_u **arg, cctx_T *cctx)
return FAIL;
}
// include the '$' in the name, get_env_tv() expects it.
// include the '$' in the name, eval_env_var() expects it.
name = vim_strnsave(start, len + 1);
ret = generate_LOAD(cctx, ISN_LOADENV, 0, name, &t_string);
vim_free(name);
@@ -3761,21 +3761,21 @@ compile_expr7(
case '7':
case '8':
case '9':
case '.': if (get_number_tv(arg, rettv, TRUE, FALSE) == FAIL)
case '.': if (eval_number(arg, rettv, TRUE, FALSE) == FAIL)
return FAIL;
break;
/*
* String constant: "string".
*/
case '"': if (get_string_tv(arg, rettv, TRUE) == FAIL)
case '"': if (eval_string(arg, rettv, TRUE) == FAIL)
return FAIL;
break;
/*
* Literal string constant: 'str''ing'.
*/
case '\'': if (get_lit_string_tv(arg, rettv, TRUE) == FAIL)
case '\'': if (eval_lit_string(arg, rettv, TRUE) == FAIL)
return FAIL;
break;

View File

@@ -1089,7 +1089,7 @@ call_def_function(
// compilation: don't set SOURCING_LNUM.
if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
goto failed;
if (get_option_tv(&name, &optval, TRUE) == FAIL)
if (eval_option(&name, &optval, TRUE) == FAIL)
goto failed;
*STACK_TV_BOT(0) = optval;
++ectx.ec_stack.ga_len;
@@ -1105,7 +1105,7 @@ call_def_function(
if (GA_GROW(&ectx.ec_stack, 1) == FAIL)
goto failed;
// name is always valid, checked when compiling
(void)get_env_tv(&name, &optval, TRUE);
(void)eval_env_var(&name, &optval, TRUE);
*STACK_TV_BOT(0) = optval;
++ectx.ec_stack.ga_len;
}

View File

@@ -302,9 +302,9 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
tv.v_type = VAR_UNKNOWN;
// TODO: should we accept any expression?
if (*arg == '\'')
ret = get_lit_string_tv(&arg, &tv, TRUE);
ret = eval_lit_string(&arg, &tv, TRUE);
else if (*arg == '"')
ret = get_string_tv(&arg, &tv, TRUE);
ret = eval_string(&arg, &tv, TRUE);
if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL)
{
emsg(_("E1071: Invalid string after \"from\""));