diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
commit | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch) | |
tree | cd08258054db80bb9a11b1061bb091c70b76926a /src/nvim/eval/decode.c | |
parent | eaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-aucmd_textputpost.tar.gz rneovim-aucmd_textputpost.tar.bz2 rneovim-aucmd_textputpost.zip |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'src/nvim/eval/decode.c')
-rw-r--r-- | src/nvim/eval/decode.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index cd1479f150..03f79fca84 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include <assert.h> #include <msgpack/object.h> #include <stdbool.h> @@ -10,22 +7,22 @@ #include <string.h> #include "klib/kvec.h" -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/charset.h" #include "nvim/eval.h" #include "nvim/eval/decode.h" #include "nvim/eval/encode.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" +#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" -#include "nvim/hashtab.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/memory.h" #include "nvim/message.h" -#include "nvim/types.h" -#include "nvim/vim.h" +#include "nvim/types_defs.h" +#include "nvim/vim_defs.h" /// Helper structure for container_struct typedef struct { @@ -148,7 +145,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, ValuesStack *const stack assert(!(key.is_special_string || key.val.vval.v_string == NULL || *key.val.vval.v_string == NUL)); - dictitem_T *const obj_di = tv_dict_item_alloc((const char *)key.val.vval.v_string); + dictitem_T *const obj_di = tv_dict_item_alloc(key.val.vval.v_string); tv_clear(&key.val); if (tv_dict_add(last_container.container.vval.v_dict, obj_di) == FAIL) { @@ -179,8 +176,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, ValuesStack *const stack && (obj.is_special_string || obj.val.vval.v_string == NULL || *obj.val.vval.v_string == NUL - || tv_dict_find(last_container.container.vval.v_dict, - (const char *)obj.val.vval.v_string, -1))) { + || tv_dict_find(last_container.container.vval.v_dict, obj.val.vval.v_string, -1))) { tv_clear(&obj.val); // Restart @@ -228,7 +224,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, ValuesStack *const stack /// /// @param[out] ret_tv Address where new special dictionary is saved. /// @param[in] len Expected number of items to be populated before list -/// becomes accessible from VimL. It is still valid to +/// becomes accessible from Vimscript. It is still valid to /// underpopulate a list, value only controls how many elements /// will be allocated in advance. @see ListLenSpecials. /// @@ -439,7 +435,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, t += 4; uvarnumber_T ch; vim_str2nr(ubuf, NULL, NULL, - STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4, true); + STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4, true, NULL); if (ch == 0) { hasnul = true; } @@ -608,7 +604,7 @@ parse_json_number_check: // Convert integer varnumber_T nr; int num_len; - vim_str2nr(s, NULL, &num_len, 0, &nr, NULL, (int)(p - s), true); + vim_str2nr(s, NULL, &num_len, 0, &nr, NULL, (int)(p - s), true, NULL); if ((int)exp_num_len != num_len) { semsg(_("E685: internal error: while converting number \"%.*s\" " "to integer vim_str2nr consumed %i bytes in place of %zu"), @@ -646,7 +642,7 @@ parse_json_number_ret: } \ } while (0) -/// Convert JSON string into VimL object +/// Convert JSON string into Vimscript object /// /// @param[in] buf String to convert. UTF-8 encoding is assumed. /// @param[in] buf_len Length of the string. @@ -922,7 +918,7 @@ json_decode_string_ret: #undef DICT_LEN -/// Convert msgpack object to a VimL one +/// Convert msgpack object to a Vimscript one int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { @@ -966,7 +962,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) } break; case MSGPACK_OBJECT_NEGATIVE_INTEGER: - if (mobj.via.i64 >= VARNUMBER_MIN) { // -V547 + if (mobj.via.i64 >= VARNUMBER_MIN) { *rettv = (typval_T) { .v_type = VAR_NUMBER, .v_lock = VAR_UNLOCKED, @@ -987,12 +983,8 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) tv_list_append_number(list, (varnumber_T)(n & 0x7FFFFFFF)); } break; -#ifdef NVIM_MSGPACK_HAS_FLOAT32 case MSGPACK_OBJECT_FLOAT32: case MSGPACK_OBJECT_FLOAT64: -#else - case MSGPACK_OBJECT_FLOAT: -#endif *rettv = (typval_T) { .v_type = VAR_FLOAT, .v_lock = VAR_UNLOCKED, |