summaryrefslogtreecommitdiff
path: root/src/message.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-27 15:26:35 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-27 15:26:35 +0200
commit9992237a3e791fbc0c1ebf743ece1b75e1488410 (patch)
tree1016f2132eb5318b0136ce8ad71921177322a5fb /src/message.c
parent76efafba2af36ae5f6c7b79b56c537fcbcdb386c (diff)
downloadvim-git-9992237a3e791fbc0c1ebf743ece1b75e1488410.tar.gz
patch 7.4.2266v7.4.2266
Problem: printf() test fails on Windows. "-inf" is not used. Solution: Check for Windows-specific values for "nan". Add sign to "inf" when appropriate.
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/message.c b/src/message.c
index 0d1043137..2824b5bbb 100644
--- a/src/message.c
+++ b/src/message.c
@@ -4701,6 +4701,7 @@ vim_vsnprintf(
char format[40];
int l;
int remove_trailing_zeroes = FALSE;
+ char *s;
f =
# if defined(FEAT_EVAL)
@@ -4730,8 +4731,16 @@ vim_vsnprintf(
)
{
/* Avoid a buffer overflow */
- strcpy(tmp, "inf");
- str_arg_l = 3;
+ if (f < 0)
+ {
+ strcpy(tmp, "-inf");
+ str_arg_l = 4;
+ }
+ else
+ {
+ strcpy(tmp, "inf");
+ str_arg_l = 3;
+ }
}
else
{
@@ -4753,6 +4762,22 @@ vim_vsnprintf(
format[l + 1] = NUL;
str_arg_l = sprintf(tmp, format, f);
+ /* Be consistent: Change "1.#IND" to "nan" and
+ * "1.#INF" to "inf". */
+ s = *tmp == '-' ? tmp + 1 : tmp;
+ if (STRNCMP(s, "1.#INF", 6) == 0)
+ STRCPY(s, "inf");
+ else if (STRNCMP(s, "1.#IND", 6) == 0)
+ STRCPY(s, "nan");
+
+ /* Remove sign before "nan". */
+ if (STRNCMP(tmp, "-nan", 4) == 0)
+ STRCPY(tmp, "nan");
+
+ /* Add sign before "inf" if needed. */
+ if (isinf(f) == -1 && STRNCMP(tmp, "inf", 3) == 0)
+ STRCPY(tmp, "-inf");
+
if (remove_trailing_zeroes)
{
int i;