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