Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
10535:7eeebb3487d4 | 10536:6ddf322ff7cf |
---|---|
5969 float_T *value) /* result stored here */ | 5969 float_T *value) /* result stored here */ |
5970 { | 5970 { |
5971 char *s = (char *)text; | 5971 char *s = (char *)text; |
5972 float_T f; | 5972 float_T f; |
5973 | 5973 |
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 } | |
5974 f = strtod(s, &s); | 5990 f = strtod(s, &s); |
5975 *value = f; | 5991 *value = f; |
5976 return (int)((char_u *)s - text); | 5992 return (int)((char_u *)s - text); |
5977 } | 5993 } |
5978 #endif | 5994 #endif |