To: vim_dev@googlegroups.com Subject: Patch 8.1.2125 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2125 Problem: Fnamemodify() fails when repeating :e. Solution: Do not go before the tail. (Rob Pilling, closes #5024) Files: src/filepath.c, src/testdir/test_fnamemodify.vim *** ../vim-8.1.2124/src/filepath.c 2019-10-06 22:00:08.297244105 +0200 --- src/filepath.c 2019-10-08 23:21:51.723363379 +0200 *************** *** 563,569 **** } else // :r { ! if (s > tail) // remove one extension *fnamelen = (int)(s - *fnamep); } *usedlen += 2; --- 563,573 ---- } else // :r { ! char_u *limit = *fnamep; ! ! if (limit < tail) ! limit = tail; ! if (s > limit) // remove one extension *fnamelen = (int)(s - *fnamep); } *usedlen += 2; *** ../vim-8.1.2124/src/testdir/test_fnamemodify.vim 2019-08-24 20:49:58.825320302 +0200 --- src/testdir/test_fnamemodify.vim 2019-10-08 23:20:07.299875701 +0200 *************** *** 45,47 **** --- 45,75 ---- let $HOME = save_home let &shell = save_shell endfunc + + func Test_fnamemodify_er() + call assert_equal("with", fnamemodify("path/to/file.with.extensions", ':e:e:r:r')) + + call assert_equal('c', fnamemodify('a.c', ':e')) + call assert_equal('c', fnamemodify('a.c', ':e:e')) + call assert_equal('c', fnamemodify('a.c', ':e:e:r')) + call assert_equal('c', fnamemodify('a.c', ':e:e:r:r')) + + call assert_equal('rb', fnamemodify('a.spec.rb', ':e:r')) + call assert_equal('rb', fnamemodify('a.spec.rb', ':e:r')) + call assert_equal('spec.rb', fnamemodify('a.spec.rb', ':e:e')) + call assert_equal('spec', fnamemodify('a.spec.rb', ':e:e:r')) + call assert_equal('spec', fnamemodify('a.spec.rb', ':e:e:r:r')) + call assert_equal('spec', fnamemodify('a.b.spec.rb', ':e:e:r')) + call assert_equal('b.spec', fnamemodify('a.b.spec.rb', ':e:e:e:r')) + call assert_equal('b', fnamemodify('a.b.spec.rb', ':e:e:e:r:r')) + + call assert_equal('spec', fnamemodify('a.b.spec.rb', ':r:e')) + call assert_equal('b', fnamemodify('a.b.spec.rb', ':r:r:e')) + + call assert_equal('c', fnamemodify('a.b.c.d.e', ':r:r:e')) + call assert_equal('b.c', fnamemodify('a.b.c.d.e', ':r:r:e:e')) + + " :e never includes the whole filename, so "a.b":e:e:e --> "b" + call assert_equal('b.c', fnamemodify('a.b.c.d.e', ':r:r:e:e:e')) + call assert_equal('b.c', fnamemodify('a.b.c.d.e', ':r:r:e:e:e:e')) + endfunc *** ../vim-8.1.2124/src/version.c 2019-10-08 22:20:33.531292693 +0200 --- src/version.c 2019-10-08 23:22:07.099289578 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 2125, /**/ -- MONK: ... and the Lord spake, saying, "First shalt thou take out the Holy Pin, then shalt thou count to three, no more, no less. Three shalt be the number thou shalt count, and the number of the counting shalt be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thou foe, who being naughty in my sight, shall snuff it. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///