mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.3.284
Problem: The str2special() function doesn't handle multi-byte characters properly. Solution: Recognize multi-byte characters. (partly by Vladimir Vichniakov)
This commit is contained in:
@@ -3964,7 +3964,17 @@ showmap(mp, local)
|
|||||||
if (*mp->m_str == NUL)
|
if (*mp->m_str == NUL)
|
||||||
msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
|
msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8));
|
||||||
else
|
else
|
||||||
msg_outtrans_special(mp->m_str, FALSE);
|
{
|
||||||
|
/* Remove escaping of CSI, because "m_str" is in a format to be used
|
||||||
|
* as typeahead. */
|
||||||
|
char_u *s = vim_strsave(mp->m_str);
|
||||||
|
if (s != NULL)
|
||||||
|
{
|
||||||
|
vim_unescape_csi(s);
|
||||||
|
msg_outtrans_special(s, FALSE);
|
||||||
|
vim_free(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
if (p_verbose > 0)
|
if (p_verbose > 0)
|
||||||
last_set_msg(mp->m_script_ID);
|
last_set_msg(mp->m_script_ID);
|
||||||
|
@@ -1547,16 +1547,27 @@ str2special(sp, from)
|
|||||||
if (IS_SPECIAL(c) || modifiers) /* special key */
|
if (IS_SPECIAL(c) || modifiers) /* special key */
|
||||||
special = TRUE;
|
special = TRUE;
|
||||||
}
|
}
|
||||||
*sp = str + 1;
|
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
/* For multi-byte characters check for an illegal byte. */
|
if (has_mbyte && !IS_SPECIAL(c))
|
||||||
if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str))
|
|
||||||
{
|
{
|
||||||
transchar_nonprint(buf, c);
|
int len = (*mb_ptr2len)(str);
|
||||||
return buf;
|
|
||||||
|
/* For multi-byte characters check for an illegal byte. */
|
||||||
|
if (has_mbyte && MB_BYTE2LEN(*str) > len)
|
||||||
|
{
|
||||||
|
transchar_nonprint(buf, c);
|
||||||
|
*sp = str + 1;
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
/* Since 'special' is TRUE the multi-byte character 'c' will be
|
||||||
|
* processed by get_special_key_name() */
|
||||||
|
c = (*mb_ptr2char)(str);
|
||||||
|
*sp = str + len;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
*sp = str + 1;
|
||||||
|
|
||||||
/* Make unprintable characters in <> form, also <M-Space> and <Tab>.
|
/* Make unprintable characters in <> form, also <M-Space> and <Tab>.
|
||||||
* Use <Space> only for lhs of a mapping. */
|
* Use <Space> only for lhs of a mapping. */
|
||||||
|
43
src/misc2.c
43
src/misc2.c
@@ -2754,6 +2754,7 @@ find_special_key(srcp, modp, keycode, keep_x_key)
|
|||||||
int bit;
|
int bit;
|
||||||
int key;
|
int key;
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
|
int l;
|
||||||
|
|
||||||
src = *srcp;
|
src = *srcp;
|
||||||
if (src[0] != '<')
|
if (src[0] != '<')
|
||||||
@@ -2766,8 +2767,17 @@ find_special_key(srcp, modp, keycode, keep_x_key)
|
|||||||
if (*bp == '-')
|
if (*bp == '-')
|
||||||
{
|
{
|
||||||
last_dash = bp;
|
last_dash = bp;
|
||||||
if (bp[1] != NUL && bp[2] == '>')
|
if (bp[1] != NUL)
|
||||||
++bp; /* anything accepted, like <C-?> */
|
{
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (has_mbyte)
|
||||||
|
l = mb_ptr2len(bp + 1);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
l = 1;
|
||||||
|
if (bp[l + 1] == '>')
|
||||||
|
bp += l; /* anything accepted, like <C-?> */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
|
if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3])
|
||||||
bp += 3; /* skip t_xx, xx may be '-' or '>' */
|
bp += 3; /* skip t_xx, xx may be '-' or '>' */
|
||||||
@@ -2777,15 +2787,6 @@ find_special_key(srcp, modp, keycode, keep_x_key)
|
|||||||
{
|
{
|
||||||
end_of_name = bp + 1;
|
end_of_name = bp + 1;
|
||||||
|
|
||||||
if (STRNICMP(src + 1, "char-", 5) == 0 && VIM_ISDIGIT(src[6]))
|
|
||||||
{
|
|
||||||
/* <Char-123> or <Char-033> or <Char-0x33> */
|
|
||||||
vim_str2nr(src + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
|
|
||||||
*modp = 0;
|
|
||||||
*srcp = end_of_name;
|
|
||||||
return (int)n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Which modifiers are given? */
|
/* Which modifiers are given? */
|
||||||
modifiers = 0x0;
|
modifiers = 0x0;
|
||||||
for (bp = src + 1; bp < last_dash; bp++)
|
for (bp = src + 1; bp < last_dash; bp++)
|
||||||
@@ -2804,11 +2805,27 @@ find_special_key(srcp, modp, keycode, keep_x_key)
|
|||||||
*/
|
*/
|
||||||
if (bp >= last_dash)
|
if (bp >= last_dash)
|
||||||
{
|
{
|
||||||
|
if (STRNICMP(last_dash + 1, "char-", 5) == 0
|
||||||
|
&& VIM_ISDIGIT(last_dash[6]))
|
||||||
|
{
|
||||||
|
/* <Char-123> or <Char-033> or <Char-0x33> */
|
||||||
|
vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n);
|
||||||
|
*modp = modifiers;
|
||||||
|
*srcp = end_of_name;
|
||||||
|
return (int)n;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modifier with single letter, or special key name.
|
* Modifier with single letter, or special key name.
|
||||||
*/
|
*/
|
||||||
if (modifiers != 0 && last_dash[2] == '>')
|
#ifdef FEAT_MBYTE
|
||||||
key = last_dash[1];
|
if (has_mbyte)
|
||||||
|
l = mb_ptr2len(last_dash + 1);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
l = 1;
|
||||||
|
if (modifiers != 0 && last_dash[l + 1] == '>')
|
||||||
|
key = PTR2CHAR(last_dash + 1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = get_special_key_code(last_dash + 1);
|
key = get_special_key_code(last_dash + 1);
|
||||||
|
@@ -709,6 +709,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
284,
|
||||||
/**/
|
/**/
|
||||||
283,
|
283,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user