To: vim_dev@googlegroups.com Subject: Patch 8.2.1599 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1599 Problem: Missing line end when skipping a long line with :cgetfile. Solution: Fix off-by-one error. (closes #6870) Files: src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.2.1598/src/quickfix.c 2020-08-31 22:16:04.803294683 +0200 --- src/quickfix.c 2020-09-05 17:02:37.423364363 +0200 *************** *** 810,816 **** // reached. if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL || (int)STRLEN(IObuff) < IOSIZE - 1 ! || IObuff[IOSIZE - 1] == '\n') break; } --- 810,816 ---- // reached. if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL || (int)STRLEN(IObuff) < IOSIZE - 1 ! || IObuff[IOSIZE - 2] == '\n') break; } *** ../vim-8.2.1598/src/testdir/test_quickfix.vim 2020-09-04 21:18:40.488161918 +0200 --- src/testdir/test_quickfix.vim 2020-09-05 17:02:26.239385216 +0200 *************** *** 1744,1749 **** --- 1744,1767 ---- call s:long_lines_tests('l') endfunc + func Test_cgetfile_on_long_lines() + " Problematic values if the line is longer than 4096 bytes. Then 1024 bytes + " are read at a time. + for len in [4078, 4079, 4080, 5102, 5103, 5104, 6126, 6127, 6128, 7150, 7151, 7152] + let lines = [ + \ '/tmp/file1:1:1:aaa', + \ '/tmp/file2:1:1:%s', + \ '/tmp/file3:1:1:bbb', + \ '/tmp/file4:1:1:ccc', + \ ] + let lines[1] = substitute(lines[1], '%s', repeat('x', len), '') + call writefile(lines, 'Xcqetfile.txt') + cgetfile Xcqetfile.txt + call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len) + endfor + call delete('Xcqetfile.txt') + endfunc + func s:create_test_file(filename) let l = [] for i in range(1, 20) *** ../vim-8.2.1598/src/version.c 2020-09-05 16:08:46.594237023 +0200 --- src/version.c 2020-09-05 16:52:53.524288745 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1599, /**/ -- ARTHUR: You fight with the strength of many men, Sir knight. I am Arthur, King of the Britons. [pause] I seek the finest and the bravest knights in the land to join me in my Court of Camelot. [pause] You have proved yourself worthy; will you join me? [pause] You make me sad. So be it. Come, Patsy. BLACK KNIGHT: None shall pass. The Quest for the Holy Grail (Monty Python) /// 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 ///