diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-08 20:19:08 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-12-11 21:20:20 -0500 |
commit | 5ccc79e880d5913f092e041f1a67530c1d2d6728 (patch) | |
tree | 1220939397a812156a92bbdddd8d2b03ebd98fd5 /src/nvim/eval/typval.c | |
parent | 062576f679a1bd5cb546bb8081dc97caefe7b51f (diff) | |
download | rneovim-5ccc79e880d5913f092e041f1a67530c1d2d6728.tar.gz rneovim-5ccc79e880d5913f092e041f1a67530c1d2d6728.tar.bz2 rneovim-5ccc79e880d5913f092e041f1a67530c1d2d6728.zip |
eval: executable(), exepath() accept strings only
Cherry-pick f_executable(), f_exepath(), check_for_string() from patch 8.2.2117.
Rename check_for_string() to tv_check_for_string().
https://github.com/vim/vim/commit/7bb4e74c38642682cfdd0cb4052adfa5efdd7dd1
Close https://github.com/neovim/neovim/issues/13485
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index b62820fecc..02d32a4f86 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -2953,6 +2953,19 @@ float_T tv_get_float(const typval_T *const tv) return 0; } +// Give an error and return FAIL unless "tv" is a non-empty string. +int tv_check_for_string(const typval_T *const tv) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE +{ + if (tv->v_type != VAR_STRING + || tv->vval.v_string == NULL + || *tv->vval.v_string == NUL) { + EMSG(_(e_stringreq)); + return FAIL; + } + return OK; +} + /// Get the string value of a "stringish" VimL object. /// /// @param[in] tv Object to get value of. |