comparison 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
comparison
equal deleted inserted replaced
8229:8ac9d0ab3ef8 8230:51ca0cee512e
15 15
16 #include "vim.h" 16 #include "vim.h"
17 17
18 #if defined(FEAT_EVAL) || defined(PROTO) 18 #if defined(FEAT_EVAL) || defined(PROTO)
19 19
20 #if defined(FEAT_FLOAT) && defined(HAVE_MATH_H) 20 #if defined(FEAT_FLOAT)
21 /* for isnan() and isinf() */ 21 # include <float.h>
22 # include <math.h> 22 # if defined(HAVE_MATH_H)
23 /* for isnan() and isinf() */
24 # include <math.h>
25 # endif
26 # if defined(WIN32) && !defined(isnan)
27 # define isnan(x) _isnan(x)
28 # define isinf(x) (!_finite(x) && !_isnan(x))
29 # endif
30 # if defined(_MSC_VER) && !defined(INFINITY)
31 # define INFINITY (DBL_MAX+DBL_MAX)
32 # define NAN (INFINITY-INFINITY)
33 # endif
23 #endif 34 #endif
24 35
25 static int json_encode_item(garray_T *gap, typval_T *val, int copyID, int options); 36 static int json_encode_item(garray_T *gap, typval_T *val, int copyID, int options);
26 static int json_decode_item(js_read_T *reader, typval_T *res, int options); 37 static int json_decode_item(js_read_T *reader, typval_T *res, int options);
27 38
743 { 754 {
744 reader->js_used += 3; 755 reader->js_used += 3;
745 if (res != NULL) 756 if (res != NULL)
746 { 757 {
747 res->v_type = VAR_FLOAT; 758 res->v_type = VAR_FLOAT;
748 res->vval.v_float = 0.0 / 0.0; 759 res->vval.v_float = NAN;
749 } 760 }
750 return OK; 761 return OK;
751 } 762 }
752 if (STRNICMP((char *)p, "Infinity", 8) == 0) 763 if (STRNICMP((char *)p, "Infinity", 8) == 0)
753 { 764 {
754 reader->js_used += 8; 765 reader->js_used += 8;
755 if (res != NULL) 766 if (res != NULL)
756 { 767 {
757 res->v_type = VAR_FLOAT; 768 res->v_type = VAR_FLOAT;
758 res->vval.v_float = 1.0 / 0.0; 769 res->vval.v_float = INFINITY;
759 } 770 }
760 return OK; 771 return OK;
761 } 772 }
762 #endif 773 #endif
763 /* check for truncated name */ 774 /* check for truncated name */