Karsten Hopp d49469
To: vim_dev@googlegroups.com
Karsten Hopp d49469
Subject: Patch 7.4.572
Karsten Hopp d49469
Fcc: outbox
Karsten Hopp d49469
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp d49469
Mime-Version: 1.0
Karsten Hopp d49469
Content-Type: text/plain; charset=UTF-8
Karsten Hopp d49469
Content-Transfer-Encoding: 8bit
Karsten Hopp d49469
------------
Karsten Hopp d49469
Karsten Hopp d49469
Patch 7.4.572
Karsten Hopp d49469
Problem:    Address type of :wincmd depends on the argument.
Karsten Hopp d49469
Solution:   Check the argument.
Karsten Hopp d49469
Files:	    src/ex_docmd.c, src/window.c, src/proto/window.pro
Karsten Hopp d49469
Karsten Hopp d49469
Karsten Hopp d49469
*** ../vim-7.4.571/src/ex_docmd.c	2015-01-14 11:24:51.851582151 +0100
Karsten Hopp d49469
--- src/ex_docmd.c	2015-01-14 14:48:24.586468863 +0100
Karsten Hopp d49469
***************
Karsten Hopp d49469
*** 2130,2151 ****
Karsten Hopp d49469
   * is equal to the lower.
Karsten Hopp d49469
   */
Karsten Hopp d49469
  
Karsten Hopp d49469
-     if (ea.cmdidx != CMD_SIZE
Karsten Hopp d49469
- #ifdef FEAT_USR_CMDS
Karsten Hopp d49469
- 	&& ea.cmdidx != CMD_USER
Karsten Hopp d49469
- 	&& ea.cmdidx != CMD_USER_BUF
Karsten Hopp d49469
- #endif
Karsten Hopp d49469
-        )
Karsten Hopp d49469
- 	ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
Karsten Hopp d49469
-     else
Karsten Hopp d49469
- #ifdef FEAT_USR_CMDS
Karsten Hopp d49469
- 	if (ea.cmdidx != CMD_USER && ea.cmdidx != CMD_USER_BUF)
Karsten Hopp d49469
- #endif
Karsten Hopp d49469
- 	ea.addr_type = ADDR_LINES;
Karsten Hopp d49469
      /* ea.addr_type for user commands is set by find_ucmd */
Karsten Hopp d49469
!     ea.cmd = cmd;
Karsten Hopp d49469
  
Karsten Hopp d49469
      /* repeat for all ',' or ';' separated addresses */
Karsten Hopp d49469
      for (;;)
Karsten Hopp d49469
      {
Karsten Hopp d49469
  	ea.line1 = ea.line2;
Karsten Hopp d49469
--- 2130,2152 ----
Karsten Hopp d49469
   * is equal to the lower.
Karsten Hopp d49469
   */
Karsten Hopp d49469
  
Karsten Hopp d49469
      /* ea.addr_type for user commands is set by find_ucmd */
Karsten Hopp d49469
!     if (!IS_USER_CMDIDX(ea.cmdidx))
Karsten Hopp d49469
!     {
Karsten Hopp d49469
! 	if (ea.cmdidx != CMD_SIZE)
Karsten Hopp d49469
! 	    ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
Karsten Hopp d49469
! 	else
Karsten Hopp d49469
! 	    ea.addr_type = ADDR_LINES;
Karsten Hopp d49469
! 
Karsten Hopp d49469
! #ifdef FEAT_WINDOWS
Karsten Hopp d49469
! 	/* :wincmd range depends on the argument. */
Karsten Hopp d49469
! 	if (ea.cmdidx == CMD_wincmd)
Karsten Hopp d49469
! 	    get_wincmd_addr_type(p, &ea);
Karsten Hopp d49469
! #endif
Karsten Hopp d49469
!     }
Karsten Hopp d49469
  
Karsten Hopp d49469
      /* repeat for all ',' or ';' separated addresses */
Karsten Hopp d49469
+     ea.cmd = cmd;
Karsten Hopp d49469
      for (;;)
Karsten Hopp d49469
      {
Karsten Hopp d49469
  	ea.line1 = ea.line2;
Karsten Hopp d49469
***************
Karsten Hopp d49469
*** 2181,2187 ****
Karsten Hopp d49469
  	{
Karsten Hopp d49469
  	    if (*ea.cmd == '%')		    /* '%' - all lines */
Karsten Hopp d49469
  	    {
Karsten Hopp d49469
- 		buf_T	*buf;
Karsten Hopp d49469
  		++ea.cmd;
Karsten Hopp d49469
  		switch (ea.addr_type)
Karsten Hopp d49469
  		{
Karsten Hopp d49469
--- 2182,2187 ----
Karsten Hopp d49469
***************
Karsten Hopp d49469
*** 2190,2204 ****
Karsten Hopp d49469
  			ea.line2 = curbuf->b_ml.ml_line_count;
Karsten Hopp d49469
  			break;
Karsten Hopp d49469
  		    case ADDR_LOADED_BUFFERS:
Karsten Hopp d49469
! 			buf = firstbuf;
Karsten Hopp d49469
! 			while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL)
Karsten Hopp d49469
! 			    buf = buf->b_next;
Karsten Hopp d49469
! 			ea.line1 = buf->b_fnum;
Karsten Hopp d49469
! 			buf = lastbuf;
Karsten Hopp d49469
! 			while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
Karsten Hopp d49469
! 			    buf = buf->b_prev;
Karsten Hopp d49469
! 			ea.line2 = buf->b_fnum;
Karsten Hopp d49469
! 			break;
Karsten Hopp d49469
  		    case ADDR_BUFFERS:
Karsten Hopp d49469
  			ea.line1 = firstbuf->b_fnum;
Karsten Hopp d49469
  			ea.line2 = lastbuf->b_fnum;
Karsten Hopp d49469
--- 2190,2209 ----
Karsten Hopp d49469
  			ea.line2 = curbuf->b_ml.ml_line_count;
Karsten Hopp d49469
  			break;
Karsten Hopp d49469
  		    case ADDR_LOADED_BUFFERS:
Karsten Hopp d49469
! 			{
Karsten Hopp d49469
! 			    buf_T	*buf = firstbuf;
Karsten Hopp d49469
! 
Karsten Hopp d49469
! 			    while (buf->b_next != NULL
Karsten Hopp d49469
! 						  && buf->b_ml.ml_mfp == NULL)
Karsten Hopp d49469
! 				buf = buf->b_next;
Karsten Hopp d49469
! 			    ea.line1 = buf->b_fnum;
Karsten Hopp d49469
! 			    buf = lastbuf;
Karsten Hopp d49469
! 			    while (buf->b_prev != NULL
Karsten Hopp d49469
! 						  && buf->b_ml.ml_mfp == NULL)
Karsten Hopp d49469
! 				buf = buf->b_prev;
Karsten Hopp d49469
! 			    ea.line2 = buf->b_fnum;
Karsten Hopp d49469
! 			    break;
Karsten Hopp d49469
! 			}
Karsten Hopp d49469
  		    case ADDR_BUFFERS:
Karsten Hopp d49469
  			ea.line1 = firstbuf->b_fnum;
Karsten Hopp d49469
  			ea.line2 = lastbuf->b_fnum;
Karsten Hopp d49469
*** ../vim-7.4.571/src/window.c	2014-12-13 03:58:03.794672546 +0100
Karsten Hopp d49469
--- src/window.c	2015-01-14 15:17:18.543647480 +0100
Karsten Hopp d49469
***************
Karsten Hopp d49469
*** 624,629 ****
Karsten Hopp d49469
--- 624,733 ----
Karsten Hopp d49469
      }
Karsten Hopp d49469
  }
Karsten Hopp d49469
  
Karsten Hopp d49469
+ /*
Karsten Hopp d49469
+  * Figure out the address type for ":wnncmd".
Karsten Hopp d49469
+  */
Karsten Hopp d49469
+     void
Karsten Hopp d49469
+ get_wincmd_addr_type(arg, eap)
Karsten Hopp d49469
+     char_u	*arg;
Karsten Hopp d49469
+     exarg_T	*eap;
Karsten Hopp d49469
+ {
Karsten Hopp d49469
+     switch (*arg)
Karsten Hopp d49469
+     {
Karsten Hopp d49469
+     case 'S':
Karsten Hopp d49469
+     case Ctrl_S:
Karsten Hopp d49469
+     case 's':
Karsten Hopp d49469
+     case Ctrl_N:
Karsten Hopp d49469
+     case 'n':
Karsten Hopp d49469
+     case 'j':
Karsten Hopp d49469
+     case Ctrl_J:
Karsten Hopp d49469
+     case 'k':
Karsten Hopp d49469
+     case Ctrl_K:
Karsten Hopp d49469
+     case 'T':
Karsten Hopp d49469
+     case Ctrl_R:
Karsten Hopp d49469
+     case 'r':
Karsten Hopp d49469
+     case 'R':
Karsten Hopp d49469
+     case 'K':
Karsten Hopp d49469
+     case 'J':
Karsten Hopp d49469
+     case '+':
Karsten Hopp d49469
+     case '-':
Karsten Hopp d49469
+     case Ctrl__:
Karsten Hopp d49469
+     case '_':
Karsten Hopp d49469
+     case '|':
Karsten Hopp d49469
+     case ']':
Karsten Hopp d49469
+     case Ctrl_RSB:
Karsten Hopp d49469
+     case 'g':
Karsten Hopp d49469
+     case Ctrl_G:
Karsten Hopp d49469
+ #ifdef FEAT_VERTSPLIT
Karsten Hopp d49469
+     case Ctrl_V:
Karsten Hopp d49469
+     case 'v':
Karsten Hopp d49469
+     case 'h':
Karsten Hopp d49469
+     case Ctrl_H:
Karsten Hopp d49469
+     case 'l':
Karsten Hopp d49469
+     case Ctrl_L:
Karsten Hopp d49469
+     case 'H':
Karsten Hopp d49469
+     case 'L':
Karsten Hopp d49469
+     case '>':
Karsten Hopp d49469
+     case '<':
Karsten Hopp d49469
+ #endif
Karsten Hopp d49469
+ #if defined(FEAT_QUICKFIX)
Karsten Hopp d49469
+     case '}':
Karsten Hopp d49469
+ #endif
Karsten Hopp d49469
+ #ifdef FEAT_SEARCHPATH
Karsten Hopp d49469
+     case 'f':
Karsten Hopp d49469
+     case 'F':
Karsten Hopp d49469
+     case Ctrl_F:
Karsten Hopp d49469
+ #endif
Karsten Hopp d49469
+ #ifdef FEAT_FIND_ID
Karsten Hopp d49469
+     case 'i':
Karsten Hopp d49469
+     case Ctrl_I:
Karsten Hopp d49469
+     case 'd':
Karsten Hopp d49469
+     case Ctrl_D:
Karsten Hopp d49469
+ #endif
Karsten Hopp d49469
+ 		/* window size or any count */
Karsten Hopp d49469
+ 		eap->addr_type = ADDR_LINES;
Karsten Hopp d49469
+ 		break;
Karsten Hopp d49469
+ 
Karsten Hopp d49469
+     case Ctrl_HAT:
Karsten Hopp d49469
+     case '^':
Karsten Hopp d49469
+ 		/* buffer number */
Karsten Hopp d49469
+ 		eap->addr_type = ADDR_BUFFERS;
Karsten Hopp d49469
+ 		break;
Karsten Hopp d49469
+ 
Karsten Hopp d49469
+     case Ctrl_Q:
Karsten Hopp d49469
+     case 'q':
Karsten Hopp d49469
+     case Ctrl_C:
Karsten Hopp d49469
+     case 'c':
Karsten Hopp d49469
+     case Ctrl_O:
Karsten Hopp d49469
+     case 'o':
Karsten Hopp d49469
+     case Ctrl_W:
Karsten Hopp d49469
+     case 'w':
Karsten Hopp d49469
+     case 'W':
Karsten Hopp d49469
+     case 'x':
Karsten Hopp d49469
+     case Ctrl_X:
Karsten Hopp d49469
+ 		/* window number */
Karsten Hopp d49469
+ 		eap->addr_type = ADDR_WINDOWS;
Karsten Hopp d49469
+ 		break;
Karsten Hopp d49469
+ 
Karsten Hopp d49469
+ #if defined(FEAT_QUICKFIX)
Karsten Hopp d49469
+     case Ctrl_Z:
Karsten Hopp d49469
+     case 'z':
Karsten Hopp d49469
+     case 'P':
Karsten Hopp d49469
+ #endif
Karsten Hopp d49469
+     case 't':
Karsten Hopp d49469
+     case Ctrl_T:
Karsten Hopp d49469
+     case 'b':
Karsten Hopp d49469
+     case Ctrl_B:
Karsten Hopp d49469
+     case 'p':
Karsten Hopp d49469
+     case Ctrl_P:
Karsten Hopp d49469
+     case '=':
Karsten Hopp d49469
+     case CAR:
Karsten Hopp d49469
+ 		/* no count */
Karsten Hopp d49469
+ 		eap->addr_type = 0;
Karsten Hopp d49469
+ 		break;
Karsten Hopp d49469
+     }
Karsten Hopp d49469
+ }
Karsten Hopp d49469
+ 
Karsten Hopp d49469
      static void
Karsten Hopp d49469
  cmd_with_count(cmd, bufp, bufsize, Prenum)
Karsten Hopp d49469
      char	*cmd;
Karsten Hopp d49469
*** ../vim-7.4.571/src/proto/window.pro	2014-12-17 14:47:52.870412129 +0100
Karsten Hopp d49469
--- src/proto/window.pro	2015-01-14 15:16:37.544092744 +0100
Karsten Hopp d49469
***************
Karsten Hopp d49469
*** 1,5 ****
Karsten Hopp d49469
--- 1,6 ----
Karsten Hopp d49469
  /* window.c */
Karsten Hopp d49469
  void do_window __ARGS((int nchar, long Prenum, int xchar));
Karsten Hopp d49469
+ void get_wincmd_addr_type __ARGS((char_u *arg, exarg_T *eap));
Karsten Hopp d49469
  int win_split __ARGS((int size, int flags));
Karsten Hopp d49469
  int win_split_ins __ARGS((int size, int flags, win_T *new_wp, int dir));
Karsten Hopp d49469
  int win_valid __ARGS((win_T *win));
Karsten Hopp d49469
*** ../vim-7.4.571/src/version.c	2015-01-14 14:08:40.364402377 +0100
Karsten Hopp d49469
--- src/version.c	2015-01-14 15:46:36.136651958 +0100
Karsten Hopp d49469
***************
Karsten Hopp d49469
*** 743,744 ****
Karsten Hopp d49469
--- 743,746 ----
Karsten Hopp d49469
  {   /* Add new patch number below this line */
Karsten Hopp d49469
+ /**/
Karsten Hopp d49469
+     572,
Karsten Hopp d49469
  /**/
Karsten Hopp d49469
Karsten Hopp d49469
-- 
Karsten Hopp d49469
From "know your smileys":
Karsten Hopp d49469
 :^[/   mean-smiley-with-cigarette
Karsten Hopp d49469
Karsten Hopp d49469
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp d49469
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp d49469
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp d49469
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///