diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-08 19:25:40 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-08 19:25:40 +0100 |
commit | 6247361101dcccc0c877e90ad67cd0cc83df7c68 (patch) | |
tree | 185ea45d4f9e0cf0ba760c7fc398e9e2fa854337 /src/eval.c | |
parent | 2d02839050a2557bf36dab37ccd9f92168a757d1 (diff) | |
download | vim-git-6247361101dcccc0c877e90ad67cd0cc83df7c68.tar.gz |
patch 8.0.0158: float funcion test fails on MS-Windowsv8.0.0158
Problem: On MS-Windows some float functions return a different value when
passed unusual values. strtod() doesn't work for "inf" and "nan".
Solution: Accept both results. Fix str2float() for MS-Windows. Also
reorder assert function arguments.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 9d2c5ac72..70fbc8863 100644 --- a/src/eval.c +++ b/src/eval.c @@ -5971,6 +5971,22 @@ string2float( char *s = (char *)text; float_T f; + /* MS-Windows does not deal with "inf" and "nan" properly. */ + if (STRNICMP(text, "inf", 3) == 0) + { + *value = INFINITY; + return 3; + } + if (STRNICMP(text, "-inf", 3) == 0) + { + *value = -INFINITY; + return 4; + } + if (STRNICMP(text, "nan", 3) == 0) + { + *value = NAN; + return 3; + } f = strtod(s, &s); *value = f; return (int)((char_u *)s - text); |