From ccdb37b075c6804cece245a58d766efb0f6a22f2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Apr 2025 06:49:42 +0800 Subject: [PATCH 1/2] vim-patch:9.1.1314: max allowed string width too small Problem: max allowed string width too small Solution: increased MAX_ALLOWED_STRING_WIDTH from 6400 to 1MiB (Hirohito Higashi) closes: vim/vim#17138 https://github.com/vim/vim/commit/06fdfa11c565599ac13ad5c077d1dabbbfde03ac Co-authored-by: Hirohito Higashi Co-authored-by: John Marriott --- src/nvim/strings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/strings.c b/src/nvim/strings.c index add4c9dcb6..0538ee2b22 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -1027,7 +1027,7 @@ static void format_overflow_error(const char *pstart) xfree(argcopy); } -enum { MAX_ALLOWED_STRING_WIDTH = 6400, }; +enum { MAX_ALLOWED_STRING_WIDTH = 1048576, }; // 1MiB static int get_unsigned_int(const char *pstart, const char **p, unsigned *uj, bool overflow_err) { From 0251a25541a3945bbbcc6f9b5964cd26283cb105 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Apr 2025 16:58:55 +0800 Subject: [PATCH 2/2] vim-patch:9.1.1318: tests: test_format fails Problem: tests: test_format fails (after 9.1.1314). Solution: Increase the string size. Add missing test_format.res in NEW_TESTS_RES (zeertzjq). closes: vim/vim#17144 https://github.com/vim/vim/commit/e9a27ef37395a0130f99e21b288b7765f0e38236 --- runtime/doc/builtin.txt | 3 ++- runtime/lua/vim/_meta/vimfn.lua | 3 ++- src/nvim/eval.lua | 3 ++- test/old/testdir/test_format.vim | 12 ++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 549bd8db1a..351b17fc59 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -7395,7 +7395,8 @@ printf({fmt}, {expr1} ...) *printf()* < 1.41 You will get an overflow error |E1510|, when the field-width - or precision will result in a string longer than 6400 chars. + or precision will result in a string longer than 1 MB + (1024*1024 = 1048576) chars. *E1500* You cannot mix positional and non-positional arguments: >vim diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 3b0d51a429..c1387954df 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -6720,7 +6720,8 @@ function vim.fn.prevnonblank(lnum) end --- < 1.41 --- --- You will get an overflow error |E1510|, when the field-width ---- or precision will result in a string longer than 6400 chars. +--- or precision will result in a string longer than 1 MB +--- (1024*1024 = 1048576) chars. --- --- *E1500* --- You cannot mix positional and non-positional arguments: >vim diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 6b4c88f071..1433394e19 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -8169,7 +8169,8 @@ M.funcs = { < 1.41 You will get an overflow error |E1510|, when the field-width - or precision will result in a string longer than 6400 chars. + or precision will result in a string longer than 1 MB + (1024*1024 = 1048576) chars. *E1500* You cannot mix positional and non-positional arguments: >vim diff --git a/test/old/testdir/test_format.vim b/test/old/testdir/test_format.vim index 36795c87ea..c2126f583c 100644 --- a/test/old/testdir/test_format.vim +++ b/test/old/testdir/test_format.vim @@ -334,13 +334,13 @@ func Test_printf_pos_errors() call CheckLegacyAndVim9Failure(["call printf('%1$*123456789$.*987654321$d', 5)"], "E1510:") call CheckLegacyAndVim9Failure(["call printf('%123456789$*1$.*987654321$d', 5)"], "E1510:") - call CheckLegacyAndVim9Failure(["call printf('%1$*2$.*1$d', 5, 9999)"], "E1510:") - call CheckLegacyAndVim9Failure(["call printf('%1$*1$.*2$d', 5, 9999)"], "E1510:") - call CheckLegacyAndVim9Failure(["call printf('%2$*3$.*1$d', 5, 9123, 9321)"], "E1510:") - call CheckLegacyAndVim9Failure(["call printf('%1$*2$.*3$d', 5, 9123, 9321)"], "E1510:") - call CheckLegacyAndVim9Failure(["call printf('%2$*1$.*3$d', 5, 9123, 9312)"], "E1510:") + call CheckLegacyAndVim9Failure(["call printf('%1$*2$.*1$d', 5, 9999999)"], "E1510:") + call CheckLegacyAndVim9Failure(["call printf('%1$*1$.*2$d', 5, 9999999)"], "E1510:") + call CheckLegacyAndVim9Failure(["call printf('%2$*3$.*1$d', 5, 9999123, 9999321)"], "E1510:") + call CheckLegacyAndVim9Failure(["call printf('%1$*2$.*3$d', 5, 9999123, 9999321)"], "E1510:") + call CheckLegacyAndVim9Failure(["call printf('%2$*1$.*3$d', 5, 9999123, 9999312)"], "E1510:") - call CheckLegacyAndVim9Failure(["call printf('%1$*2$d', 5, 9999)"], "E1510:") + call CheckLegacyAndVim9Failure(["call printf('%1$*2$d', 5, 9999999)"], "E1510:") endfunc func Test_printf_pos_64bit()