summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-05 17:03:40 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-05 17:03:40 +0200
commit59941cbd8035415d68683edc4e571306b10669ad (patch)
tree5006831992654145681761ef48fe74918000589f
parent2ce14589f210dcb3d17d1d80285256f8ac10abab (diff)
downloadvim-git-59941cbd8035415d68683edc4e571306b10669ad.tar.gz
patch 8.2.1599: missing line end when skipping a long line with :cgetfilev8.2.1599
Problem: Missing line end when skipping a long line with :cgetfile. Solution: Fix off-by-one error. (closes #6870)
-rw-r--r--src/quickfix.c2
-rw-r--r--src/testdir/test_quickfix.vim18
-rw-r--r--src/version.c2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index f8ff7765e..09d5d8fa0 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -810,7 +810,7 @@ qf_get_next_file_line(qfstate_T *state)
// reached.
if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL
|| (int)STRLEN(IObuff) < IOSIZE - 1
- || IObuff[IOSIZE - 1] == '\n')
+ || IObuff[IOSIZE - 2] == '\n')
break;
}
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 2fbbd143e..1e753a467 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1744,6 +1744,24 @@ func Test_long_lines()
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)
diff --git a/src/version.c b/src/version.c
index b6a6f41cb..b7b5d272e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1599,
+/**/
1598,
/**/
1597,