To: vim_dev@googlegroups.com Subject: Patch 8.1.1835 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1835 Problem: Cannot use printf() as a method. Solution: Pass the base as the second argument to printf(). Files: runtime/doc/eval.txt, src/evalfunc.c, src/testdir/test_method.vim *** ../vim-8.1.1834/runtime/doc/eval.txt 2019-08-09 23:25:02.636657233 +0200 --- runtime/doc/eval.txt 2019-08-10 00:06:43.094528634 +0200 *************** *** 6719,6725 **** < May result in: " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~ ! Often used items are: %s string %6S string right-aligned in 6 display cells %6s string right-aligned in 6 bytes --- 6742,6752 ---- < May result in: " 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~ ! When used as a |method| the base is passed as the second ! argument: > ! Compute()->printf("result: %d") ! ! < Often used items are: %s string %6S string right-aligned in 6 display cells %6s string right-aligned in 6 bytes *** ../vim-8.1.1834/src/evalfunc.c 2019-08-09 17:00:58.600643013 +0200 --- src/evalfunc.c 2019-08-09 23:57:32.648851338 +0200 *************** *** 733,739 **** {"pow", 2, 2, 0, f_pow}, #endif {"prevnonblank", 1, 1, 0, f_prevnonblank}, ! {"printf", 1, 19, 0, f_printf}, #ifdef FEAT_JOB_CHANNEL {"prompt_setcallback", 2, 2, 0, f_prompt_setcallback}, {"prompt_setinterrupt", 2, 2, 0, f_prompt_setinterrupt}, --- 733,739 ---- {"pow", 2, 2, 0, f_pow}, #endif {"prevnonblank", 1, 1, 0, f_prevnonblank}, ! {"printf", 1, 19, FEARG_2, f_printf}, #ifdef FEAT_JOB_CHANNEL {"prompt_setcallback", 2, 2, 0, f_prompt_setcallback}, {"prompt_setinterrupt", 2, 2, 0, f_prompt_setinterrupt}, *** ../vim-8.1.1834/src/testdir/test_method.vim 2019-08-09 23:25:02.636657233 +0200 --- src/testdir/test_method.vim 2019-08-10 00:03:27.131357433 +0200 *************** *** 67,79 **** endfunc func Test_string_method() ! call assert_equal(['1', '2', '3'], '1 2 3'->split()) ! call assert_equal([1, 2, 3], '1 2 3'->split()->map({i, v -> str2nr(v)})) ! call assert_equal([65, 66, 67], 'ABC'->str2list()) ! call assert_equal(3, 'ABC'->strlen()) ! call assert_equal('a^Mb^[c', "a\rb\ec"->strtrans()) ! call assert_equal(4, "aあb"->strwidth()) ! call assert_equal('axc', 'abc'->substitute('b', 'x', '')) endfunc func Test_method_append() --- 67,81 ---- endfunc func Test_string_method() ! eval '1 2 3'->split()->assert_equal(['1', '2', '3']) ! eval '1 2 3'->split()->map({i, v -> str2nr(v)})->assert_equal([1, 2, 3]) ! eval 'ABC'->str2list()->assert_equal([65, 66, 67]) ! eval 'ABC'->strlen()->assert_equal(3) ! eval "a\rb\ec"->strtrans()->assert_equal('a^Mb^[c') ! eval "aあb"->strwidth()->assert_equal(4) ! eval 'abc'->substitute('b', 'x', '')->assert_equal('axc') ! ! eval 'abc'->printf('the %s arg')->assert_equal('the abc arg') endfunc func Test_method_append() *** ../vim-8.1.1834/src/version.c 2019-08-09 23:25:02.636657233 +0200 --- src/version.c 2019-08-09 23:59:01.048479639 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 1835, /**/ -- Bumper sticker: Honk if you love peace and quiet. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///