diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-05-08 23:17:28 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-08 23:17:28 +0800 |
| commit | 71424a8a0e42ce56bbe3a4319764a8c32f1f511f (patch) | |
| tree | 51c6d88e710a4fe5b66e4ac76e68657c08872b07 /src/nvim/eval | |
| parent | 9753cda591e2fceaaeea26bdf2d5b5d874d7e9f5 (diff) | |
| parent | 625926f729137658d0a8a73a55aeefc5583488c3 (diff) | |
| download | rneovim-71424a8a0e42ce56bbe3a4319764a8c32f1f511f.tar.gz rneovim-71424a8a0e42ce56bbe3a4319764a8c32f1f511f.tar.bz2 rneovim-71424a8a0e42ce56bbe3a4319764a8c32f1f511f.zip | |
Merge pull request #23540 from zeertzjq/vim-9.0.1522
vim-patch:9.0.{1522,1524}: some functions give two error messages
Diffstat (limited to 'src/nvim/eval')
| -rw-r--r-- | src/nvim/eval/typval.c | 22 | ||||
| -rw-r--r-- | src/nvim/eval/typval.h | 4 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 5755178b18..cb8f8ce44d 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -2166,6 +2166,16 @@ varnumber_T tv_dict_get_number_def(const dict_T *const d, const char *const key, return tv_get_number(&di->di_tv); } +varnumber_T tv_dict_get_bool(const dict_T *const d, const char *const key, const int def) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +{ + dictitem_T *const di = tv_dict_find(d, key, -1); + if (di == NULL) { + return def; + } + return tv_get_bool(&di->di_tv); +} + /// Converts a dict to an environment char **tv_dict_to_env(dict_T *denv) { @@ -4049,6 +4059,18 @@ varnumber_T tv_get_number_chk(const typval_T *const tv, bool *const ret_error) return (ret_error == NULL ? -1 : 0); } +varnumber_T tv_get_bool(const typval_T *const tv) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT +{ + return tv_get_number_chk(tv, NULL); +} + +varnumber_T tv_get_bool_chk(const typval_T *const tv, bool *const ret_error) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1) +{ + return tv_get_number_chk(tv, ret_error); +} + /// Get the line number from VimL object /// /// @param[in] tv Object to get value from. Is expected to be a number or diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 84e4067f9d..767fd706b3 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -567,8 +567,4 @@ EXTERN const size_t kTVTranslate INIT(= TV_TRANSLATE); # include "eval/typval.h.generated.h" #endif -#define tv_get_bool tv_get_number -#define tv_get_bool_chk tv_get_number_chk -#define tv_dict_get_bool tv_dict_get_number_def - #endif // NVIM_EVAL_TYPVAL_H |