mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 10:26:31 +00:00
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().
f1b6ac7229
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "nvim/indent_c.h"
|
||||
#include "nvim/indent.h"
|
||||
#include "nvim/mark.h"
|
||||
#include "nvim/math.h"
|
||||
#include "nvim/mbyte.h"
|
||||
#include "nvim/memline.h"
|
||||
#include "nvim/memory.h"
|
||||
@@ -12028,6 +12029,12 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
clear_lval(&lv);
|
||||
}
|
||||
|
||||
// "isnan()" function
|
||||
static void f_isnan(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
rettv->vval.v_number = argvars[0].v_type == VAR_FLOAT
|
||||
&& xisnan(argvars[0].vval.v_float);
|
||||
}
|
||||
|
||||
/// Turn a dictionary into a list
|
||||
///
|
||||
|
@@ -190,6 +190,7 @@ return {
|
||||
invert={args=1},
|
||||
isdirectory={args=1},
|
||||
islocked={args=1},
|
||||
isnan={args=1},
|
||||
id={args=1},
|
||||
items={args=1},
|
||||
jobclose={args={1, 2}, func="f_chanclose"},
|
||||
|
@@ -289,7 +289,6 @@ func Test_trunc()
|
||||
endfunc
|
||||
|
||||
func Test_isnan()
|
||||
throw 'skipped: Nvim does not support isnan()'
|
||||
call assert_equal(0, isnan(1.0))
|
||||
call assert_equal(1, isnan(0.0/0.0))
|
||||
call assert_equal(0, isnan(1.0/0.0))
|
||||
|
Reference in New Issue
Block a user