Mercurial > vim
comparison src/message.c @ 3024:27d43855b723 v7.3.284
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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 17 Aug 2011 20:33:22 +0200 |
parents | 2e72d84e8965 |
children | 61c5e1527bd8 |
comparison
equal
deleted
inserted
replaced
3023:023e84b3592c | 3024:27d43855b723 |
---|---|
1545 c = NUL; | 1545 c = NUL; |
1546 } | 1546 } |
1547 if (IS_SPECIAL(c) || modifiers) /* special key */ | 1547 if (IS_SPECIAL(c) || modifiers) /* special key */ |
1548 special = TRUE; | 1548 special = TRUE; |
1549 } | 1549 } |
1550 *sp = str + 1; | |
1551 | 1550 |
1552 #ifdef FEAT_MBYTE | 1551 #ifdef FEAT_MBYTE |
1553 /* For multi-byte characters check for an illegal byte. */ | 1552 if (has_mbyte && !IS_SPECIAL(c)) |
1554 if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str)) | 1553 { |
1555 { | 1554 int len = (*mb_ptr2len)(str); |
1556 transchar_nonprint(buf, c); | 1555 |
1557 return buf; | 1556 /* For multi-byte characters check for an illegal byte. */ |
1558 } | 1557 if (has_mbyte && MB_BYTE2LEN(*str) > len) |
1559 #endif | 1558 { |
1559 transchar_nonprint(buf, c); | |
1560 *sp = str + 1; | |
1561 return buf; | |
1562 } | |
1563 /* Since 'special' is TRUE the multi-byte character 'c' will be | |
1564 * processed by get_special_key_name() */ | |
1565 c = (*mb_ptr2char)(str); | |
1566 *sp = str + len; | |
1567 } | |
1568 else | |
1569 #endif | |
1570 *sp = str + 1; | |
1560 | 1571 |
1561 /* Make unprintable characters in <> form, also <M-Space> and <Tab>. | 1572 /* Make unprintable characters in <> form, also <M-Space> and <Tab>. |
1562 * Use <Space> only for lhs of a mapping. */ | 1573 * Use <Space> only for lhs of a mapping. */ |
1563 if (special || char2cells(c) > 1 || (from && c == ' ')) | 1574 if (special || char2cells(c) > 1 || (from && c == ' ')) |
1564 return get_special_key_name(c, modifiers); | 1575 return get_special_key_name(c, modifiers); |