forked from aniani/vim
patch 7.4.1407
Problem: json_encode() does not handle NaN and inf properly. (David Barnett) Solution: For JSON turn them into "null". For JS use "NaN" and "Infinity". Add isnan().
This commit is contained in:
18
src/eval.c
18
src/eval.c
@@ -628,6 +628,9 @@ static void f_insert(typval_T *argvars, typval_T *rettv);
|
||||
static void f_invert(typval_T *argvars, typval_T *rettv);
|
||||
static void f_isdirectory(typval_T *argvars, typval_T *rettv);
|
||||
static void f_islocked(typval_T *argvars, typval_T *rettv);
|
||||
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
|
||||
static void f_isnan(typval_T *argvars, typval_T *rettv);
|
||||
#endif
|
||||
static void f_items(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_JOB
|
||||
# ifdef FEAT_CHANNEL
|
||||
@@ -8320,6 +8323,9 @@ static struct fst
|
||||
{"invert", 1, 1, f_invert},
|
||||
{"isdirectory", 1, 1, f_isdirectory},
|
||||
{"islocked", 1, 1, f_islocked},
|
||||
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
|
||||
{"isnan", 1, 1, f_isnan},
|
||||
#endif
|
||||
{"items", 1, 1, f_items},
|
||||
#ifdef FEAT_JOB
|
||||
# ifdef FEAT_CHANNEL
|
||||
@@ -14740,6 +14746,18 @@ f_islocked(typval_T *argvars, typval_T *rettv)
|
||||
clear_lval(&lv);
|
||||
}
|
||||
|
||||
#if defined(FEAT_FLOAT) && defined(HAVE_MATH_H)
|
||||
/*
|
||||
* "isnan()" function
|
||||
*/
|
||||
static void
|
||||
f_isnan(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
|
||||
&& isnan(argvars[0].vval.v_float);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void dict_list(typval_T *argvars, typval_T *rettv, int what);
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user