Patch 8.0.0227
Problem: Crash when 'fileformat' is forced to "dos" and the first line in
the file is empty and does not have a CR character.
Solution: Don't check for CR before the start of the buffer.
Files: src/fileio.c, src/testdir/test_fileformat.vim
*** ../vim-8.0.0226/src/fileio.c 2017-01-23 21:31:05.203482973 +0100
--- src/fileio.c 2017-01-24 15:38:41.034570560 +0100
***************
*** 2251,2258 ****
len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS)
{
! if (ptr[-1] == CAR) /* remove CR */
{
ptr[-1] = NUL;
--len;
}
--- 2251,2259 ----
len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS)
{
! if (ptr > line_start && ptr[-1] == CAR)
{
+ /* remove CR before NL */
ptr[-1] = NUL;
--len;
}
*** ../vim-8.0.0226/src/testdir/test_fileformat.vim 2017-01-24
13:18:40.169542919 +0100
--- src/testdir/test_fileformat.vim 2017-01-24 15:36:35.475407490 +0100
***************
*** 17,23 ****
endfunc
func Test_fileformat_autocommand()
! let filecnt = ["\<CR>", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>",
"drei", "vier", "fünf", ""]
let ffs = &ffs
call writefile(filecnt, 'Xfile', 'b')
au BufReadPre Xfile set ffs=dos ff=dos
--- 17,23 ----
endfunc
func Test_fileformat_autocommand()
! let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>",
"drei", "vier", "fünf", ""]
let ffs = &ffs
call writefile(filecnt, 'Xfile', 'b')
au BufReadPre Xfile set ffs=dos ff=dos
*** ../vim-8.0.0226/src/version.c 2017-01-24 13:18:40.169542919 +0100
--- src/version.c 2017-01-24 15:41:00.093644191 +0100
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 227,
/**/
--
Computers are not intelligent. They only think they are.
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
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.