From c3efb2804a6bcf3b61695cd2b0c60bb16f1ec0a9 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 16 Nov 2016 14:30:20 -0500 Subject: [PATCH] vim-patch:7.4.2029 Problem: printf() does not work with 64 bit numbers. Solution: use the "L" length modifier. (Ken Takata) https://github.com/vim/vim/commit/38ee6b041e73ad31c3b6b99d56d20833b59b2b57 --- src/nvim/strings.c | 7 +++++++ src/nvim/testdir/test_expr.vim | 6 ++++++ src/nvim/version.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/nvim/strings.c b/src/nvim/strings.c index c5fd8741b8..9b9aa6d2f4 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -910,6 +910,13 @@ int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap, default: break; } + switch (fmt_spec) { + case 'd': case 'u': case 'o': case 'x': case 'X': + if (tvs && length_modifier == '\0') { + length_modifier = '2'; + } + } + // get parameter value, do initial processing switch (fmt_spec) { // '%' and 'c' behave similar to 's' regarding flags and field widths diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index 25cbd60114..04979b867f 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -121,6 +121,12 @@ func Test_option_value() set cpo&vim endfunc +function Test_printf_64bit() + if has('num64') + call assert_equal("123456789012345", printf('%d', 123456789012345)) + endif +endfunc + func Test_setmatches() hi def link 1 Comment hi def link 2 PreProc diff --git a/src/nvim/version.c b/src/nvim/version.c index 40cea51c58..242b2c4b69 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -415,7 +415,7 @@ static const int included_patches[] = { // 2032 NA 2031, // 2030 NA - // 2029, + 2029, 2028, // 2027 NA // 2026 NA