Mercurial > vim
diff src/eval.c @ 20731:ab27db64f1fb v8.2.0918
patch 8.2.0918: duplicate code for evaluating expression argument
Commit: https://github.com/vim/vim/commit/a9c010494767e43a51c443cac35ebc80d0831d0b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 7 14:50:50 2020 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 07 Jun 2020 15:00:04 +0200 |
parents | f502455965c0 |
children | d9a2e5dcfd9f |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -212,6 +212,18 @@ eval1_emsg(char_u **arg, typval_T *rettv } /* + * 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]". * Return the result in "rettv" and OK or FAIL.