Karsten Hopp 990a0e
To: vim_dev@googlegroups.com
Karsten Hopp 990a0e
Subject: Patch 7.3.150
Karsten Hopp 990a0e
Fcc: outbox
Karsten Hopp 990a0e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 990a0e
Mime-Version: 1.0
Karsten Hopp 990a0e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 990a0e
Content-Transfer-Encoding: 8bit
Karsten Hopp 990a0e
------------
Karsten Hopp 990a0e
Karsten Hopp 990a0e
Patch 7.3.150
Karsten Hopp 990a0e
Problem:    readline() does not return the last line when the NL is missing.
Karsten Hopp 990a0e
	    (Hong Xu)
Karsten Hopp 990a0e
Solution:   When at the end of the file Also check for a previous line.
Karsten Hopp 990a0e
Files:	    src/eval.c
Karsten Hopp 990a0e
Karsten Hopp 990a0e
Karsten Hopp 990a0e
*** ../vim-7.3.149/src/eval.c	2011-03-27 16:03:09.000000000 +0200
Karsten Hopp 990a0e
--- src/eval.c	2011-04-01 16:06:04.000000000 +0200
Karsten Hopp 990a0e
***************
Karsten Hopp 990a0e
*** 14305,14313 ****
Karsten Hopp 990a0e
  	{
Karsten Hopp 990a0e
  	    if (buf[filtd] == '\n' || readlen <= 0)
Karsten Hopp 990a0e
  	    {
Karsten Hopp 990a0e
! 		/* Only when in binary mode add an empty list item when the
Karsten Hopp 990a0e
! 		 * last line ends in a '\n'. */
Karsten Hopp 990a0e
! 		if (!binary && readlen == 0 && filtd == 0)
Karsten Hopp 990a0e
  		    break;
Karsten Hopp 990a0e
  
Karsten Hopp 990a0e
  		/* Found end-of-line or end-of-file: add a text line to the
Karsten Hopp 990a0e
--- 14305,14313 ----
Karsten Hopp 990a0e
  	{
Karsten Hopp 990a0e
  	    if (buf[filtd] == '\n' || readlen <= 0)
Karsten Hopp 990a0e
  	    {
Karsten Hopp 990a0e
! 		/* In binary mode add an empty list item when the last
Karsten Hopp 990a0e
! 		 * non-empty line ends in a '\n'. */
Karsten Hopp 990a0e
! 		if (!binary && readlen == 0 && filtd == 0 && prev == NULL)
Karsten Hopp 990a0e
  		    break;
Karsten Hopp 990a0e
  
Karsten Hopp 990a0e
  		/* Found end-of-line or end-of-file: add a text line to the
Karsten Hopp 990a0e
***************
Karsten Hopp 990a0e
*** 14372,14396 ****
Karsten Hopp 990a0e
  
Karsten Hopp 990a0e
  	if (tolist == 0)
Karsten Hopp 990a0e
  	{
Karsten Hopp 990a0e
! 	    /* "buf" is full, need to move text to an allocated buffer */
Karsten Hopp 990a0e
! 	    if (prev == NULL)
Karsten Hopp 990a0e
  	    {
Karsten Hopp 990a0e
! 		prev = vim_strnsave(buf, buflen);
Karsten Hopp 990a0e
! 		prevlen = buflen;
Karsten Hopp 990a0e
! 	    }
Karsten Hopp 990a0e
! 	    else
Karsten Hopp 990a0e
! 	    {
Karsten Hopp 990a0e
! 		s = alloc((unsigned)(prevlen + buflen));
Karsten Hopp 990a0e
! 		if (s != NULL)
Karsten Hopp 990a0e
  		{
Karsten Hopp 990a0e
! 		    mch_memmove(s, prev, prevlen);
Karsten Hopp 990a0e
! 		    mch_memmove(s + prevlen, buf, buflen);
Karsten Hopp 990a0e
! 		    vim_free(prev);
Karsten Hopp 990a0e
! 		    prev = s;
Karsten Hopp 990a0e
! 		    prevlen += buflen;
Karsten Hopp 990a0e
  		}
Karsten Hopp 990a0e
  	    }
Karsten Hopp 990a0e
- 	    filtd = 0;
Karsten Hopp 990a0e
  	}
Karsten Hopp 990a0e
  	else
Karsten Hopp 990a0e
  	{
Karsten Hopp 990a0e
--- 14372,14399 ----
Karsten Hopp 990a0e
  
Karsten Hopp 990a0e
  	if (tolist == 0)
Karsten Hopp 990a0e
  	{
Karsten Hopp 990a0e
! 	    if (buflen >= FREAD_SIZE / 2)
Karsten Hopp 990a0e
  	    {
Karsten Hopp 990a0e
! 		/* "buf" is full, need to move text to an allocated buffer */
Karsten Hopp 990a0e
! 		if (prev == NULL)
Karsten Hopp 990a0e
! 		{
Karsten Hopp 990a0e
! 		    prev = vim_strnsave(buf, buflen);
Karsten Hopp 990a0e
! 		    prevlen = buflen;
Karsten Hopp 990a0e
! 		}
Karsten Hopp 990a0e
! 		else
Karsten Hopp 990a0e
  		{
Karsten Hopp 990a0e
! 		    s = alloc((unsigned)(prevlen + buflen));
Karsten Hopp 990a0e
! 		    if (s != NULL)
Karsten Hopp 990a0e
! 		    {
Karsten Hopp 990a0e
! 			mch_memmove(s, prev, prevlen);
Karsten Hopp 990a0e
! 			mch_memmove(s + prevlen, buf, buflen);
Karsten Hopp 990a0e
! 			vim_free(prev);
Karsten Hopp 990a0e
! 			prev = s;
Karsten Hopp 990a0e
! 			prevlen += buflen;
Karsten Hopp 990a0e
! 		    }
Karsten Hopp 990a0e
  		}
Karsten Hopp 990a0e
+ 		filtd = 0;
Karsten Hopp 990a0e
  	    }
Karsten Hopp 990a0e
  	}
Karsten Hopp 990a0e
  	else
Karsten Hopp 990a0e
  	{
Karsten Hopp 990a0e
*** ../vim-7.3.149/src/version.c	2011-04-01 15:33:54.000000000 +0200
Karsten Hopp 990a0e
--- src/version.c	2011-04-01 16:04:42.000000000 +0200
Karsten Hopp 990a0e
***************
Karsten Hopp 990a0e
*** 716,717 ****
Karsten Hopp 990a0e
--- 716,719 ----
Karsten Hopp 990a0e
  {   /* Add new patch number below this line */
Karsten Hopp 990a0e
+ /**/
Karsten Hopp 990a0e
+     150,
Karsten Hopp 990a0e
  /**/
Karsten Hopp 990a0e
Karsten Hopp 990a0e
-- 
Karsten Hopp 990a0e
ARTHUR: What are you going to do. bleed on me?
Karsten Hopp 990a0e
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 990a0e
Karsten Hopp 990a0e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 990a0e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 990a0e
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 990a0e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///