summaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-08 19:25:40 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-08 19:25:40 +0100
commit6247361101dcccc0c877e90ad67cd0cc83df7c68 (patch)
tree185ea45d4f9e0cf0ba760c7fc398e9e2fa854337 /src/eval.c
parent2d02839050a2557bf36dab37ccd9f92168a757d1 (diff)
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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index 9d2c5ac72b..70fbc8863b 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);