Skip to content

Commit 6247361

Browse files
committed
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.
1 parent 2d02839 commit 6247361

File tree

3 files changed

+175
-153
lines changed

3 files changed

+175
-153
lines changed

src/eval.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5971,6 +5971,22 @@ string2float(
59715971
char *s = (char *)text;
59725972
float_T f;
59735973

5974+
/* MS-Windows does not deal with "inf" and "nan" properly. */
5975+
if (STRNICMP(text, "inf", 3) == 0)
5976+
{
5977+
*value = INFINITY;
5978+
return 3;
5979+
}
5980+
if (STRNICMP(text, "-inf", 3) == 0)
5981+
{
5982+
*value = -INFINITY;
5983+
return 4;
5984+
}
5985+
if (STRNICMP(text, "nan", 3) == 0)
5986+
{
5987+
*value = NAN;
5988+
return 3;
5989+
}
59745990
f = strtod(s, &s);
59755991
*value = f;
59765992
return (int)((char_u *)s - text);

0 commit comments

Comments
 (0)