summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-02-27 16:33:22 +0100
committerBram Moolenaar <Bram@vim.org>2016-02-27 16:33:22 +0100
commit7ce686c990ea8c490d16be7f1c6bd95eb48816f9 (patch)
tree6b507613c77479f9e5a94600bc2a332d657ee363 /src/json.c
parentd804fdf4c25435284333258856bc265f1ff10b09 (diff)
downloadvim-git-7ce686c990ea8c490d16be7f1c6bd95eb48816f9.tar.gz
patch 7.4.1430v7.4.1430
Problem: When encoding JSON, turning NaN and Infinity into null without giving an error is not useful. Solution: Pass NaN and Infinity on. If the receiver can't handle them it will generate the error.
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/json.c b/src/json.c
index 1a3dea1e5..a42faec0d 100644
--- a/src/json.c
+++ b/src/json.c
@@ -27,8 +27,10 @@
# define isnan(x) _isnan(x)
# define isinf(x) (!_finite(x) && !_isnan(x))
# endif
-# if defined(_MSC_VER) && !defined(INFINITY)
+# if !defined(INFINITY) && defined(DBL_MAX)
# define INFINITY (DBL_MAX+DBL_MAX)
+# endif
+# if !defined(NAN) && defined(INFINITY)
# define NAN (INFINITY-INFINITY)
# endif
#endif
@@ -285,12 +287,10 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
case VAR_FLOAT:
#ifdef FEAT_FLOAT
# if defined(HAVE_MATH_H)
- if ((options & JSON_JS) && isnan(val->vval.v_float))
+ if (isnan(val->vval.v_float))
ga_concat(gap, (char_u *)"NaN");
- else if ((options & JSON_JS) && isinf(val->vval.v_float))
+ else if (isinf(val->vval.v_float))
ga_concat(gap, (char_u *)"Infinity");
- else if (isnan(val->vval.v_float) || isinf(val->vval.v_float))
- ga_concat(gap, (char_u *)"null");
else
# endif
{