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