mirror of
https://github.com/neovim/neovim.git
synced 2025-12-04 13:42:41 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user