From: Bram Moolenaar Date: Tue, 12 Jul 2016 19:11:33 +0000 (+0200) Subject: patch 7.4.2029 X-Git-Tag: v7.4.2029 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38ee6b041e73ad31c3b6b99d56d20833b59b2b57;p=vim patch 7.4.2029 Problem: printf() does not work with 64 bit numbers. Solution: use the "L" length modifier. (Ken Takata) --- diff --git a/src/message.c b/src/message.c index 7bb154d2e..954152850 100644 --- a/src/message.c +++ b/src/message.c @@ -4198,6 +4198,15 @@ vim_vsnprintf( default: break; } +# if defined(FEAT_EVAL) && defined(FEAT_NUM64) + switch (fmt_spec) + { + case 'd': case 'u': case 'o': case 'x': case 'X': + if (tvs != NULL && length_modifier == '\0') + length_modifier = 'L'; + } +# endif + /* get parameter value, do initial processing */ switch (fmt_spec) { diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 067dbf24f..86c86c58d 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -129,3 +129,9 @@ func Test_option_value() call assert_equal("abcdefgi", &cpo) set cpo&vim endfunc + +function Test_printf_64bit() + if has('num64') + call assert_equal("123456789012345", printf('%d', 123456789012345)) + endif +endfunc diff --git a/src/version.c b/src/version.c index 6d75f76f1..301b406d2 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2029, /**/ 2028, /**/