aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/encode.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/eval/encode.c')
-rw-r--r--src/nvim/eval/encode.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index b457353838..6f4357421b 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[] = {
@@ -354,20 +352,20 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
const float_T flt_ = (flt); \
switch (xfpclassify(flt_)) { \
case FP_NAN: { \
- ga_concat(gap, "str2float('nan')"); \
- break; \
+ ga_concat(gap, "str2float('nan')"); \
+ break; \
} \
case FP_INFINITE: { \
- if (flt_ < 0) { \
- ga_append(gap, '-'); \
- } \
- ga_concat(gap, "str2float('inf')"); \
- break; \
+ if (flt_ < 0) { \
+ ga_append(gap, '-'); \
+ } \
+ ga_concat(gap, "str2float('inf')"); \
+ break; \
} \
default: { \
- char numbuf[NUMBUFLEN]; \
- vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
- ga_concat(gap, numbuf); \
+ char numbuf[NUMBUFLEN]; \
+ vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
+ ga_concat(gap, numbuf); \
} \
} \
} while (0)
@@ -558,18 +556,18 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
const float_T flt_ = (flt); \
switch (xfpclassify(flt_)) { \
case FP_NAN: { \
- emsg(_("E474: Unable to represent NaN value in JSON")); \
- return FAIL; \
+ emsg(_("E474: Unable to represent NaN value in JSON")); \
+ return FAIL; \
} \
case FP_INFINITE: { \
- emsg(_("E474: Unable to represent infinity in JSON")); \
- return FAIL; \
+ emsg(_("E474: Unable to represent infinity in JSON")); \
+ return FAIL; \
} \
default: { \
- char numbuf[NUMBUFLEN]; \
- vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
- ga_concat(gap, numbuf); \
- break; \
+ char numbuf[NUMBUFLEN]; \
+ vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
+ ga_concat(gap, numbuf); \
+ break; \
} \
} \
} while (0)
@@ -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: