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.
diff --git a/src/eval.c b/src/eval.c
index 6f89030..b184264 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -212,6 +212,18 @@
}
/*
+ * 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.