0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.0918: duplicate code for evaluating expression argument

Problem:    Duplicate code for evaluating expression argument.
Solution:   Merge the code and make the use more flexible.
This commit is contained in:
Bram Moolenaar
2020-06-07 14:50:50 +02:00
parent e928366de5
commit a9c0104947
7 changed files with 28 additions and 121 deletions

View File

@@ -211,6 +211,18 @@ eval1_emsg(char_u **arg, typval_T *rettv, int evaluate)
return ret;
}
/*
* Return whether a typval is a valid expression to pass to eval_expr_typval()
* or eval_expr_to_bool(). An empty string returns FALSE;
*/
int
eval_expr_valid_arg(typval_T *tv)
{
return tv->v_type != VAR_UNKNOWN
&& (tv->v_type != VAR_STRING
|| (tv->vval.v_string != NULL && *tv->vval.v_string != NUL));
}
/*
* Evaluate an expression, which can be a function, partial or string.
* Pass arguments "argv[argc]".