Skip to content

Commit 38ee6b0

Browse files
committed
patch 7.4.2029
Problem: printf() does not work with 64 bit numbers. Solution: use the "L" length modifier. (Ken Takata)
1 parent 5498a41 commit 38ee6b0

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/message.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,6 +4198,15 @@ vim_vsnprintf(
41984198
default: break;
41994199
}
42004200

4201+
# if defined(FEAT_EVAL) && defined(FEAT_NUM64)
4202+
switch (fmt_spec)
4203+
{
4204+
case 'd': case 'u': case 'o': case 'x': case 'X':
4205+
if (tvs != NULL && length_modifier == '\0')
4206+
length_modifier = 'L';
4207+
}
4208+
# endif
4209+
42014210
/* get parameter value, do initial processing */
42024211
switch (fmt_spec)
42034212
{

src/testdir/test_expr.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,9 @@ func Test_option_value()
129129
call assert_equal("abcdefgi", &cpo)
130130
set cpo&vim
131131
endfunc
132+
133+
function Test_printf_64bit()
134+
if has('num64')
135+
call assert_equal("123456789012345", printf('%d', 123456789012345))
136+
endif
137+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,8 @@ static char *(features[]) =
758758

759759
static int included_patches[] =
760760
{ /* Add new patch number below this line */
761+
/**/
762+
2029,
761763
/**/
762764
2028,
763765
/**/

0 commit comments

Comments
 (0)