0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

updated for version 7.3.150

Problem:    readline() does not return the last line when the NL is missing.
            (Hong Xu)
Solution:   When at the end of the file Also check for a previous line.
This commit is contained in:
Bram Moolenaar
2011-04-01 16:07:46 +02:00
parent 96bcc5e6cd
commit 27b6056d85
2 changed files with 23 additions and 18 deletions

View File

@@ -14305,9 +14305,9 @@ f_readfile(argvars, rettv)
{ {
if (buf[filtd] == '\n' || readlen <= 0) if (buf[filtd] == '\n' || readlen <= 0)
{ {
/* Only when in binary mode add an empty list item when the /* In binary mode add an empty list item when the last
* last line ends in a '\n'. */ * non-empty line ends in a '\n'. */
if (!binary && readlen == 0 && filtd == 0) if (!binary && readlen == 0 && filtd == 0 && prev == NULL)
break; break;
/* Found end-of-line or end-of-file: add a text line to the /* Found end-of-line or end-of-file: add a text line to the
@@ -14371,6 +14371,8 @@ f_readfile(argvars, rettv)
break; break;
if (tolist == 0) if (tolist == 0)
{
if (buflen >= FREAD_SIZE / 2)
{ {
/* "buf" is full, need to move text to an allocated buffer */ /* "buf" is full, need to move text to an allocated buffer */
if (prev == NULL) if (prev == NULL)
@@ -14392,6 +14394,7 @@ f_readfile(argvars, rettv)
} }
filtd = 0; filtd = 0;
} }
}
else else
{ {
mch_memmove(buf, buf + tolist, buflen - tolist); mch_memmove(buf, buf + tolist, buflen - tolist);

View File

@@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
150,
/**/ /**/
149, 149,
/**/ /**/