Hi,
2016/7/13 Wed 0:10:46 UTC+9 Ken Takata wrote:
> Hi,
>
> The printf() function on Vim script doesn't support 64-bit Numbers.
> E.g.:
>
> :echo 100000000000000
> 100000000000000
> :echo printf('%d', 100000000000000)
> 276447232
>
> Attached patch fixes the problem.
A test is added.
Please check the attached patch.
Regards,
Ken Takata
--
--
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.
# HG changeset patch
# Parent b366794c67551cd403263586cbcc929a74a62b32
diff --git a/src/message.c b/src/message.c
--- a/src/message.c
+++ b/src/message.c
@@ -4205,6 +4205,17 @@ 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';
+ default:
+ break;
+ }
+# endif
+
/* get parameter value, do initial processing */
switch (fmt_spec)
{
diff --git a/src/testdir/test_viml.vim b/src/testdir/test_viml.vim
--- a/src/testdir/test_viml.vim
+++ b/src/testdir/test_viml.vim
@@ -1222,6 +1222,8 @@ func Test_num64()
call assert_equal(0x100000001, max(rng))
call assert_equal(0xFFFFffff, min(rng))
call assert_equal(rng, sort(range(0x100000001, 0xFFFFffff, -1), 'N'))
+
+ call assert_equal("123456789012345", printf('%d', 123456789012345))
endfunc
"-------------------------------------------------------------------------------