Blame SOURCES/7.4.486

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.486
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.486
22c937
Problem:    Check for writing to a yank register is wrong.
22c937
Solution:   Negate the check. (Zyx).  Also clean up the #ifdefs.
22c937
Files:	    src/ex_docmd.c, src/ex_cmds.h
22c937
22c937
22c937
*** ../vim-7.4.485/src/ex_docmd.c	2014-09-19 20:07:22.546449677 +0200
22c937
--- src/ex_docmd.c	2014-10-21 19:56:31.290287055 +0200
22c937
***************
22c937
*** 49,58 ****
22c937
--- 49,63 ----
22c937
  static char_u *get_user_command_name __ARGS((int idx));
22c937
  # endif
22c937
  
22c937
+ /* Wether a command index indicates a user command. */
22c937
+ # define IS_USER_CMDIDX(idx) ((int)(idx) < 0)
22c937
+ 
22c937
  #else
22c937
  # define ex_command	ex_ni
22c937
  # define ex_comclear	ex_ni
22c937
  # define ex_delcommand	ex_ni
22c937
+ /* Wether a command index indicates a user command. */
22c937
+ # define IS_USER_CMDIDX(idx) (FALSE)
22c937
  #endif
22c937
  
22c937
  #ifdef FEAT_EVAL
22c937
***************
22c937
*** 2190,2200 ****
22c937
  	goto doend;
22c937
      }
22c937
  
22c937
!     ni = (
22c937
! #ifdef FEAT_USR_CMDS
22c937
! 	    !USER_CMDIDX(ea.cmdidx) &&
22c937
! #endif
22c937
! 	    (cmdnames[ea.cmdidx].cmd_func == ex_ni
22c937
  #ifdef HAVE_EX_SCRIPT_NI
22c937
  	     || cmdnames[ea.cmdidx].cmd_func == ex_script_ni
22c937
  #endif
22c937
--- 2195,2202 ----
22c937
  	goto doend;
22c937
      }
22c937
  
22c937
!     ni = (!IS_USER_CMDIDX(ea.cmdidx)
22c937
! 	    && (cmdnames[ea.cmdidx].cmd_func == ex_ni
22c937
  #ifdef HAVE_EX_SCRIPT_NI
22c937
  	     || cmdnames[ea.cmdidx].cmd_func == ex_script_ni
22c937
  #endif
22c937
***************
22c937
*** 2229,2237 ****
22c937
  /*
22c937
   * 5. parse arguments
22c937
   */
22c937
! #ifdef FEAT_USR_CMDS
22c937
!     if (!USER_CMDIDX(ea.cmdidx))
22c937
! #endif
22c937
  	ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
22c937
  
22c937
      if (!ea.skip)
22c937
--- 2231,2237 ----
22c937
  /*
22c937
   * 5. parse arguments
22c937
   */
22c937
!     if (!IS_USER_CMDIDX(ea.cmdidx))
22c937
  	ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
22c937
  
22c937
      if (!ea.skip)
22c937
***************
22c937
*** 2252,2261 ****
22c937
  	}
22c937
  
22c937
  	if (text_locked() && !(ea.argt & CMDWIN)
22c937
! # ifdef FEAT_USR_CMDS
22c937
! 		&& !USER_CMDIDX(ea.cmdidx)
22c937
! # endif
22c937
! 	   )
22c937
  	{
22c937
  	    /* Command not allowed when editing the command line. */
22c937
  #ifdef FEAT_CMDWIN
22c937
--- 2252,2258 ----
22c937
  	}
22c937
  
22c937
  	if (text_locked() && !(ea.argt & CMDWIN)
22c937
! 		&& !IS_USER_CMDIDX(ea.cmdidx))
22c937
  	{
22c937
  	    /* Command not allowed when editing the command line. */
22c937
  #ifdef FEAT_CMDWIN
22c937
***************
22c937
*** 2273,2281 ****
22c937
  	if (!(ea.argt & CMDWIN)
22c937
  		&& ea.cmdidx != CMD_edit
22c937
  		&& ea.cmdidx != CMD_checktime
22c937
! # ifdef FEAT_USR_CMDS
22c937
! 		&& !USER_CMDIDX(ea.cmdidx)
22c937
! # endif
22c937
  		&& curbuf_locked())
22c937
  	    goto doend;
22c937
  #endif
22c937
--- 2270,2276 ----
22c937
  	if (!(ea.argt & CMDWIN)
22c937
  		&& ea.cmdidx != CMD_edit
22c937
  		&& ea.cmdidx != CMD_checktime
22c937
! 		&& !IS_USER_CMDIDX(ea.cmdidx)
22c937
  		&& curbuf_locked())
22c937
  	    goto doend;
22c937
  #endif
22c937
***************
22c937
*** 2468,2477 ****
22c937
      /* accept numbered register only when no count allowed (:put) */
22c937
      if (       (ea.argt & REGSTR)
22c937
  	    && *ea.arg != NUL
22c937
! #ifdef FEAT_USR_CMDS
22c937
! 	    /* Do not allow register = for user commands */
22c937
! 	    && (!USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')
22c937
! #endif
22c937
  	    && !((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg)))
22c937
      {
22c937
  #ifndef FEAT_CLIPBOARD
22c937
--- 2463,2470 ----
22c937
      /* accept numbered register only when no count allowed (:put) */
22c937
      if (       (ea.argt & REGSTR)
22c937
  	    && *ea.arg != NUL
22c937
! 	       /* Do not allow register = for user commands */
22c937
! 	    && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')
22c937
  	    && !((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg)))
22c937
      {
22c937
  #ifndef FEAT_CLIPBOARD
22c937
***************
22c937
*** 2482,2495 ****
22c937
  	    goto doend;
22c937
  	}
22c937
  #endif
22c937
! 	if (
22c937
! #ifdef FEAT_USR_CMDS
22c937
! 	    valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put
22c937
! 						   && USER_CMDIDX(ea.cmdidx)))
22c937
! #else
22c937
! 	    valid_yank_reg(*ea.arg, ea.cmdidx != CMD_put)
22c937
! #endif
22c937
! 	   )
22c937
  	{
22c937
  	    ea.regname = *ea.arg++;
22c937
  #ifdef FEAT_EVAL
22c937
--- 2475,2482 ----
22c937
  	    goto doend;
22c937
  	}
22c937
  #endif
22c937
! 	if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put
22c937
! 					      && !IS_USER_CMDIDX(ea.cmdidx))))
22c937
  	{
22c937
  	    ea.regname = *ea.arg++;
22c937
  #ifdef FEAT_EVAL
22c937
***************
22c937
*** 2663,2672 ****
22c937
       * number.  Don't do this for a user command.
22c937
       */
22c937
      if ((ea.argt & BUFNAME) && *ea.arg != NUL && ea.addr_count == 0
22c937
! # ifdef FEAT_USR_CMDS
22c937
! 	    && !USER_CMDIDX(ea.cmdidx)
22c937
! # endif
22c937
! 	    )
22c937
      {
22c937
  	/*
22c937
  	 * :bdelete, :bwipeout and :bunload take several arguments, separated
22c937
--- 2650,2656 ----
22c937
       * number.  Don't do this for a user command.
22c937
       */
22c937
      if ((ea.argt & BUFNAME) && *ea.arg != NUL && ea.addr_count == 0
22c937
! 	    && !IS_USER_CMDIDX(ea.cmdidx))
22c937
      {
22c937
  	/*
22c937
  	 * :bdelete, :bwipeout and :bunload take several arguments, separated
22c937
***************
22c937
*** 2704,2710 ****
22c937
  #endif
22c937
  
22c937
  #ifdef FEAT_USR_CMDS
22c937
!     if (USER_CMDIDX(ea.cmdidx))
22c937
      {
22c937
  	/*
22c937
  	 * Execute a user-defined command.
22c937
--- 2688,2694 ----
22c937
  #endif
22c937
  
22c937
  #ifdef FEAT_USR_CMDS
22c937
!     if (IS_USER_CMDIDX(ea.cmdidx))
22c937
      {
22c937
  	/*
22c937
  	 * Execute a user-defined command.
22c937
***************
22c937
*** 2763,2773 ****
22c937
      }
22c937
  #ifdef FEAT_EVAL
22c937
      do_errthrow(cstack,
22c937
! 	    (ea.cmdidx != CMD_SIZE
22c937
! # ifdef FEAT_USR_CMDS
22c937
! 	     && !USER_CMDIDX(ea.cmdidx)
22c937
! # endif
22c937
! 	    ) ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);
22c937
  #endif
22c937
  
22c937
      if (verbose_save >= 0)
22c937
--- 2747,2754 ----
22c937
      }
22c937
  #ifdef FEAT_EVAL
22c937
      do_errthrow(cstack,
22c937
! 	    (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx))
22c937
! 			? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);
22c937
  #endif
22c937
  
22c937
      if (verbose_save >= 0)
22c937
***************
22c937
*** 3361,3369 ****
22c937
  /*
22c937
   * 5. parse arguments
22c937
   */
22c937
! #ifdef FEAT_USR_CMDS
22c937
!     if (!USER_CMDIDX(ea.cmdidx))
22c937
! #endif
22c937
  	ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
22c937
  
22c937
      arg = skipwhite(p);
22c937
--- 3342,3348 ----
22c937
  /*
22c937
   * 5. parse arguments
22c937
   */
22c937
!     if (!IS_USER_CMDIDX(ea.cmdidx))
22c937
  	ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
22c937
  
22c937
      arg = skipwhite(p);
22c937
*** ../vim-7.4.485/src/ex_cmds.h	2014-09-19 20:07:22.546449677 +0200
22c937
--- src/ex_cmds.h	2014-10-21 19:52:45.926286562 +0200
22c937
***************
22c937
*** 1153,1160 ****
22c937
  #endif
22c937
  };
22c937
  
22c937
- #define USER_CMDIDX(idx) ((int)(idx) < 0)
22c937
- 
22c937
  #ifndef DO_DECLARE_EXCMD
22c937
  typedef enum CMD_index cmdidx_T;
22c937
  
22c937
--- 1153,1158 ----
22c937
*** ../vim-7.4.485/src/version.c	2014-10-21 19:35:28.406284296 +0200
22c937
--- src/version.c	2014-10-21 20:00:44.350287607 +0200
22c937
***************
22c937
*** 743,744 ****
22c937
--- 743,746 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     486,
22c937
  /**/
22c937
22c937
-- 
22c937
FATHER: One day, lad, all this will be yours ...
22c937
PRINCE: What - the curtains?
22c937
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
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    ///