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