Mercurial > vim
diff src/json.c @ 8230:51ca0cee512e v7.4.1408
commit https://github.com/vim/vim/commit/3ea0f1ae318db6cd9413914bb2ff824d71cefc6e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 23 22:07:32 2016 +0100
patch 7.4.1408
Problem: MS-Windows doesn't have isnan() and isinf().
Solution: Use _isnan() and _isinf().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 23 Feb 2016 22:15:05 +0100 |
parents | a0e552c51c34 |
children | ff900e499f79 |
line wrap: on
line diff
--- a/src/json.c +++ b/src/json.c @@ -17,9 +17,20 @@ #if defined(FEAT_EVAL) || defined(PROTO) -#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) - /* for isnan() and isinf() */ -# include <math.h> +#if defined(FEAT_FLOAT) +# include <float.h> +# if defined(HAVE_MATH_H) + /* for isnan() and isinf() */ +# include <math.h> +# endif +# if defined(WIN32) && !defined(isnan) +# define isnan(x) _isnan(x) +# define isinf(x) (!_finite(x) && !_isnan(x)) +# endif +# if defined(_MSC_VER) && !defined(INFINITY) +# define INFINITY (DBL_MAX+DBL_MAX) +# define NAN (INFINITY-INFINITY) +# endif #endif static int json_encode_item(garray_T *gap, typval_T *val, int copyID, int options); @@ -745,7 +756,7 @@ json_decode_item(js_read_T *reader, typv if (res != NULL) { res->v_type = VAR_FLOAT; - res->vval.v_float = 0.0 / 0.0; + res->vval.v_float = NAN; } return OK; } @@ -755,7 +766,7 @@ json_decode_item(js_read_T *reader, typv if (res != NULL) { res->v_type = VAR_FLOAT; - res->vval.v_float = 1.0 / 0.0; + res->vval.v_float = INFINITY; } return OK; }