Blame SOURCES/7.4.572

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