summaryrefslogtreecommitdiff
path: root/src/misc2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2011-08-17 20:33:22 +0200
committerBram Moolenaar <Bram@vim.org>2011-08-17 20:33:22 +0200
commitb8bf541f8944a9a0ea0a4b75f8d18a565f5d91d1 (patch)
treeedfac684d6d04e6566e4508fdeb24c70c6b44aef /src/misc2.c
parentf6f4a01ab15d6c962af1210d75a5dc3876e42f39 (diff)
downloadvim-git-b8bf541f8944a9a0ea0a4b75f8d18a565f5d91d1.tar.gz
updated for version 7.3.284v7.3.284
Problem: The str2special() function doesn't handle multi-byte characters properly. Solution: Recognize multi-byte characters. (partly by Vladimir Vichniakov)
Diffstat (limited to 'src/misc2.c')
-rw-r--r--src/misc2.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/misc2.c b/src/misc2.c
index f91a64ace..dbcd653c1 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2754,6 +2754,7 @@ find_special_key(srcp, modp, keycode, keep_x_key)
int bit;
int key;
unsigned long n;
+ int l;
src = *srcp;
if (src[0] != '<')
@@ -2766,8 +2767,17 @@ find_special_key(srcp, modp, keycode, keep_x_key)
if (*bp == '-')
{
last_dash = bp;
- if (bp[1] != NUL && bp[2] == '>')
- ++bp; /* anything accepted, like <C-?> */
+ if (bp[1] != NUL)
+ {
+#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])
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;
- 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? */
modifiers = 0x0;
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 (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.
*/
- if (modifiers != 0 && last_dash[2] == '>')
- key = last_dash[1];
+#ifdef FEAT_MBYTE
+ 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
{
key = get_special_key_code(last_dash + 1);