diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2021-11-16 20:27:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-16 20:27:59 +0100 |
commit | eba317d7a907a76e6e265c0fe0b97a87f17cf943 (patch) | |
tree | 21edca825d0de28a4024c969e26ecfe75f6dc298 /src/nvim/eval/encode.c | |
parent | 99211b008c10561560e84eabfaa22e1577ac179a (diff) | |
download | rneovim-eba317d7a907a76e6e265c0fe0b97a87f17cf943.tar.gz rneovim-eba317d7a907a76e6e265c0fe0b97a87f17cf943.tar.bz2 rneovim-eba317d7a907a76e6e265c0fe0b97a87f17cf943.zip |
refactor: reduce number of explicit char casts (#16077)
* refactor: reduce number of explicit char casts
Diffstat (limited to 'src/nvim/eval/encode.c')
-rw-r--r-- | src/nvim/eval/encode.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index b457353838..d694b8a374 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -29,8 +29,6 @@ #include "nvim/message.h" #include "nvim/vim.h" // For _() -#define utf_ptr2char(b) utf_ptr2char((char_u *)b) -#define utf_ptr2len(b) ((size_t)utf_ptr2len((char_u *)b)) #define utf_char2len(b) ((size_t)utf_char2len(b)) const char *const encode_bool_var_names[] = { @@ -614,8 +612,8 @@ static inline int convert_to_json_string(garray_T *const gap, const char *const #define ENCODE_RAW(ch) \ (ch >= 0x20 && utf_printable(ch)) for (size_t i = 0; i < utf_len;) { - const int ch = utf_ptr2char(utf_buf + i); - const size_t shift = (ch == 0? 1: utf_ptr2len(utf_buf + i)); + const int ch = utf_ptr2char((char_u *)utf_buf + i); + const size_t shift = (ch == 0 ? 1 : ((size_t)utf_ptr2len((char_u *)utf_buf + i))); assert(shift > 0); i += shift; switch (ch) { @@ -654,11 +652,11 @@ static inline int convert_to_json_string(garray_T *const gap, const char *const ga_append(gap, '"'); ga_grow(gap, (int)str_len); for (size_t i = 0; i < utf_len;) { - const int ch = utf_ptr2char(utf_buf + i); + const int ch = utf_ptr2char((char_u *)utf_buf + i); const size_t shift = (ch == 0? 1: utf_char2len(ch)); assert(shift > 0); // Is false on invalid unicode, but this should already be handled. - assert(ch == 0 || shift == utf_ptr2len(utf_buf + i)); + assert(ch == 0 || shift == ((size_t)utf_ptr2len((char_u *)utf_buf + i))); switch (ch) { case BS: case TAB: |