diff options
author | Bram Moolenaar <Bram@vim.org> | 2011-04-01 16:07:46 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2011-04-01 16:07:46 +0200 |
commit | 27b6056d85370f13c4e156d83d095676357ba34a (patch) | |
tree | ed684d5e03d1cb086976cc809cefa3721328ca61 /src | |
parent | 96bcc5e6cd90c914c55e1606067fbdee4a981891 (diff) | |
download | vim-27b6056d85370f13c4e156d83d095676357ba34a.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 39 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 23 insertions, 18 deletions
diff --git a/src/eval.c b/src/eval.c index 7baa8a72d..d9dc3f103 100644 --- a/src/eval.c +++ b/src/eval.c @@ -14305,9 +14305,9 @@ f_readfile(argvars, rettv) { if (buf[filtd] == '\n' || readlen <= 0) { - /* Only when in binary mode add an empty list item when the - * last line ends in a '\n'. */ - if (!binary && readlen == 0 && filtd == 0) + /* In binary mode add an empty list item when the last + * non-empty line ends in a '\n'. */ + if (!binary && readlen == 0 && filtd == 0 && prev == NULL) break; /* 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) { - /* "buf" is full, need to move text to an allocated buffer */ - if (prev == NULL) + if (buflen >= FREAD_SIZE / 2) { - prev = vim_strnsave(buf, buflen); - prevlen = buflen; - } - else - { - s = alloc((unsigned)(prevlen + buflen)); - if (s != NULL) + /* "buf" is full, need to move text to an allocated buffer */ + if (prev == NULL) { - mch_memmove(s, prev, prevlen); - mch_memmove(s + prevlen, buf, buflen); - vim_free(prev); - prev = s; - prevlen += buflen; + prev = vim_strnsave(buf, buflen); + 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 { diff --git a/src/version.c b/src/version.c index d96aa0270..63ddf68a2 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 150, +/**/ 149, /**/ 148, |