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