mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.1111: inconsistent naming of get_list_tv() and eval_dict() (#23086)
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.
9a78e6df17
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
c15939c1f7
commit
90efe85a99
@ -1674,8 +1674,8 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool
|
|||||||
|
|
||||||
// handle +=, -=, *=, /=, %= and .=
|
// handle +=, -=, *=, /=, %= and .=
|
||||||
di = NULL;
|
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) {
|
&tv, &di, true, false) == OK) {
|
||||||
if ((di == NULL
|
if ((di == NULL
|
||||||
|| (!var_check_ro(di->di_flags, lp->ll_name, TV_CSTRING)
|
|| (!var_check_ro(di->di_flags, lp->ll_name, TV_CSTRING)
|
||||||
&& !tv_check_lock(&di->di_tv, lp->ll_name, TV_CSTRING)))
|
&& !tv_check_lock(&di->di_tv, lp->ll_name, TV_CSTRING)))
|
||||||
@ -3049,7 +3049,7 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
ret = get_number_tv(arg, rettv, evaluate, want_string);
|
ret = eval_number(arg, rettv, evaluate, want_string);
|
||||||
|
|
||||||
// Apply prefixed "-" and "+" now. Matters especially when
|
// Apply prefixed "-" and "+" now. Matters especially when
|
||||||
// "->" follows.
|
// "->" follows.
|
||||||
@ -3060,17 +3060,17 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
|
|
||||||
// String constant: "string".
|
// String constant: "string".
|
||||||
case '"':
|
case '"':
|
||||||
ret = get_string_tv(arg, rettv, evaluate);
|
ret = eval_string(arg, rettv, evaluate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Literal string constant: 'str''ing'.
|
// Literal string constant: 'str''ing'.
|
||||||
case '\'':
|
case '\'':
|
||||||
ret = get_lit_string_tv(arg, rettv, evaluate);
|
ret = eval_lit_string(arg, rettv, evaluate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// List: [expr, expr]
|
// List: [expr, expr]
|
||||||
case '[':
|
case '[':
|
||||||
ret = get_list_tv(arg, rettv, evalarg);
|
ret = eval_list(arg, rettv, evalarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Dictionary: #{key: val, key: val}
|
// Dictionary: #{key: val, key: val}
|
||||||
@ -3094,11 +3094,11 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
|
|
||||||
// Option value: &name
|
// Option value: &name
|
||||||
case '&':
|
case '&':
|
||||||
ret = get_option_tv((const char **)arg, rettv, evaluate);
|
ret = eval_option((const char **)arg, rettv, evaluate);
|
||||||
break;
|
break;
|
||||||
// Environment variable: $VAR.
|
// Environment variable: $VAR.
|
||||||
case '$':
|
case '$':
|
||||||
ret = get_env_tv(arg, rettv, evaluate);
|
ret = eval_env_var(arg, rettv, evaluate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Register contents: @r.
|
// Register contents: @r.
|
||||||
@ -3146,11 +3146,14 @@ static int eval7(char **arg, typval_T *rettv, evalarg_T *const evalarg, bool wan
|
|||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
} else {
|
} else {
|
||||||
const int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
|
const int flags = evalarg == NULL ? 0 : evalarg->eval_flags;
|
||||||
if (**arg == '(') { // recursive!
|
if (**arg == '(') {
|
||||||
|
// "name(..." recursive!
|
||||||
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
|
ret = eval_func(arg, evalarg, s, len, rettv, flags, NULL);
|
||||||
} else if (evaluate) {
|
} 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 {
|
} else {
|
||||||
|
// skip the name
|
||||||
check_vars(s, (size_t)len);
|
check_vars(s, (size_t)len);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
@ -3711,7 +3714,7 @@ static int eval_index(char **arg, typval_T *rettv, evalarg_T *const evalarg, boo
|
|||||||
/// @param[in] evaluate If not true, rettv is not populated.
|
/// @param[in] evaluate If not true, rettv is not populated.
|
||||||
///
|
///
|
||||||
/// @return OK or FAIL.
|
/// @return OK or FAIL.
|
||||||
int get_option_tv(const char **const arg, typval_T *const rettv, const bool evaluate)
|
int eval_option(const char **const arg, typval_T *const rettv, const bool evaluate)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
const bool working = (**arg == '+'); // has("+option")
|
const bool working = (**arg == '+'); // has("+option")
|
||||||
@ -3774,7 +3777,7 @@ int get_option_tv(const char **const arg, typval_T *const rettv, const bool eval
|
|||||||
/// Allocate a variable for a number constant. Also deals with "0z" for blob.
|
/// Allocate a variable for a number constant. Also deals with "0z" for blob.
|
||||||
///
|
///
|
||||||
/// @return OK or FAIL.
|
/// @return OK or FAIL.
|
||||||
static int get_number_tv(char **arg, typval_T *rettv, bool evaluate, bool want_string)
|
static int eval_number(char **arg, typval_T *rettv, bool evaluate, bool want_string)
|
||||||
{
|
{
|
||||||
char *p = skipdigits(*arg + 1);
|
char *p = skipdigits(*arg + 1);
|
||||||
bool get_float = false;
|
bool get_float = false;
|
||||||
@ -3859,7 +3862,7 @@ static int get_number_tv(char **arg, typval_T *rettv, bool evaluate, bool want_s
|
|||||||
/// Allocate a variable for a string constant.
|
/// Allocate a variable for a string constant.
|
||||||
///
|
///
|
||||||
/// @return OK or FAIL.
|
/// @return OK or FAIL.
|
||||||
static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
|
static int eval_string(char **arg, typval_T *rettv, int evaluate)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
unsigned int extra = 0;
|
unsigned int extra = 0;
|
||||||
@ -3972,7 +3975,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
|
|||||||
if (extra != 0) {
|
if (extra != 0) {
|
||||||
name += extra;
|
name += extra;
|
||||||
if (name >= rettv->vval.v_string + len) {
|
if (name >= rettv->vval.v_string + len) {
|
||||||
iemsg("get_string_tv() used more space than allocated");
|
iemsg("eval_string() used more space than allocated");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3999,7 +4002,7 @@ static int get_string_tv(char **arg, typval_T *rettv, int evaluate)
|
|||||||
/// Allocate a variable for a 'str''ing' constant.
|
/// Allocate a variable for a 'str''ing' constant.
|
||||||
///
|
///
|
||||||
/// @return OK or FAIL.
|
/// @return OK or FAIL.
|
||||||
static int get_lit_string_tv(char **arg, typval_T *rettv, int evaluate)
|
static int eval_lit_string(char **arg, typval_T *rettv, int evaluate)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int reduce = 0;
|
int reduce = 0;
|
||||||
@ -4085,7 +4088,7 @@ void partial_unref(partial_T *pt)
|
|||||||
///
|
///
|
||||||
/// @param arg "*arg" points to the "[".
|
/// @param arg "*arg" points to the "[".
|
||||||
/// @return OK or FAIL.
|
/// @return OK or FAIL.
|
||||||
static int get_list_tv(char **arg, typval_T *rettv, evalarg_T *const evalarg)
|
static int eval_list(char **arg, typval_T *rettv, evalarg_T *const evalarg)
|
||||||
{
|
{
|
||||||
const bool evaluate = evalarg == NULL ? false : evalarg->eval_flags & EVAL_EVALUATE;
|
const bool evaluate = evalarg == NULL ? false : evalarg->eval_flags & EVAL_EVALUATE;
|
||||||
list_T *l = NULL;
|
list_T *l = NULL;
|
||||||
@ -4883,7 +4886,7 @@ size_t string2float(const char *const text, float_T *const ret_value)
|
|||||||
/// @param arg Points to the '$'. It is advanced to after the name.
|
/// @param arg Points to the '$'. It is advanced to after the name.
|
||||||
///
|
///
|
||||||
/// @return FAIL if the name is invalid.
|
/// @return FAIL if the name is invalid.
|
||||||
static int get_env_tv(char **arg, typval_T *rettv, int evaluate)
|
static int eval_env_var(char **arg, typval_T *rettv, int evaluate)
|
||||||
{
|
{
|
||||||
(*arg)++;
|
(*arg)++;
|
||||||
char *name = *arg;
|
char *name = *arg;
|
||||||
@ -8420,14 +8423,14 @@ bool eval_has_provider(const char *feat)
|
|||||||
typval_T tv;
|
typval_T tv;
|
||||||
// Get the g:loaded_xx_provider variable.
|
// Get the g:loaded_xx_provider variable.
|
||||||
int len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
|
int len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
|
||||||
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
|
if (eval_variable(buf, len, &tv, NULL, false, true) == FAIL) {
|
||||||
// Trigger autoload once.
|
// Trigger autoload once.
|
||||||
len = snprintf(buf, sizeof(buf), "provider#%s#bogus", name);
|
len = snprintf(buf, sizeof(buf), "provider#%s#bogus", name);
|
||||||
script_autoload(buf, (size_t)len, false);
|
script_autoload(buf, (size_t)len, false);
|
||||||
|
|
||||||
// Retry the (non-autoload-style) variable.
|
// Retry the (non-autoload-style) variable.
|
||||||
len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
|
len = snprintf(buf, sizeof(buf), "g:loaded_%s_provider", name);
|
||||||
if (get_var_tv(buf, len, &tv, NULL, false, true) == FAIL) {
|
if (eval_variable(buf, len, &tv, NULL, false, true) == FAIL) {
|
||||||
// Show a hint if Call() is defined but g:loaded_xx_provider is missing.
|
// Show a hint if Call() is defined but g:loaded_xx_provider is missing.
|
||||||
snprintf(buf, sizeof(buf), "provider#%s#Call", name);
|
snprintf(buf, sizeof(buf), "provider#%s#Call", name);
|
||||||
if (!!find_func(buf) && p_lpl) {
|
if (!!find_func(buf) && p_lpl) {
|
||||||
|
@ -1722,7 +1722,7 @@ static void f_exists(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
xfree(exp);
|
xfree(exp);
|
||||||
}
|
}
|
||||||
} else if (*p == '&' || *p == '+') { // Option.
|
} else if (*p == '&' || *p == '+') { // Option.
|
||||||
n = (get_option_tv(&p, NULL, true) == OK);
|
n = (eval_option(&p, NULL, true) == OK);
|
||||||
if (*skipwhite(p) != NUL) {
|
if (*skipwhite(p) != NUL) {
|
||||||
n = false; // Trailing garbage.
|
n = false; // Trailing garbage.
|
||||||
}
|
}
|
||||||
|
@ -503,8 +503,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first)
|
|||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
name = tofree;
|
name = tofree;
|
||||||
}
|
}
|
||||||
if (get_var_tv(name, len, &tv, NULL, true, false)
|
if (eval_variable(name, len, &tv, NULL, true, false) == FAIL) {
|
||||||
== FAIL) {
|
|
||||||
error = true;
|
error = true;
|
||||||
} else {
|
} else {
|
||||||
// handle d.key, l[idx], f(expr)
|
// handle d.key, l[idx], f(expr)
|
||||||
@ -1076,8 +1075,8 @@ static int do_lock_var(lval_T *lp, char *name_end FUNC_ATTR_UNUSED, exarg_T *eap
|
|||||||
/// @param dip non-NULL when typval's dict item is needed
|
/// @param dip non-NULL when typval's dict item is needed
|
||||||
/// @param verbose may give error message
|
/// @param verbose may give error message
|
||||||
/// @param no_autoload do not use script autoloading
|
/// @param no_autoload do not use script autoloading
|
||||||
int get_var_tv(const char *name, int len, typval_T *rettv, dictitem_T **dip, bool verbose,
|
int eval_variable(const char *name, int len, typval_T *rettv, dictitem_T **dip, bool verbose,
|
||||||
bool no_autoload)
|
bool no_autoload)
|
||||||
{
|
{
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
typval_T *tv = NULL;
|
typval_T *tv = NULL;
|
||||||
@ -1564,7 +1563,7 @@ static void get_var_from(const char *varname, typval_T *rettv, typval_T *deftv,
|
|||||||
tv_dict_set_ret(rettv, opts);
|
tv_dict_set_ret(rettv, opts);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
} else if (get_option_tv(&varname, rettv, true) == OK) {
|
} else if (eval_option(&varname, rettv, true) == OK) {
|
||||||
// Local option
|
// Local option
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -1713,7 +1712,7 @@ bool var_exists(const char *var)
|
|||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
name = tofree;
|
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) {
|
if (n) {
|
||||||
// Handle d.key, l[idx], f(expr).
|
// Handle d.key, l[idx], f(expr).
|
||||||
n = handle_subscript(&var, &tv, &EVALARG_EVALUATE, false) == OK;
|
n = handle_subscript(&var, &tv, &EVALARG_EVALUATE, false) == OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user