jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.565

3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.565
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.565
3ef2ca
Problem:    Ranges for arguments, buffers, tabs, etc. are not checked to be
3ef2ca
	    valid but limited to the maximum.  This can cause the wrong thing
3ef2ca
	    to happen.
3ef2ca
Solution:   Give an error for an invalid value. (Marcin Szamotulski)
3ef2ca
	    Use windows range for ":wincmd".
3ef2ca
Files:	    src/ex_docmd.c, src/ex_cmds.h, src/testdir/test62.in,
3ef2ca
	    src/testdir/test_argument_count.in,
3ef2ca
	    src/testdir/test_argument_count.ok,
3ef2ca
	    src/testdir/test_close_count.in,
3ef2ca
	    src/testdir/test_command_count.in,
3ef2ca
	    src/testdir/test_command_count.ok
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.564/src/ex_docmd.c	2015-01-07 13:15:40.605829542 +0100
3ef2ca
--- src/ex_docmd.c	2015-01-07 15:33:21.950217606 +0100
3ef2ca
***************
3ef2ca
*** 2161,2166 ****
3ef2ca
--- 2161,2168 ----
3ef2ca
  		break;
3ef2ca
  	    case ADDR_ARGUMENTS:
3ef2ca
  		ea.line2 = curwin->w_arg_idx + 1;
3ef2ca
+ 		if (ea.line2 > ARGCOUNT)
3ef2ca
+ 		    ea.line2 = ARGCOUNT;
3ef2ca
  		break;
3ef2ca
  	    case ADDR_LOADED_BUFFERS:
3ef2ca
  	    case ADDR_BUFFERS:
3ef2ca
***************
3ef2ca
*** 3110,3116 ****
3ef2ca
       * Exceptions:
3ef2ca
       * - the 'k' command can directly be followed by any character.
3ef2ca
       * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
3ef2ca
!      *	    but :sre[wind] is another command, as are :scrip[tnames],
3ef2ca
       *	    :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
3ef2ca
       * - the "d" command can directly be followed by 'l' or 'p' flag.
3ef2ca
       */
3ef2ca
--- 3112,3118 ----
3ef2ca
       * Exceptions:
3ef2ca
       * - the 'k' command can directly be followed by any character.
3ef2ca
       * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
3ef2ca
!      *	    but :sre[wind] is another command, as are :scr[iptnames],
3ef2ca
       *	    :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
3ef2ca
       * - the "d" command can directly be followed by 'l' or 'p' flag.
3ef2ca
       */
3ef2ca
***************
3ef2ca
*** 4573,4618 ****
3ef2ca
  		lnum -= n;
3ef2ca
  	    else
3ef2ca
  		lnum += n;
3ef2ca
- 
3ef2ca
- 	    switch (addr_type)
3ef2ca
- 	    {
3ef2ca
- 		case ADDR_LINES:
3ef2ca
- 		    break;
3ef2ca
- 		case ADDR_ARGUMENTS:
3ef2ca
- 		    if (lnum < 0)
3ef2ca
- 			lnum = 0;
3ef2ca
- 		    else if (lnum >= ARGCOUNT)
3ef2ca
- 			lnum = ARGCOUNT;
3ef2ca
- 		    break;
3ef2ca
- 		case ADDR_TABS:
3ef2ca
- 		    if (lnum < 0)
3ef2ca
- 		    {
3ef2ca
- 			lnum = 0;
3ef2ca
- 			break;
3ef2ca
- 		    }
3ef2ca
- 		    if (lnum >= LAST_TAB_NR)
3ef2ca
- 			lnum = LAST_TAB_NR;
3ef2ca
- 		    break;
3ef2ca
- 		case ADDR_WINDOWS:
3ef2ca
- 		    if (lnum < 0)
3ef2ca
- 		    {
3ef2ca
- 			lnum = 0;
3ef2ca
- 			break;
3ef2ca
- 		    }
3ef2ca
- 		    if (lnum >= LAST_WIN_NR)
3ef2ca
- 			lnum = LAST_WIN_NR;
3ef2ca
- 		    break;
3ef2ca
- 		case ADDR_LOADED_BUFFERS:
3ef2ca
- 		case ADDR_BUFFERS:
3ef2ca
- 		    if (lnum < firstbuf->b_fnum)
3ef2ca
- 		    {
3ef2ca
- 			lnum = firstbuf->b_fnum;
3ef2ca
- 			break;
3ef2ca
- 		    }
3ef2ca
- 		    if (lnum > lastbuf->b_fnum)
3ef2ca
- 			lnum = lastbuf->b_fnum;
3ef2ca
- 		    break;
3ef2ca
- 	    }
3ef2ca
  	}
3ef2ca
      } while (*cmd == '/' || *cmd == '?');
3ef2ca
  
3ef2ca
--- 4575,4580 ----
3ef2ca
***************
3ef2ca
*** 4675,4691 ****
3ef2ca
  invalid_range(eap)
3ef2ca
      exarg_T	*eap;
3ef2ca
  {
3ef2ca
      if (       eap->line1 < 0
3ef2ca
  	    || eap->line2 < 0
3ef2ca
! 	    || eap->line1 > eap->line2
3ef2ca
! 	    || ((eap->argt & RANGE)
3ef2ca
! 		&& !(eap->argt & NOTADR)
3ef2ca
! 		&& eap->line2 > curbuf->b_ml.ml_line_count
3ef2ca
  #ifdef FEAT_DIFF
3ef2ca
! 			+ (eap->cmdidx == CMD_diffget)
3ef2ca
  #endif
3ef2ca
! 		))
3ef2ca
! 	return (char_u *)_(e_invrange);
3ef2ca
      return NULL;
3ef2ca
  }
3ef2ca
  
3ef2ca
--- 4637,4701 ----
3ef2ca
  invalid_range(eap)
3ef2ca
      exarg_T	*eap;
3ef2ca
  {
3ef2ca
+     buf_T	*buf;
3ef2ca
      if (       eap->line1 < 0
3ef2ca
  	    || eap->line2 < 0
3ef2ca
! 	    || eap->line1 > eap->line2)
3ef2ca
! 	return (char_u *)_(e_invrange);
3ef2ca
! 
3ef2ca
!     if (eap->argt & RANGE)
3ef2ca
!     {
3ef2ca
! 	switch(eap->addr_type)
3ef2ca
! 	{
3ef2ca
! 	    case ADDR_LINES:
3ef2ca
! 		if (!(eap->argt & NOTADR)
3ef2ca
! 			&& eap->line2 > curbuf->b_ml.ml_line_count
3ef2ca
  #ifdef FEAT_DIFF
3ef2ca
! 			    + (eap->cmdidx == CMD_diffget)
3ef2ca
  #endif
3ef2ca
! 		   )
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		break;
3ef2ca
! 	    case ADDR_ARGUMENTS:
3ef2ca
! 		if (eap->line2 > ARGCOUNT + (!ARGCOUNT))    // add 1 if ARCOUNT is 0
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		break;
3ef2ca
! 	    case ADDR_BUFFERS:
3ef2ca
! 		if (eap->line1 < firstbuf->b_fnum
3ef2ca
! 			|| eap->line2 > lastbuf->b_fnum)
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		break;
3ef2ca
! 	    case ADDR_LOADED_BUFFERS:
3ef2ca
! 		buf = firstbuf;
3ef2ca
! 		while (buf->b_ml.ml_mfp == NULL)
3ef2ca
! 		{
3ef2ca
! 		    if (buf->b_next == NULL)
3ef2ca
! 			return (char_u *)_(e_invrange);
3ef2ca
! 		    buf = buf->b_next;
3ef2ca
! 		}
3ef2ca
! 		if (eap->line1 < buf->b_fnum)
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		buf = lastbuf;
3ef2ca
! 		while (buf->b_ml.ml_mfp == NULL)
3ef2ca
! 		{
3ef2ca
! 		    if (buf->b_prev == NULL)
3ef2ca
! 			return (char_u *)_(e_invrange);
3ef2ca
! 		    buf = buf->b_prev;
3ef2ca
! 		}
3ef2ca
! 		if (eap->line2 > buf->b_fnum)
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		break;
3ef2ca
! 	    case ADDR_WINDOWS:
3ef2ca
! 		if (eap->line1 < 1
3ef2ca
! 			|| eap->line2 > LAST_WIN_NR)
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		break;
3ef2ca
! 	    case ADDR_TABS:
3ef2ca
! 		if (eap->line2 > LAST_TAB_NR)
3ef2ca
! 		    return (char_u *)_(e_invrange);
3ef2ca
! 		break;
3ef2ca
! 	}
3ef2ca
!     }
3ef2ca
      return NULL;
3ef2ca
  }
3ef2ca
  
3ef2ca
*** ../vim-7.4.564/src/ex_cmds.h	2014-12-17 14:36:10.363090985 +0100
3ef2ca
--- src/ex_cmds.h	2015-01-07 15:47:15.336518550 +0100
3ef2ca
***************
3ef2ca
*** 1574,1580 ****
3ef2ca
  			ADDR_LINES),
3ef2ca
  EX(CMD_wincmd,		"wincmd",	ex_wincmd,
3ef2ca
  			NEEDARG|WORD1|RANGE|NOTADR,
3ef2ca
! 			ADDR_LINES),
3ef2ca
  EX(CMD_windo,		"windo",	ex_listdo,
3ef2ca
  			BANG|NEEDARG|EXTRA|NOTRLCOM,
3ef2ca
  			ADDR_LINES),
3ef2ca
--- 1574,1580 ----
3ef2ca
  			ADDR_LINES),
3ef2ca
  EX(CMD_wincmd,		"wincmd",	ex_wincmd,
3ef2ca
  			NEEDARG|WORD1|RANGE|NOTADR,
3ef2ca
! 			ADDR_WINDOWS),
3ef2ca
  EX(CMD_windo,		"windo",	ex_listdo,
3ef2ca
  			BANG|NEEDARG|EXTRA|NOTRLCOM,
3ef2ca
  			ADDR_LINES),
3ef2ca
*** ../vim-7.4.564/src/testdir/test62.in	2014-04-29 11:55:26.172053624 +0200
3ef2ca
--- src/testdir/test62.in	2015-01-07 15:33:21.950217606 +0100
3ef2ca
***************
3ef2ca
*** 13,19 ****
3ef2ca
  :" Open three tab pages and use ":tabdo"
3ef2ca
  :0tabnew
3ef2ca
  :1tabnew
3ef2ca
! :888tabnew
3ef2ca
  :tabdo call append(line('$'), 'this is tab page ' . tabpagenr())
3ef2ca
  :tabclose! 2
3ef2ca
  :tabrewind
3ef2ca
--- 13,19 ----
3ef2ca
  :" Open three tab pages and use ":tabdo"
3ef2ca
  :0tabnew
3ef2ca
  :1tabnew
3ef2ca
! :$tabnew
3ef2ca
  :tabdo call append(line('$'), 'this is tab page ' . tabpagenr())
3ef2ca
  :tabclose! 2
3ef2ca
  :tabrewind
3ef2ca
*** ../vim-7.4.564/src/testdir/test_argument_count.in	2014-11-27 18:32:58.532564506 +0100
3ef2ca
--- src/testdir/test_argument_count.in	2015-01-07 15:33:21.950217606 +0100
3ef2ca
***************
3ef2ca
*** 27,36 ****
3ef2ca
  :1arga c
3ef2ca
  :1arga b
3ef2ca
  :$argu
3ef2ca
- :+arga d
3ef2ca
  :$arga x
3ef2ca
  :call add(arglists, argv())
3ef2ca
! :$-10arga Y
3ef2ca
  :call add(arglists, argv())
3ef2ca
  :%argd
3ef2ca
  :call add(arglists, argv())
3ef2ca
--- 27,35 ----
3ef2ca
  :1arga c
3ef2ca
  :1arga b
3ef2ca
  :$argu
3ef2ca
  :$arga x
3ef2ca
  :call add(arglists, argv())
3ef2ca
! :0arga Y
3ef2ca
  :call add(arglists, argv())
3ef2ca
  :%argd
3ef2ca
  :call add(arglists, argv())
3ef2ca
*** ../vim-7.4.564/src/testdir/test_argument_count.ok	2014-11-27 16:22:42.746412995 +0100
3ef2ca
--- src/testdir/test_argument_count.ok	2015-01-07 15:33:21.950217606 +0100
3ef2ca
***************
3ef2ca
*** 7,13 ****
3ef2ca
  a b d
3ef2ca
  a d
3ef2ca
  a
3ef2ca
! a b c d x
3ef2ca
! Y a b c d x
3ef2ca
  
3ef2ca
  a f
3ef2ca
--- 7,13 ----
3ef2ca
  a b d
3ef2ca
  a d
3ef2ca
  a
3ef2ca
! a b c x
3ef2ca
! Y a b c x
3ef2ca
  
3ef2ca
  a f
3ef2ca
*** ../vim-7.4.564/src/testdir/test_close_count.in	2014-12-17 14:42:42.990240206 +0100
3ef2ca
--- src/testdir/test_close_count.in	2015-01-07 15:33:21.950217606 +0100
3ef2ca
***************
3ef2ca
*** 28,34 ****
3ef2ca
  :new
3ef2ca
  :new
3ef2ca
  :2wincmd w
3ef2ca
! :-2close!
3ef2ca
  :let buffers = []
3ef2ca
  :windo call add(buffers, bufnr('%'))
3ef2ca
  :call add(tests, buffers)
3ef2ca
--- 28,34 ----
3ef2ca
  :new
3ef2ca
  :new
3ef2ca
  :2wincmd w
3ef2ca
! :-1close!
3ef2ca
  :let buffers = []
3ef2ca
  :windo call add(buffers, bufnr('%'))
3ef2ca
  :call add(tests, buffers)
3ef2ca
***************
3ef2ca
*** 61,67 ****
3ef2ca
  :let buffers = []
3ef2ca
  :windo call add(buffers, bufnr('%'))
3ef2ca
  :call add(tests, buffers)
3ef2ca
! :9hide
3ef2ca
  :let buffers = []
3ef2ca
  :windo call add(buffers, bufnr('%'))
3ef2ca
  :call add(tests, buffers)
3ef2ca
--- 61,67 ----
3ef2ca
  :let buffers = []
3ef2ca
  :windo call add(buffers, bufnr('%'))
3ef2ca
  :call add(tests, buffers)
3ef2ca
! :$hide
3ef2ca
  :let buffers = []
3ef2ca
  :windo call add(buffers, bufnr('%'))
3ef2ca
  :call add(tests, buffers)
3ef2ca
*** ../vim-7.4.564/src/testdir/test_command_count.in	2015-01-07 13:15:40.609829496 +0100
3ef2ca
--- src/testdir/test_command_count.in	2015-01-07 15:49:24.343016552 +0100
3ef2ca
***************
3ef2ca
*** 1,8 ****
3ef2ca
  Test for user command counts	    vim: set ft=vim :
3ef2ca
  
3ef2ca
  STARTTEST
3ef2ca
- :let g:lines = []
3ef2ca
  :so tiny.vim
3ef2ca
  :com -range=% RangeLines :call add(g:lines, 'RangeLines '.<line1>.' '.<line2>)
3ef2ca
  :com -range -addr=arguments RangeArguments :call add(g:lines, 'RangeArguments '.<line1>.' '.<line2>)
3ef2ca
  :com -range=% -addr=arguments RangeArgumentsAll :call add(g:lines, 'RangeArgumentsAll '.<line1>.' '.<line2>)
3ef2ca
--- 1,8 ----
3ef2ca
  Test for user command counts	    vim: set ft=vim :
3ef2ca
  
3ef2ca
  STARTTEST
3ef2ca
  :so tiny.vim
3ef2ca
+ :let g:lines = []
3ef2ca
  :com -range=% RangeLines :call add(g:lines, 'RangeLines '.<line1>.' '.<line2>)
3ef2ca
  :com -range -addr=arguments RangeArguments :call add(g:lines, 'RangeArguments '.<line1>.' '.<line2>)
3ef2ca
  :com -range=% -addr=arguments RangeArgumentsAll :call add(g:lines, 'RangeArgumentsAll '.<line1>.' '.<line2>)
3ef2ca
***************
3ef2ca
*** 48,53 ****
3ef2ca
--- 48,93 ----
3ef2ca
  :'<,'>RangeLines
3ef2ca
  :com -range=% -buffer LocalRangeLines :call add(g:lines, 'LocalRangeLines '.<line1>.' '.<line2>)
3ef2ca
  :'<,'>LocalRangeLines
3ef2ca
+ :b1
3ef2ca
+ ENDTEST
3ef2ca
+ 
3ef2ca
+ STARTTEST
3ef2ca
+ :call add(g:lines, '')
3ef2ca
+ :%argd
3ef2ca
+ :arga a b c d
3ef2ca
+ :let v:errmsg = ''
3ef2ca
+ :5argu
3ef2ca
+ :call add(g:lines, '5argu ' . v:errmsg)
3ef2ca
+ :$argu
3ef2ca
+ :call add(g:lines, '4argu ' . expand('%:t'))
3ef2ca
+ :let v:errmsg = ''
3ef2ca
+ :1argu
3ef2ca
+ :call add(g:lines, '1argu ' . expand('%:t'))
3ef2ca
+ :let v:errmsg = ''
3ef2ca
+ :100b
3ef2ca
+ :call add(g:lines, '100b ' . v:errmsg)
3ef2ca
+ :split|split|split|split
3ef2ca
+ :let v:errmsg = ''
3ef2ca
+ :0close
3ef2ca
+ :call add(g:lines, '0close ' . v:errmsg)
3ef2ca
+ :$wincmd w
3ef2ca
+ :$close
3ef2ca
+ :call add(g:lines, '$close ' . winnr())
3ef2ca
+ :let v:errmsg = ''
3ef2ca
+ :$+close
3ef2ca
+ :call add(g:lines, '$+close ' . v:errmsg)
3ef2ca
+ :$tabe
3ef2ca
+ :call add(g:lines, '$tabe ' . tabpagenr())
3ef2ca
+ :let v:errmsg = ''
3ef2ca
+ :$+tabe
3ef2ca
+ :call add(g:lines, '$+tabe ' . v:errmsg)
3ef2ca
+ :only!
3ef2ca
+ :e x
3ef2ca
+ :0tabm
3ef2ca
+ :normal 1gt
3ef2ca
+ :call add(g:lines, '0tabm ' . expand('%:t'))
3ef2ca
+ :tabonly!
3ef2ca
+ :only!
3ef2ca
  :e! test.out
3ef2ca
  :call append(0, g:lines)
3ef2ca
  :w|qa!
3ef2ca
*** ../vim-7.4.564/src/testdir/test_command_count.ok	2015-01-07 13:15:40.609829496 +0100
3ef2ca
--- src/testdir/test_command_count.ok	2015-01-07 15:49:19.223076159 +0100
3ef2ca
***************
3ef2ca
*** 17,19 ****
3ef2ca
--- 17,30 ----
3ef2ca
  RangeLines 2 5
3ef2ca
  LocalRangeLines 2 5
3ef2ca
  
3ef2ca
+ 5argu E16: Invalid range
3ef2ca
+ 4argu d
3ef2ca
+ 1argu a
3ef2ca
+ 100b E16: Invalid range
3ef2ca
+ 0close E16: Invalid range
3ef2ca
+ $close 4
3ef2ca
+ $+close E16: Invalid range
3ef2ca
+ $tabe 2
3ef2ca
+ $+tabe E16: Invalid range
3ef2ca
+ 0tabm x
3ef2ca
+ 
3ef2ca
*** ../vim-7.4.564/src/version.c	2015-01-07 14:43:35.728900384 +0100
3ef2ca
--- src/version.c	2015-01-07 15:32:05.899101868 +0100
3ef2ca
***************
3ef2ca
*** 743,744 ****
3ef2ca
--- 743,746 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     565,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
"I simultaneously try to keep my head in the clouds and my feet on the
3ef2ca
ground.  Sometimes it's a stretch, though."              -- Larry Wall
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///