Skip to content

Commit 3ea0f1a

Browse files
committed
patch 7.4.1408
Problem: MS-Windows doesn't have isnan() and isinf(). Solution: Use _isnan() and _isinf().
1 parent f1b6ac7 commit 3ea0f1a

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

src/eval.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
# include <time.h> /* for time_t */
2828
#endif
2929

30-
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
31-
# include <math.h>
30+
#if defined(FEAT_FLOAT)
31+
# include <float.h>
32+
# if defined(HAVE_MATH_H)
33+
# include <math.h>
34+
# endif
35+
# if defined(WIN32) && !defined(isnan)
36+
# define isnan(x) _isnan(x)
37+
# endif
3238
#endif
3339

3440
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */

src/json.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,20 @@
1717

1818
#if defined(FEAT_EVAL) || defined(PROTO)
1919

20-
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
21-
/* for isnan() and isinf() */
22-
# include <math.h>
20+
#if defined(FEAT_FLOAT)
21+
# include <float.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
2334
#endif
2435

2536
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, typval_T *res, int options)
745756
if (res != NULL)
746757
{
747758
res->v_type = VAR_FLOAT;
748-
res->vval.v_float = 0.0 / 0.0;
759+
res->vval.v_float = NAN;
749760
}
750761
return OK;
751762
}
@@ -755,7 +766,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
755766
if (res != NULL)
756767
{
757768
res->v_type = VAR_FLOAT;
758-
res->vval.v_float = 1.0 / 0.0;
769+
res->vval.v_float = INFINITY;
759770
}
760771
return OK;
761772
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ static char *(features[]) =
748748

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1408,
751753
/**/
752754
1407,
753755
/**/

0 commit comments

Comments
 (0)