]>
Commit | Line | Data |
---|---|---|
da34a1a9 | 1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.284 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.284 | |
11 | Problem: The str2special() function doesn't handle multi-byte characters | |
12 | properly. | |
13 | Solution: Recognize multi-byte characters. (partly by Vladimir Vichniakov) | |
14 | Files: src/getchar.c, src/message.c, src/misc2.c | |
15 | ||
16 | ||
17 | *** ../vim-7.3.283/src/getchar.c 2011-08-17 17:18:14.000000000 +0200 | |
18 | --- src/getchar.c 2011-08-17 20:11:58.000000000 +0200 | |
19 | *************** | |
20 | *** 3964,3970 **** | |
21 | if (*mp->m_str == NUL) | |
22 | msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8)); | |
23 | else | |
24 | ! msg_outtrans_special(mp->m_str, FALSE); | |
25 | #ifdef FEAT_EVAL | |
26 | if (p_verbose > 0) | |
27 | last_set_msg(mp->m_script_ID); | |
28 | --- 3964,3980 ---- | |
29 | if (*mp->m_str == NUL) | |
30 | msg_puts_attr((char_u *)"<Nop>", hl_attr(HLF_8)); | |
31 | else | |
32 | ! { | |
33 | ! /* Remove escaping of CSI, because "m_str" is in a format to be used | |
34 | ! * as typeahead. */ | |
35 | ! char_u *s = vim_strsave(mp->m_str); | |
36 | ! if (s != NULL) | |
37 | ! { | |
38 | ! vim_unescape_csi(s); | |
39 | ! msg_outtrans_special(s, FALSE); | |
40 | ! vim_free(s); | |
41 | ! } | |
42 | ! } | |
43 | #ifdef FEAT_EVAL | |
44 | if (p_verbose > 0) | |
45 | last_set_msg(mp->m_script_ID); | |
46 | *** ../vim-7.3.283/src/message.c 2011-03-22 13:07:19.000000000 +0100 | |
47 | --- src/message.c 2011-08-17 18:40:10.000000000 +0200 | |
48 | *************** | |
49 | *** 1547,1562 **** | |
50 | if (IS_SPECIAL(c) || modifiers) /* special key */ | |
51 | special = TRUE; | |
52 | } | |
53 | - *sp = str + 1; | |
54 | ||
55 | #ifdef FEAT_MBYTE | |
56 | ! /* For multi-byte characters check for an illegal byte. */ | |
57 | ! if (has_mbyte && MB_BYTE2LEN(*str) > (*mb_ptr2len)(str)) | |
58 | { | |
59 | ! transchar_nonprint(buf, c); | |
60 | ! return buf; | |
61 | } | |
62 | #endif | |
63 | ||
64 | /* Make unprintable characters in <> form, also <M-Space> and <Tab>. | |
65 | * Use <Space> only for lhs of a mapping. */ | |
66 | --- 1547,1573 ---- | |
67 | if (IS_SPECIAL(c) || modifiers) /* special key */ | |
68 | special = TRUE; | |
69 | } | |
70 | ||
71 | #ifdef FEAT_MBYTE | |
72 | ! if (has_mbyte && !IS_SPECIAL(c)) | |
73 | { | |
74 | ! int len = (*mb_ptr2len)(str); | |
75 | ! | |
76 | ! /* For multi-byte characters check for an illegal byte. */ | |
77 | ! if (has_mbyte && MB_BYTE2LEN(*str) > len) | |
78 | ! { | |
79 | ! transchar_nonprint(buf, c); | |
80 | ! *sp = str + 1; | |
81 | ! return buf; | |
82 | ! } | |
83 | ! /* Since 'special' is TRUE the multi-byte character 'c' will be | |
84 | ! * processed by get_special_key_name() */ | |
85 | ! c = (*mb_ptr2char)(str); | |
86 | ! *sp = str + len; | |
87 | } | |
88 | + else | |
89 | #endif | |
90 | + *sp = str + 1; | |
91 | ||
92 | /* Make unprintable characters in <> form, also <M-Space> and <Tab>. | |
93 | * Use <Space> only for lhs of a mapping. */ | |
94 | *** ../vim-7.3.283/src/misc2.c 2011-07-27 17:31:42.000000000 +0200 | |
95 | --- src/misc2.c 2011-08-17 20:27:30.000000000 +0200 | |
96 | *************** | |
97 | *** 2754,2759 **** | |
98 | --- 2754,2760 ---- | |
99 | int bit; | |
100 | int key; | |
101 | unsigned long n; | |
102 | + int l; | |
103 | ||
104 | src = *srcp; | |
105 | if (src[0] != '<') | |
106 | *************** | |
107 | *** 2766,2773 **** | |
108 | if (*bp == '-') | |
109 | { | |
110 | last_dash = bp; | |
111 | ! if (bp[1] != NUL && bp[2] == '>') | |
112 | ! ++bp; /* anything accepted, like <C-?> */ | |
113 | } | |
114 | if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) | |
115 | bp += 3; /* skip t_xx, xx may be '-' or '>' */ | |
116 | --- 2767,2783 ---- | |
117 | if (*bp == '-') | |
118 | { | |
119 | last_dash = bp; | |
120 | ! if (bp[1] != NUL) | |
121 | ! { | |
122 | ! #ifdef FEAT_MBYTE | |
123 | ! if (has_mbyte) | |
124 | ! l = mb_ptr2len(bp + 1); | |
125 | ! else | |
126 | ! #endif | |
127 | ! l = 1; | |
128 | ! if (bp[l + 1] == '>') | |
129 | ! bp += l; /* anything accepted, like <C-?> */ | |
130 | ! } | |
131 | } | |
132 | if (bp[0] == 't' && bp[1] == '_' && bp[2] && bp[3]) | |
133 | bp += 3; /* skip t_xx, xx may be '-' or '>' */ | |
134 | *************** | |
135 | *** 2777,2791 **** | |
136 | { | |
137 | end_of_name = bp + 1; | |
138 | ||
139 | - if (STRNICMP(src + 1, "char-", 5) == 0 && VIM_ISDIGIT(src[6])) | |
140 | - { | |
141 | - /* <Char-123> or <Char-033> or <Char-0x33> */ | |
142 | - vim_str2nr(src + 6, NULL, NULL, TRUE, TRUE, NULL, &n); | |
143 | - *modp = 0; | |
144 | - *srcp = end_of_name; | |
145 | - return (int)n; | |
146 | - } | |
147 | - | |
148 | /* Which modifiers are given? */ | |
149 | modifiers = 0x0; | |
150 | for (bp = src + 1; bp < last_dash; bp++) | |
151 | --- 2787,2792 ---- | |
152 | *************** | |
153 | *** 2804,2814 **** | |
154 | */ | |
155 | if (bp >= last_dash) | |
156 | { | |
157 | /* | |
158 | * Modifier with single letter, or special key name. | |
159 | */ | |
160 | ! if (modifiers != 0 && last_dash[2] == '>') | |
161 | ! key = last_dash[1]; | |
162 | else | |
163 | { | |
164 | key = get_special_key_code(last_dash + 1); | |
165 | --- 2805,2831 ---- | |
166 | */ | |
167 | if (bp >= last_dash) | |
168 | { | |
169 | + if (STRNICMP(last_dash + 1, "char-", 5) == 0 | |
170 | + && VIM_ISDIGIT(last_dash[6])) | |
171 | + { | |
172 | + /* <Char-123> or <Char-033> or <Char-0x33> */ | |
173 | + vim_str2nr(last_dash + 6, NULL, NULL, TRUE, TRUE, NULL, &n); | |
174 | + *modp = modifiers; | |
175 | + *srcp = end_of_name; | |
176 | + return (int)n; | |
177 | + } | |
178 | + | |
179 | /* | |
180 | * Modifier with single letter, or special key name. | |
181 | */ | |
182 | ! #ifdef FEAT_MBYTE | |
183 | ! if (has_mbyte) | |
184 | ! l = mb_ptr2len(last_dash + 1); | |
185 | ! else | |
186 | ! #endif | |
187 | ! l = 1; | |
188 | ! if (modifiers != 0 && last_dash[l + 1] == '>') | |
189 | ! key = PTR2CHAR(last_dash + 1); | |
190 | else | |
191 | { | |
192 | key = get_special_key_code(last_dash + 1); | |
193 | *** ../vim-7.3.283/src/version.c 2011-08-17 17:18:14.000000000 +0200 | |
194 | --- src/version.c 2011-08-17 20:27:47.000000000 +0200 | |
195 | *************** | |
196 | *** 711,712 **** | |
197 | --- 711,714 ---- | |
198 | { /* Add new patch number below this line */ | |
199 | + /**/ | |
200 | + 284, | |
201 | /**/ | |
202 | ||
203 | -- | |
204 | Snoring is prohibited unless all bedroom windows are closed and securely | |
205 | locked. | |
206 | [real standing law in Massachusetts, United States of America] | |
207 | ||
208 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
209 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
210 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
211 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |