f91b62b
To: vim_dev@googlegroups.com
f91b62b
Subject: Patch 7.3.283
f91b62b
Fcc: outbox
f91b62b
From: Bram Moolenaar <Bram@moolenaar.net>
f91b62b
Mime-Version: 1.0
f91b62b
Content-Type: text/plain; charset=UTF-8
f91b62b
Content-Transfer-Encoding: 8bit
f91b62b
------------
f91b62b
f91b62b
Patch 7.3.283
f91b62b
Problem:    An expression mapping with a multi-byte character containing a
f91b62b
	    0x80 byte gets messed up. (ZyX)
f91b62b
Solution:   Unescape the expression before evaluating it (Yukihiro Nakadaira)
f91b62b
Files:	    src/getchar.c
f91b62b
f91b62b
f91b62b
*** ../vim-7.3.282/src/getchar.c	2011-04-28 17:30:05.000000000 +0200
f91b62b
--- src/getchar.c	2011-08-17 17:04:38.000000000 +0200
f91b62b
***************
f91b62b
*** 3262,3270 ****
f91b62b
      validate_maphash();
f91b62b
  
f91b62b
      /*
f91b62b
!      * find end of keys and skip CTRL-Vs (and backslashes) in it
f91b62b
       * Accept backslash like CTRL-V when 'cpoptions' does not contain 'B'.
f91b62b
!      * with :unmap white space is included in the keys, no argument possible
f91b62b
       */
f91b62b
      p = keys;
f91b62b
      do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL);
f91b62b
--- 3262,3270 ----
f91b62b
      validate_maphash();
f91b62b
  
f91b62b
      /*
f91b62b
!      * Find end of keys and skip CTRL-Vs (and backslashes) in it.
f91b62b
       * Accept backslash like CTRL-V when 'cpoptions' does not contain 'B'.
f91b62b
!      * with :unmap white space is included in the keys, no argument possible.
f91b62b
       */
f91b62b
      p = keys;
f91b62b
      do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL);
f91b62b
***************
f91b62b
*** 4506,4517 ****
f91b62b
--- 4506,4528 ----
f91b62b
  {
f91b62b
      char_u	*res;
f91b62b
      char_u	*p;
f91b62b
+     char_u	*expr;
f91b62b
      char_u	*save_cmd;
f91b62b
      pos_T	save_cursor;
f91b62b
  
f91b62b
+     /* Remove escaping of CSI, because "str" is in a format to be used as
f91b62b
+      * typeahead. */
f91b62b
+     expr = vim_strsave(str);
f91b62b
+     if (expr == NULL)
f91b62b
+ 	return NULL;
f91b62b
+     vim_unescape_csi(expr);
f91b62b
+ 
f91b62b
      save_cmd = save_cmdline_alloc();
f91b62b
      if (save_cmd == NULL)
f91b62b
+     {
f91b62b
+ 	vim_free(expr);
f91b62b
  	return NULL;
f91b62b
+     }
f91b62b
  
f91b62b
      /* Forbid changing text or using ":normal" to avoid most of the bad side
f91b62b
       * effects.  Also restore the cursor position. */
f91b62b
***************
f91b62b
*** 4521,4527 ****
f91b62b
  #endif
f91b62b
      set_vim_var_char(c);  /* set v:char to the typed character */
f91b62b
      save_cursor = curwin->w_cursor;
f91b62b
!     p = eval_to_string(str, NULL, FALSE);
f91b62b
      --textlock;
f91b62b
  #ifdef FEAT_EX_EXTRA
f91b62b
      --ex_normal_lock;
f91b62b
--- 4532,4538 ----
f91b62b
  #endif
f91b62b
      set_vim_var_char(c);  /* set v:char to the typed character */
f91b62b
      save_cursor = curwin->w_cursor;
f91b62b
!     p = eval_to_string(expr, NULL, FALSE);
f91b62b
      --textlock;
f91b62b
  #ifdef FEAT_EX_EXTRA
f91b62b
      --ex_normal_lock;
f91b62b
***************
f91b62b
*** 4529,4536 ****
f91b62b
--- 4540,4550 ----
f91b62b
      curwin->w_cursor = save_cursor;
f91b62b
  
f91b62b
      restore_cmdline_alloc(save_cmd);
f91b62b
+     vim_free(expr);
f91b62b
+ 
f91b62b
      if (p == NULL)
f91b62b
  	return NULL;
f91b62b
+     /* Escape CSI in the result to be able to use the string as typeahead. */
f91b62b
      res = vim_strsave_escape_csi(p);
f91b62b
      vim_free(p);
f91b62b
  
f91b62b
*** ../vim-7.3.282/src/version.c	2011-08-17 16:25:43.000000000 +0200
f91b62b
--- src/version.c	2011-08-17 17:17:03.000000000 +0200
f91b62b
***************
f91b62b
*** 711,712 ****
f91b62b
--- 711,714 ----
f91b62b
  {   /* Add new patch number below this line */
f91b62b
+ /**/
f91b62b
+     283,
f91b62b
  /**/
f91b62b
f91b62b
-- 
f91b62b
bashian roulette:
f91b62b
$ ((RANDOM%6)) || rm -rf ~
f91b62b
f91b62b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
f91b62b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
f91b62b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
f91b62b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///