]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.150 v7.3.150
authorBram Moolenaar <Bram@vim.org>
Fri, 1 Apr 2011 14:07:46 +0000 (16:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 1 Apr 2011 14:07:46 +0000 (16:07 +0200)
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.

src/eval.c
src/version.c

index 7baa8a72d63fcaa3436e3c272d769cb444bbfd27..d9dc3f10314bace6c14cf2da8c5ed9c068c135b6 100644 (file)
@@ -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
        {
index d96aa0270b7723d0ddd90bbe3975a868f5ddcf06..63ddf68a226bd30b8da2bfad84f6f82e23e77287 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    150,
 /**/
     149,
 /**/