fb3ab05
To: vim-dev@vim.org
fb3ab05
Subject: Patch 7.2.090
fb3ab05
Fcc: outbox
fb3ab05
From: Bram Moolenaar <Bram@moolenaar.net>
fb3ab05
Mime-Version: 1.0
fb3ab05
Content-Type: text/plain; charset=ISO-8859-1
fb3ab05
Content-Transfer-Encoding: 8bit
fb3ab05
------------
fb3ab05
fb3ab05
Patch 7.2.090
fb3ab05
Problem:    User command containing 0x80 in multi-byte character does not work
fb3ab05
	    properly. (Yasuhiro Matsumoto)
fb3ab05
Solution:   Undo replacement of K_SPECIAL and CSI characters when executing
fb3ab05
	    the command.
fb3ab05
Files:	    src/ex_docmd.c
fb3ab05
fb3ab05
fb3ab05
*** ../vim-7.2.089/src/ex_docmd.c	Tue Dec  9 11:17:23 2008
fb3ab05
--- src/ex_docmd.c	Wed Jan 28 15:34:19 2009
fb3ab05
***************
fb3ab05
*** 5482,5487 ****
fb3ab05
--- 5482,5490 ----
fb3ab05
      return OK;
fb3ab05
  }
fb3ab05
  
fb3ab05
+ /*
fb3ab05
+  * ":command ..."
fb3ab05
+  */
fb3ab05
      static void
fb3ab05
  ex_command(eap)
fb3ab05
      exarg_T   *eap;
fb3ab05
***************
fb3ab05
*** 5914,5919 ****
fb3ab05
--- 5917,5923 ----
fb3ab05
  
fb3ab05
      char_u	*start;
fb3ab05
      char_u	*end;
fb3ab05
+     char_u	*ksp;
fb3ab05
      size_t	len, totlen;
fb3ab05
  
fb3ab05
      size_t	split_len = 0;
fb3ab05
***************
fb3ab05
*** 5930,5945 ****
fb3ab05
  
fb3ab05
      /*
fb3ab05
       * Replace <> in the command by the arguments.
fb3ab05
       */
fb3ab05
      buf = NULL;
fb3ab05
      for (;;)
fb3ab05
      {
fb3ab05
! 	p = cmd->uc_rep;
fb3ab05
! 	q = buf;
fb3ab05
  	totlen = 0;
fb3ab05
! 	while ((start = vim_strchr(p, '<')) != NULL
fb3ab05
! 	       && (end = vim_strchr(start + 1, '>')) != NULL)
fb3ab05
  	{
fb3ab05
  	    /* Include the '>' */
fb3ab05
  	    ++end;
fb3ab05
  
fb3ab05
--- 5934,5984 ----
fb3ab05
  
fb3ab05
      /*
fb3ab05
       * Replace <> in the command by the arguments.
fb3ab05
+      * First round: "buf" is NULL, compute length, allocate "buf".
fb3ab05
+      * Second round: copy result into "buf".
fb3ab05
       */
fb3ab05
      buf = NULL;
fb3ab05
      for (;;)
fb3ab05
      {
fb3ab05
! 	p = cmd->uc_rep;    /* source */
fb3ab05
! 	q = buf;	    /* destinateion */
fb3ab05
  	totlen = 0;
fb3ab05
! 
fb3ab05
! 	for (;;)
fb3ab05
  	{
fb3ab05
+ 	    start = vim_strchr(p, '<');
fb3ab05
+ 	    if (start != NULL)
fb3ab05
+ 		end = vim_strchr(start + 1, '>');
fb3ab05
+ 	    if (buf != NULL)
fb3ab05
+ 	    {
fb3ab05
+ 		ksp = vim_strchr(p, K_SPECIAL);
fb3ab05
+ 		if (ksp != NULL && (start == NULL || ksp < start || end == NULL)
fb3ab05
+ 			&& ((ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)
fb3ab05
+ # ifdef FEAT_GUI
fb3ab05
+ 			    || (ksp[1] == KS_EXTRA && ksp[2] == (int)KE_CSI)
fb3ab05
+ # endif
fb3ab05
+ 			    ))
fb3ab05
+ 		{
fb3ab05
+ 		    /* K_SPECIAL han been put in the buffer as K_SPECIAL
fb3ab05
+ 		     * KS_SPECIAL KE_FILLER, like for mappings, but
fb3ab05
+ 		     * do_cmdline() doesn't handle that, so convert it back.
fb3ab05
+ 		     * Also change K_SPECIAL KS_EXTRA KE_CSI into CSI. */
fb3ab05
+ 		    len = ksp - p;
fb3ab05
+ 		    if (len > 0)
fb3ab05
+ 		    {
fb3ab05
+ 			mch_memmove(q, p, len);
fb3ab05
+ 			q += len;
fb3ab05
+ 		    }
fb3ab05
+ 		    *q++ = ksp[1] == KS_SPECIAL ? K_SPECIAL : CSI;
fb3ab05
+ 		    p = ksp + 3;
fb3ab05
+ 		    continue;
fb3ab05
+ 		}
fb3ab05
+ 	    }
fb3ab05
+ 
fb3ab05
+ 	    /* break if there no <item> is found */
fb3ab05
+ 	    if (start == NULL || end == NULL)
fb3ab05
+ 		break;
fb3ab05
+ 
fb3ab05
  	    /* Include the '>' */
fb3ab05
  	    ++end;
fb3ab05
  
fb3ab05
*** ../vim-7.2.089/src/version.c	Wed Jan 28 14:17:21 2009
fb3ab05
--- src/version.c	Wed Jan 28 15:37:40 2009
fb3ab05
***************
fb3ab05
*** 678,679 ****
fb3ab05
--- 678,681 ----
fb3ab05
  {   /* Add new patch number below this line */
fb3ab05
+ /**/
fb3ab05
+     90,
fb3ab05
  /**/
fb3ab05
fb3ab05
-- 
fb3ab05
How To Keep A Healthy Level Of Insanity:
fb3ab05
17. When the money comes out the ATM, scream "I won!, I won! 3rd
fb3ab05
    time this week!!!!!"
fb3ab05
fb3ab05
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
fb3ab05
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
fb3ab05
\\\        download, build and distribute -- http://www.A-A-P.org        ///
fb3ab05
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///