aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2017-06-05 21:58:33 -0400
committerJames McCoy <jamessan@jamessan.com>2017-06-06 05:07:14 -0400
commitb1d4ef2b420b1fa9826a9e79344adaf71ad27e18 (patch)
tree12ff1a30676d3712fbe16837548ac716d395cea7 /src/nvim/eval.c
parent09eefbe92ce83e81b6e9c80681152a41ed011d56 (diff)
downloadrneovim-b1d4ef2b420b1fa9826a9e79344adaf71ad27e18.tar.gz
rneovim-b1d4ef2b420b1fa9826a9e79344adaf71ad27e18.tar.bz2
rneovim-b1d4ef2b420b1fa9826a9e79344adaf71ad27e18.zip
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. https://github.com/vim/vim/commit/6247361101dcccc0c877e90ad67cd0cc83df7c68
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c9da08acd0..612c3be368 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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);
}