eval: Use str2float() to represent inf and nan values

Closes #3248
This commit is contained in:
ZyX
2015-12-26 01:14:26 +03:00
parent 830678d5f9
commit 2873a17c55

View File

@@ -6839,9 +6839,25 @@ vim_to_msgpack_error_ret: \
#define CONV_FLOAT(flt) \ #define CONV_FLOAT(flt) \
do { \ do { \
char numbuf[NUMBUFLEN]; \ const float_T flt_ = (flt); \
vim_snprintf(numbuf, NUMBUFLEN - 1, "%g", (flt)); \ switch (fpclassify(flt_)) { \
ga_concat(gap, (char_u *) numbuf); \ case FP_NAN: { \
ga_concat(gap, (char_u *) "str2float('nan')"); \
break; \
} \
case FP_INFINITE: { \
if (flt_ < 0) { \
ga_append(gap, '-'); \
} \
ga_concat(gap, (char_u *) "str2float('inf')"); \
break; \
} \
default: { \
char numbuf[NUMBUFLEN]; \
vim_snprintf(numbuf, NUMBUFLEN - 1, "%g", flt_); \
ga_concat(gap, (char_u *) numbuf); \
} \
} \
} while (0) } while (0)
#define CONV_FUNC(fun) \ #define CONV_FUNC(fun) \