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