diff options
Diffstat (limited to 'src/nvim/eval/decode.c')
-rw-r--r-- | src/nvim/eval/decode.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 797420c150..7b975ce775 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -290,8 +290,7 @@ typval_T decode_string(const char *const s, const size_t len, const TriState has return (typval_T) { .v_type = VAR_STRING, .v_lock = VAR_UNLOCKED, - .vval = { .v_string = (char_u *)( - (s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) }, + .vval = { .v_string = ((s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) }, }; } } @@ -376,7 +375,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, "inside string: %.*s"), LENP(p, e)); goto parse_json_string_fail; } - const int ch = utf_ptr2char((char_u *)p); + const int ch = utf_ptr2char(p); // All characters above U+007F are encoded using two or more bytes // and thus cannot possibly be equal to *p. But utf_ptr2char({0xFF, // 0}) will return 0xFF, even though 0xFF cannot start any UTF-8 @@ -393,7 +392,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, goto parse_json_string_fail; } const size_t ch_len = (size_t)utf_char2len(ch); - assert(ch_len == (size_t)(ch ? utf_ptr2len((char_u *)p) : 1)); + assert(ch_len == (size_t)(ch ? utf_ptr2len(p) : 1)); len += ch_len; p += ch_len; } @@ -415,9 +414,9 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, bool hasnul = false; #define PUT_FST_IN_PAIR(fst_in_pair, str_end) \ do { \ - if (fst_in_pair != 0) { \ - str_end += utf_char2bytes(fst_in_pair, (char_u *)str_end); \ - fst_in_pair = 0; \ + if ((fst_in_pair) != 0) { \ + (str_end) += utf_char2bytes(fst_in_pair, (str_end)); \ + (fst_in_pair) = 0; \ } \ } while (0) for (const char *t = s; t < p; t++) { @@ -441,15 +440,14 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len, fst_in_pair = (int)ch; } else if (SURROGATE_LO_START <= ch && ch <= SURROGATE_LO_END && fst_in_pair != 0) { - const int full_char = ( - (int)(ch - SURROGATE_LO_START) + const int full_char = ((int)(ch - SURROGATE_LO_START) + ((fst_in_pair - SURROGATE_HI_START) << 10) + SURROGATE_FIRST_CHAR); - str_end += utf_char2bytes(full_char, (char_u *)str_end); + str_end += utf_char2bytes(full_char, str_end); fst_in_pair = 0; } else { PUT_FST_IN_PAIR(fst_in_pair, str_end); - str_end += utf_char2bytes((int)ch, (char_u *)str_end); + str_end += utf_char2bytes((int)ch, str_end); } break; } |