diff src/eval.c @ 10536:6ddf322ff7cf v8.0.0158

patch 8.0.0158: float funcion test fails on MS-Windows commit https://github.com/vim/vim/commit/6247361101dcccc0c877e90ad67cd0cc83df7c68 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 8 19:25:40 2017 +0100 patch 8.0.0158: float funcion test fails on MS-Windows 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.
author Christian Brabandt <cb@256bit.org>
date Sun, 08 Jan 2017 19:30:03 +0100
parents d3f0946b4a80
children ea7fbae33285
line wrap: on
line diff
--- 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);