Blame SOURCES/7.4.539

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.539
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.539 (after 7.4.530)
22c937
Problem:    Crash when computing buffer count.  Problem with range for user
22c937
	    commands.  Line range wrong in Visual area.
22c937
Solution:   Avoid segfault in compute_buffer_local_count().  Check for
22c937
	    CMD_USER when checking type of range. (Marcin Szamotulski)
22c937
Files:	    runtime/doc/windows.txt, src/ex_docmd.c
22c937
22c937
22c937
*** ../vim-7.4.538/runtime/doc/windows.txt	2014-11-27 16:22:42.738413084 +0100
22c937
--- runtime/doc/windows.txt	2014-11-30 14:34:30.241835431 +0100
22c937
***************
22c937
*** 1026,1032 ****
22c937
  		Actually, the buffer isn't completely deleted, it is removed
22c937
  		from the buffer list |unlisted-buffer| and option values,
22c937
  		variables and mappings/abbreviations for the buffer are
22c937
! 		cleared.
22c937
  
22c937
  :bdelete[!] {bufname}						*E93* *E94*
22c937
  		Like ":bdelete[!] [N]", but buffer given by name.  Note that a
22c937
--- 1029,1039 ----
22c937
  		Actually, the buffer isn't completely deleted, it is removed
22c937
  		from the buffer list |unlisted-buffer| and option values,
22c937
  		variables and mappings/abbreviations for the buffer are
22c937
! 		cleared. Examples: >
22c937
! 		    :.,$-bdelete    " delete buffers from the current one to
22c937
! 				    " last but one
22c937
! 		    :%bdelete	    " delete all buffers
22c937
! <
22c937
  
22c937
  :bdelete[!] {bufname}						*E93* *E94*
22c937
  		Like ":bdelete[!] [N]", but buffer given by name.  Note that a
22c937
***************
22c937
*** 1050,1056 ****
22c937
  		Like |:bdelete|, but really delete the buffer.  Everything
22c937
  		related to the buffer is lost.  All marks in this buffer
22c937
  		become invalid, option settings are lost, etc.  Don't use this
22c937
! 		unless you know what you are doing.
22c937
  
22c937
  :[N]bun[load][!]				*:bun* *:bunload* *E515*
22c937
  :bun[load][!] [N]
22c937
--- 1057,1067 ----
22c937
  		Like |:bdelete|, but really delete the buffer.  Everything
22c937
  		related to the buffer is lost.  All marks in this buffer
22c937
  		become invalid, option settings are lost, etc.  Don't use this
22c937
! 		unless you know what you are doing. Examples: >
22c937
! 		    :.+,$bwipeout   " wipe out all buffers after the current
22c937
! 				    " one
22c937
! 		    :%bwipeout	    " wipe out all buffers
22c937
! <
22c937
  
22c937
  :[N]bun[load][!]				*:bun* *:bunload* *E515*
22c937
  :bun[load][!] [N]
22c937
*** ../vim-7.4.538/src/ex_docmd.c	2014-11-27 18:32:58.528564550 +0100
22c937
--- src/ex_docmd.c	2014-11-30 14:40:28.521847466 +0100
22c937
***************
22c937
*** 1694,1699 ****
22c937
--- 1694,1700 ----
22c937
      int	    offset;
22c937
  {
22c937
      buf_T   *buf;
22c937
+     buf_T   *nextbuf;
22c937
      int     count = offset;
22c937
  
22c937
      buf = firstbuf;
22c937
***************
22c937
*** 1701,1715 ****
22c937
  	buf = buf->b_next;
22c937
      while (count != 0)
22c937
      {
22c937
! 	count += (count < 0) ? 1 : -1;
22c937
! 	if (buf->b_prev == NULL)
22c937
  	    break;
22c937
! 	buf = (count < 0) ? buf->b_prev : buf->b_next;
22c937
  	if (addr_type == ADDR_LOADED_BUFFERS)
22c937
  	    /* skip over unloaded buffers */
22c937
! 	    while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
22c937
! 		buf = (count < 0) ? buf->b_prev : buf->b_next;
22c937
      }
22c937
      return buf->b_fnum;
22c937
  }
22c937
  
22c937
--- 1702,1731 ----
22c937
  	buf = buf->b_next;
22c937
      while (count != 0)
22c937
      {
22c937
! 	count += (offset < 0) ? 1 : -1;
22c937
! 	nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
22c937
! 	if (nextbuf == NULL)
22c937
  	    break;
22c937
! 	buf = nextbuf;
22c937
  	if (addr_type == ADDR_LOADED_BUFFERS)
22c937
  	    /* skip over unloaded buffers */
22c937
! 	    while (buf->b_ml.ml_mfp == NULL)
22c937
! 	    {
22c937
! 		nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
22c937
! 		if (nextbuf == NULL)
22c937
! 		    break;
22c937
! 		buf = nextbuf;
22c937
! 	    }
22c937
      }
22c937
+     /* we might have gone too far, last buffer is not loadedd */
22c937
+     if (addr_type == ADDR_LOADED_BUFFERS)
22c937
+ 	while (buf->b_ml.ml_mfp == NULL)
22c937
+ 	{
22c937
+ 	    nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next;
22c937
+ 	    if (nextbuf == NULL)
22c937
+ 		break;
22c937
+ 	    buf = nextbuf;
22c937
+ 	}
22c937
      return buf->b_fnum;
22c937
  }
22c937
  
22c937
***************
22c937
*** 2113,2119 ****
22c937
   * is equal to the lower.
22c937
   */
22c937
  
22c937
!     if (ea.cmdidx != CMD_SIZE)
22c937
  	ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
22c937
      else
22c937
  	ea.addr_type = ADDR_LINES;
22c937
--- 2129,2135 ----
22c937
   * is equal to the lower.
22c937
   */
22c937
  
22c937
!     if (ea.cmdidx != CMD_USER && ea.cmdidx != CMD_SIZE)
22c937
  	ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
22c937
      else
22c937
  	ea.addr_type = ADDR_LINES;
22c937
***************
22c937
*** 2153,2158 ****
22c937
--- 2169,2175 ----
22c937
  	{
22c937
  	    if (*ea.cmd == '%')		    /* '%' - all lines */
22c937
  	    {
22c937
+ 		buf_T	*buf;
22c937
  		++ea.cmd;
22c937
  		switch (ea.addr_type)
22c937
  		{
22c937
***************
22c937
*** 2160,2168 ****
22c937
  			ea.line1 = 1;
22c937
  			ea.line2 = curbuf->b_ml.ml_line_count;
22c937
  			break;
22c937
- 		    case ADDR_WINDOWS:
22c937
  		    case ADDR_LOADED_BUFFERS:
22c937
  		    case ADDR_UNLOADED_BUFFERS:
22c937
  		    case ADDR_TABS:
22c937
  			errormsg = (char_u *)_(e_invrange);
22c937
  			goto doend;
22c937
--- 2177,2197 ----
22c937
  			ea.line1 = 1;
22c937
  			ea.line2 = curbuf->b_ml.ml_line_count;
22c937
  			break;
22c937
  		    case ADDR_LOADED_BUFFERS:
22c937
+ 			buf = firstbuf;
22c937
+ 			while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL)
22c937
+ 			    buf = buf->b_next;
22c937
+ 			ea.line1 = buf->b_fnum;
22c937
+ 			buf = lastbuf;
22c937
+ 			while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
22c937
+ 			    buf = buf->b_prev;
22c937
+ 			ea.line2 = buf->b_fnum;
22c937
+ 			break;
22c937
  		    case ADDR_UNLOADED_BUFFERS:
22c937
+ 			ea.line1 = firstbuf->b_fnum;
22c937
+ 			ea.line2 = lastbuf->b_fnum;
22c937
+ 			break;
22c937
+ 		    case ADDR_WINDOWS:
22c937
  		    case ADDR_TABS:
22c937
  			errormsg = (char_u *)_(e_invrange);
22c937
  			goto doend;
22c937
***************
22c937
*** 4463,4469 ****
22c937
  		n = getdigits(&cmd);
22c937
  	    if (addr_type == ADDR_LOADED_BUFFERS
22c937
  		    || addr_type == ADDR_UNLOADED_BUFFERS)
22c937
! 		lnum = compute_buffer_local_count(addr_type, lnum, n);
22c937
  	    else if (i == '-')
22c937
  		lnum -= n;
22c937
  	    else
22c937
--- 4492,4498 ----
22c937
  		n = getdigits(&cmd);
22c937
  	    if (addr_type == ADDR_LOADED_BUFFERS
22c937
  		    || addr_type == ADDR_UNLOADED_BUFFERS)
22c937
! 		lnum = compute_buffer_local_count(addr_type, lnum, (i == '-') ? -1 * n : n);
22c937
  	    else if (i == '-')
22c937
  		lnum -= n;
22c937
  	    else
22c937
***************
22c937
*** 4485,4493 ****
22c937
  			lnum = 0;
22c937
  			break;
22c937
  		    }
22c937
! 		    c = LAST_TAB_NR;
22c937
! 		    if (lnum >= c)
22c937
! 			lnum = c;
22c937
  		    break;
22c937
  		case ADDR_WINDOWS:
22c937
  		    if (lnum < 0)
22c937
--- 4514,4521 ----
22c937
  			lnum = 0;
22c937
  			break;
22c937
  		    }
22c937
! 		    if (lnum >= LAST_TAB_NR)
22c937
! 			lnum = LAST_TAB_NR;
22c937
  		    break;
22c937
  		case ADDR_WINDOWS:
22c937
  		    if (lnum < 0)
22c937
***************
22c937
*** 4495,4503 ****
22c937
  			lnum = 0;
22c937
  			break;
22c937
  		    }
22c937
! 		    c = LAST_WIN_NR;
22c937
! 		    if (lnum > c)
22c937
! 			lnum = c;
22c937
  		    break;
22c937
  		case ADDR_LOADED_BUFFERS:
22c937
  		case ADDR_UNLOADED_BUFFERS:
22c937
--- 4523,4530 ----
22c937
  			lnum = 0;
22c937
  			break;
22c937
  		    }
22c937
! 		    if (lnum >= LAST_WIN_NR)
22c937
! 			lnum = LAST_WIN_NR;
22c937
  		    break;
22c937
  		case ADDR_LOADED_BUFFERS:
22c937
  		case ADDR_UNLOADED_BUFFERS:
22c937
*** ../vim-7.4.538/src/version.c	2014-11-30 13:34:16.893626683 +0100
22c937
--- src/version.c	2014-11-30 14:33:29.622510487 +0100
22c937
***************
22c937
*** 743,744 ****
22c937
--- 743,746 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     539,
22c937
  /**/
22c937
22c937
-- 
22c937
SOLDIER: What?  Ridden on a horse?
22c937
ARTHUR:  Yes!
22c937
SOLDIER: You're using coconuts!
22c937
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///