Karsten Hopp 005f84
To: vim_dev@googlegroups.com
Karsten Hopp 005f84
Subject: Patch 7.3.284
Karsten Hopp 005f84
Fcc: outbox
Karsten Hopp 005f84
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 005f84
Mime-Version: 1.0
Karsten Hopp 005f84
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 005f84
Content-Transfer-Encoding: 8bit
Karsten Hopp 005f84
------------
Karsten Hopp 005f84
Karsten Hopp 005f84
Patch 7.3.284
Karsten Hopp 005f84
Problem:    The str2special() function doesn't handle multi-byte characters
Karsten Hopp 005f84
	    properly.
Karsten Hopp 005f84
Solution:   Recognize multi-byte characters. (partly by Vladimir Vichniakov)
Karsten Hopp 005f84
Files:	    src/getchar.c, src/message.c, src/misc2.c
Karsten Hopp 005f84
Karsten Hopp 005f84
Karsten Hopp 005f84
*** ../vim-7.3.283/src/getchar.c	2011-08-17 17:18:14.000000000 +0200
Karsten Hopp 005f84
--- src/getchar.c	2011-08-17 20:11:58.000000000 +0200
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 3964,3970 ****
Karsten Hopp 005f84
      if (*mp->m_str == NUL)
Karsten Hopp 005f84
  	msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
Karsten Hopp 005f84
      else
Karsten Hopp 005f84
! 	msg_outtrans_special(mp->m_str, FALSE);
Karsten Hopp 005f84
  #ifdef FEAT_EVAL
Karsten Hopp 005f84
      if (p_verbose > 0)
Karsten Hopp 005f84
  	last_set_msg(mp->m_script_ID);
Karsten Hopp 005f84
--- 3964,3980 ----
Karsten Hopp 005f84
      if (*mp->m_str == NUL)
Karsten Hopp 005f84
  	msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
Karsten Hopp 005f84
      else
Karsten Hopp 005f84
!     {
Karsten Hopp 005f84
! 	/* Remove escaping of CSI, because "m_str" is in a format to be used
Karsten Hopp 005f84
! 	 * as typeahead. */
Karsten Hopp 005f84
! 	char_u *s = vim_strsave(mp->m_str);
Karsten Hopp 005f84
! 	if (s != NULL)
Karsten Hopp 005f84
! 	{
Karsten Hopp 005f84
! 	    vim_unescape_csi(s);
Karsten Hopp 005f84
! 	    msg_outtrans_special(s, FALSE);
Karsten Hopp 005f84
! 	    vim_free(s);
Karsten Hopp 005f84
! 	}
Karsten Hopp 005f84
!     }
Karsten Hopp 005f84
  #ifdef FEAT_EVAL
Karsten Hopp 005f84
      if (p_verbose > 0)
Karsten Hopp 005f84
  	last_set_msg(mp->m_script_ID);
Karsten Hopp 005f84
*** ../vim-7.3.283/src/message.c	2011-03-22 13:07:19.000000000 +0100
Karsten Hopp 005f84
--- src/message.c	2011-08-17 18:40:10.000000000 +0200
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 1547,1562 ****
Karsten Hopp 005f84
  	if (IS_SPECIAL(c) || modifiers)	/* special key */
Karsten Hopp 005f84
  	    special = TRUE;
Karsten Hopp 005f84
      }
Karsten Hopp 005f84
-     *sp = str + 1;
Karsten Hopp 005f84
  
Karsten Hopp 005f84
  #ifdef FEAT_MBYTE
Karsten Hopp 005f84
!     /* For multi-byte characters check for an illegal byte. */
Karsten Hopp 005f84
!     if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str))
Karsten Hopp 005f84
      {
Karsten Hopp 005f84
! 	transchar_nonprint(buf, c);
Karsten Hopp 005f84
! 	return buf;
Karsten Hopp 005f84
      }
Karsten Hopp 005f84
  #endif
Karsten Hopp 005f84
  
Karsten Hopp 005f84
      /* Make unprintable characters in <> form, also <M-Space> and <Tab>.
Karsten Hopp 005f84
       * Use <Space> only for lhs of a mapping. */
Karsten Hopp 005f84
--- 1547,1573 ----
Karsten Hopp 005f84
  	if (IS_SPECIAL(c) || modifiers)	/* special key */
Karsten Hopp 005f84
  	    special = TRUE;
Karsten Hopp 005f84
      }
Karsten Hopp 005f84
  
Karsten Hopp 005f84
  #ifdef FEAT_MBYTE
Karsten Hopp 005f84
!     if (has_mbyte && !IS_SPECIAL(c))
Karsten Hopp 005f84
      {
Karsten Hopp 005f84
!         int len = (*mb_ptr2len)(str);
Karsten Hopp 005f84
! 
Karsten Hopp 005f84
! 	/* For multi-byte characters check for an illegal byte. */
Karsten Hopp 005f84
! 	if (has_mbyte && MB_BYTE2LEN(*str) > len)
Karsten Hopp 005f84
! 	{
Karsten Hopp 005f84
! 	    transchar_nonprint(buf, c);
Karsten Hopp 005f84
! 	    *sp = str + 1;
Karsten Hopp 005f84
! 	    return buf;
Karsten Hopp 005f84
! 	}
Karsten Hopp 005f84
!         /* Since 'special' is TRUE the multi-byte character 'c' will be
Karsten Hopp 005f84
!          * processed by get_special_key_name() */
Karsten Hopp 005f84
!         c = (*mb_ptr2char)(str);
Karsten Hopp 005f84
!         *sp = str + len;
Karsten Hopp 005f84
      }
Karsten Hopp 005f84
+     else
Karsten Hopp 005f84
  #endif
Karsten Hopp 005f84
+ 	*sp = str + 1;
Karsten Hopp 005f84
  
Karsten Hopp 005f84
      /* Make unprintable characters in <> form, also <M-Space> and <Tab>.
Karsten Hopp 005f84
       * Use <Space> only for lhs of a mapping. */
Karsten Hopp 005f84
*** ../vim-7.3.283/src/misc2.c	2011-07-27 17:31:42.000000000 +0200
Karsten Hopp 005f84
--- src/misc2.c	2011-08-17 20:27:30.000000000 +0200
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 2754,2759 ****
Karsten Hopp 005f84
--- 2754,2760 ----
Karsten Hopp 005f84
      int		bit;
Karsten Hopp 005f84
      int		key;
Karsten Hopp 005f84
      unsigned long n;
Karsten Hopp 005f84
+     int		l;
Karsten Hopp 005f84
  
Karsten Hopp 005f84
      src = *srcp;
Karsten Hopp 005f84
      if (src[0] != '<')
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 2766,2773 ****
Karsten Hopp 005f84
  	if (*bp == '-')
Karsten Hopp 005f84
  	{
Karsten Hopp 005f84
  	    last_dash = bp;
Karsten Hopp 005f84
! 	    if (bp[1] != NUL && bp[2] == '>')
Karsten Hopp 005f84
! 		++bp;	/* anything accepted, like <C-?> */
Karsten Hopp 005f84
  	}
Karsten Hopp 005f84
  	if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
Karsten Hopp 005f84
  	    bp += 3;	/* skip t_xx, xx may be '-' or '>' */
Karsten Hopp 005f84
--- 2767,2783 ----
Karsten Hopp 005f84
  	if (*bp == '-')
Karsten Hopp 005f84
  	{
Karsten Hopp 005f84
  	    last_dash = bp;
Karsten Hopp 005f84
! 	    if (bp[1] != NUL)
Karsten Hopp 005f84
! 	    {
Karsten Hopp 005f84
! #ifdef FEAT_MBYTE
Karsten Hopp 005f84
! 		if (has_mbyte)
Karsten Hopp 005f84
! 		    l = mb_ptr2len(bp + 1);
Karsten Hopp 005f84
! 		else
Karsten Hopp 005f84
! #endif
Karsten Hopp 005f84
! 		    l = 1;
Karsten Hopp 005f84
! 		if (bp[l + 1] == '>')
Karsten Hopp 005f84
! 		    bp += l;	/* anything accepted, like <C-?> */
Karsten Hopp 005f84
! 	    }
Karsten Hopp 005f84
  	}
Karsten Hopp 005f84
  	if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
Karsten Hopp 005f84
  	    bp += 3;	/* skip t_xx, xx may be '-' or '>' */
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 2777,2791 ****
Karsten Hopp 005f84
      {
Karsten Hopp 005f84
  	end_of_name = bp + 1;
Karsten Hopp 005f84
  
Karsten Hopp 005f84
- 	if (STRNICMP(src + 1, "char-", 5) == 0 && VIM_ISDIGIT(src[6]))
Karsten Hopp 005f84
- 	{
Karsten Hopp 005f84
- 	    /* <Char-123> or <Char-033> or <Char-0x33> */
Karsten Hopp 005f84
- 	    vim_str2nr(src + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
Karsten Hopp 005f84
- 	    *modp = 0;
Karsten Hopp 005f84
- 	    *srcp = end_of_name;
Karsten Hopp 005f84
- 	    return (int)n;
Karsten Hopp 005f84
- 	}
Karsten Hopp 005f84
- 
Karsten Hopp 005f84
  	/* Which modifiers are given? */
Karsten Hopp 005f84
  	modifiers = 0x0;
Karsten Hopp 005f84
  	for (bp = src + 1; bp < last_dash; bp++)
Karsten Hopp 005f84
--- 2787,2792 ----
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 2804,2814 ****
Karsten Hopp 005f84
  	 */
Karsten Hopp 005f84
  	if (bp >= last_dash)
Karsten Hopp 005f84
  	{
Karsten Hopp 005f84
  	    /*
Karsten Hopp 005f84
  	     * Modifier with single letter, or special key name.
Karsten Hopp 005f84
  	     */
Karsten Hopp 005f84
! 	    if (modifiers != 0 && last_dash[2] == '>')
Karsten Hopp 005f84
! 		key = last_dash[1];
Karsten Hopp 005f84
  	    else
Karsten Hopp 005f84
  	    {
Karsten Hopp 005f84
  		key = get_special_key_code(last_dash + 1);
Karsten Hopp 005f84
--- 2805,2831 ----
Karsten Hopp 005f84
  	 */
Karsten Hopp 005f84
  	if (bp >= last_dash)
Karsten Hopp 005f84
  	{
Karsten Hopp 005f84
+ 	    if (STRNICMP(last_dash + 1, "char-", 5) == 0
Karsten Hopp 005f84
+ 						 && VIM_ISDIGIT(last_dash[6]))
Karsten Hopp 005f84
+ 	    {
Karsten Hopp 005f84
+ 		/* <Char-123> or <Char-033> or <Char-0x33> */
Karsten Hopp 005f84
+ 		vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
Karsten Hopp 005f84
+ 		*modp = modifiers;
Karsten Hopp 005f84
+ 		*srcp = end_of_name;
Karsten Hopp 005f84
+ 		return (int)n;
Karsten Hopp 005f84
+ 	    }
Karsten Hopp 005f84
+ 
Karsten Hopp 005f84
  	    /*
Karsten Hopp 005f84
  	     * Modifier with single letter, or special key name.
Karsten Hopp 005f84
  	     */
Karsten Hopp 005f84
! #ifdef FEAT_MBYTE
Karsten Hopp 005f84
! 	    if (has_mbyte)
Karsten Hopp 005f84
! 		l = mb_ptr2len(last_dash + 1);
Karsten Hopp 005f84
! 	    else
Karsten Hopp 005f84
! #endif
Karsten Hopp 005f84
! 		l = 1;
Karsten Hopp 005f84
! 	    if (modifiers != 0 && last_dash[l + 1] == '>')
Karsten Hopp 005f84
! 		key = PTR2CHAR(last_dash + 1);
Karsten Hopp 005f84
  	    else
Karsten Hopp 005f84
  	    {
Karsten Hopp 005f84
  		key = get_special_key_code(last_dash + 1);
Karsten Hopp 005f84
*** ../vim-7.3.283/src/version.c	2011-08-17 17:18:14.000000000 +0200
Karsten Hopp 005f84
--- src/version.c	2011-08-17 20:27:47.000000000 +0200
Karsten Hopp 005f84
***************
Karsten Hopp 005f84
*** 711,712 ****
Karsten Hopp 005f84
--- 711,714 ----
Karsten Hopp 005f84
  {   /* Add new patch number below this line */
Karsten Hopp 005f84
+ /**/
Karsten Hopp 005f84
+     284,
Karsten Hopp 005f84
  /**/
Karsten Hopp 005f84
Karsten Hopp 005f84
-- 
Karsten Hopp 005f84
Snoring is prohibited unless all bedroom windows are closed and securely
Karsten Hopp 005f84
locked.
Karsten Hopp 005f84
		[real standing law in Massachusetts, United States of America]
Karsten Hopp 005f84
Karsten Hopp 005f84
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 005f84
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 005f84
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 005f84
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///