Patch 8.2.4956
Problem: Reading past end of line with "gf" in Visual block mode.
Solution: Do not include the NUL in the length.
Files: src/normal.c, src/testdir/test_gf.vim
*** ../vim-8.2.4955/src/normal.c 2022-05-09 20:09:19.290641428 +0100
--- src/normal.c 2022-05-14 21:27:10.729808031 +0100
***************
*** 3671,3679 ****
}
if (**pp == NUL)
*lenp = 0;
! if (has_mbyte && *lenp > 0)
! // Correct the length to include all bytes of the last character.
! *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
}
reset_VIsual_and_resel();
return OK;
--- 3671,3686 ----
}
if (**pp == NUL)
*lenp = 0;
! if (*lenp > 0)
! {
! if (has_mbyte)
! // Correct the length to include all bytes of the last
! // character.
! *lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
! else if ((*pp)[*lenp - 1] == NUL)
! // Do not include a trailing NUL.
! *lenp -= 1;
! }
}
reset_VIsual_and_resel();
return OK;
*** ../vim-8.2.4955/src/testdir/test_gf.vim 2022-01-31 14:59:33.526943578
+0000
--- src/testdir/test_gf.vim 2022-05-14 21:25:03.329899241 +0100
***************
*** 138,143 ****
--- 138,158 ----
call assert_equal('Xtest_gf_visual', bufname('%'))
call assert_equal(3, getcurpos()[1])
+ " do not include the NUL at the end
+ call writefile(['x'], 'X')
+ let save_enc = &enc
+ for enc in ['latin1', 'utf-8']
+ exe "set enc=" .. enc
+ new
+ call setline(1, 'X')
+ set nomodified
+ exe "normal \<C-V>$gf"
+ call assert_equal('X', bufname())
+ bwipe!
+ endfor
+ let &enc = save_enc
+ call delete('X')
+
" line number in visual area is used for file name
if has('unix')
bwipe!
*** ../vim-8.2.4955/src/version.c 2022-05-14 18:47:58.807259718 +0100
--- src/version.c 2022-05-14 21:19:04.510162230 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4956,
/**/
--
hundred-and-one symptoms of being an internet addict:
200. You really believe in the concept of a "paperless" office.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220514203102.969881C076D%40moolenaar.net.