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
@@ -14372,25 +14372,28 @@ f_readfile(argvars, rettv)
if (tolist == 0) if (tolist == 0)
{ {
/* "buf" is full, need to move text to an allocated buffer */ if (buflen >= FREAD_SIZE / 2)
if (prev == NULL)
{ {
prev = vim_strnsave(buf, buflen); /* "buf" is full, need to move text to an allocated buffer */
prevlen = buflen; if (prev == NULL)
}
else
{
s = alloc((unsigned)(prevlen + buflen));
if (s != NULL)
{ {
mch_memmove(s, prev, prevlen); prev = vim_strnsave(buf, buflen);
mch_memmove(s + prevlen, buf, buflen); prevlen = buflen;
vim_free(prev);
prev = s;
prevlen += buflen;
} }
else
{
s = alloc((unsigned)(prevlen + buflen));
if (s != NULL)
{
mch_memmove(s, prev, prevlen);
mch_memmove(s + prevlen, buf, buflen);
vim_free(prev);
prev = s;
prevlen += buflen;
}
}
filtd = 0;
} }
filtd = 0;
} }
else else
{ {

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,
/**/ /**/