To: vim_dev@googlegroups.com Subject: Patch 8.0.0227 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 = ["\", "foobar\", "eins\", "\", "zwei\", "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\", "eins\", "\", "zwei\", "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 -- 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 ///