vim-patch:8.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.

6247361101
This commit is contained in:
James McCoy
2017-06-05 21:58:33 -04:00
parent 09eefbe92c
commit b1d4ef2b42
2 changed files with 170 additions and 153 deletions

View File

@@ -5898,6 +5898,19 @@ size_t string2float(const char *const text, float_T *const ret_value)
{
char *s = NULL;
// MS-Windows does not deal with "inf" and "nan" properly
if (STRNICMP(text, "inf", 3) == 0) {
*ret_value = INFINITY;
return 3;
}
if (STRNICMP(text, "-inf", 3) == 0) {
*ret_value = -INFINITY;
return 4;
}
if (STRNICMP(text, "nan", 3) == 0) {
*ret_value = NAN;
return 3;
}
*ret_value = strtod(text, &s);
return (size_t) (s - text);
}