To: vim_dev@googlegroups.com Subject: Patch 7.4.2266 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- 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 ///