Patch 7.4.2266 (after 7.4.2265)
Problem: printf() test fails on Windows. "-inf" is not used.
Solution: Check for Windows-specific values for "nan". Add sign to "inf"
when appropriate.
Files: src/message.c, src/testdir/test_expr.vim
*** ../vim-7.4.2265/src/message.c 2016-08-26 22:29:06.083185153 +0200
--- src/message.c 2016-08-27 15:25:51.482801462 +0200
***************
*** 4701,4706 ****
--- 4701,4707 ----
char format[40];
int l;
int remove_trailing_zeroes = FALSE;
+ char *s;
f =
# if defined(FEAT_EVAL)
***************
*** 4730,4737 ****
)
{
/* Avoid a buffer overflow */
! strcpy(tmp, "inf");
! str_arg_l = 3;
}
else
{
--- 4731,4746 ----
)
{
/* Avoid a buffer overflow */
! if (f < 0)
! {
! strcpy(tmp, "-inf");
! str_arg_l = 4;
! }
! else
! {
! strcpy(tmp, "inf");
! str_arg_l = 3;
! }
}
else
{
***************
*** 4753,4758 ****
--- 4762,4783 ----
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;
*** ../vim-7.4.2265/src/testdir/test_expr.vim 2016-08-27 14:21:18.888288793
+0200
--- src/testdir/test_expr.vim 2016-08-27 15:10:29.546696504 +0200
***************
*** 204,215 ****
call assert_equal('inf', printf('%f', 1.0/0.0))
! " This prints inf but shouldn't it print -inf instead?
! call assert_match('^-\?inf$', printf('%f', -1.0/0.0))
! " This prints -nan but shouldn't it print nan instead?
! call assert_match('^-\?nan$', printf('%f', sqrt(-1.0)))
! call assert_match('^-\?nan$', printf('%f', 0.0/0.0))
call assert_fails('echo printf("%f", "a")', 'E807:')
endif
--- 204,213 ----
call assert_equal('inf', printf('%f', 1.0/0.0))
! call assert_match('^-inf$', printf('%f', -1.0/0.0))
! call assert_match('^nan$', printf('%f', sqrt(-1.0)))
! call assert_match('^nan$', printf('%f', 0.0/0.0))
call assert_fails('echo printf("%f", "a")', 'E807:')
endif
*** ../vim-7.4.2265/src/version.c 2016-08-27 14:21:18.892288758 +0200
--- src/version.c 2016-08-27 15:24:54.891280125 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2266,
/**/
--
Warning label on a superhero Halloween costume:
"Caution: Cape does not enable user to fly."
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.