@@ -0,0 +1,280 @@
|
|
1
|
+
To: vim_dev@googlegroups.com
|
2
|
+
Subject: Patch 7.3.431
|
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.431
|
11
|
+
Problem: Fetching a key at a prompt may be confused by escape sequences.
|
12
|
+
Especially when getting a prompt at a VimEnter autocommand.
|
13
|
+
(Alex Efros)
|
14
|
+
Solution: Properly handle escape sequences deleted by check_termcode().
|
15
|
+
Files: src/getchar.c, src/misc1.c, src/term.c, src/proto/term.pro
|
16
|
+
|
17
|
+
|
18
|
+
*** ../vim-7.3.430/src/getchar.c 2012-02-05 01:18:41.000000000 +0100
|
19
|
+
--- src/getchar.c 2012-02-05 22:04:33.000000000 +0100
|
20
|
+
***************
|
21
|
+
*** 2282,2288 ****
|
22
|
+
typebuf.tb_off] == RM_YES))
|
23
|
+
&& !timedout)
|
24
|
+
{
|
25
|
+
! keylen = check_termcode(max_mlen + 1, NULL, 0);
|
26
|
+
|
27
|
+
/* If no termcode matched but 'pastetoggle'
|
28
|
+
* matched partially it's like an incomplete key
|
29
|
+
--- 2282,2289 ----
|
30
|
+
typebuf.tb_off] == RM_YES))
|
31
|
+
&& !timedout)
|
32
|
+
{
|
33
|
+
! keylen = check_termcode(max_mlen + 1,
|
34
|
+
! NULL, 0, NULL);
|
35
|
+
|
36
|
+
/* If no termcode matched but 'pastetoggle'
|
37
|
+
* matched partially it's like an incomplete key
|
38
|
+
*** ../vim-7.3.430/src/misc1.c 2012-01-10 18:37:53.000000000 +0100
|
39
|
+
--- src/misc1.c 2012-02-05 21:59:53.000000000 +0100
|
40
|
+
***************
|
41
|
+
*** 3105,3112 ****
|
42
|
+
int
|
43
|
+
get_keystroke()
|
44
|
+
{
|
45
|
+
! #define CBUFLEN 151
|
46
|
+
! char_u buf[CBUFLEN];
|
47
|
+
int len = 0;
|
48
|
+
int n;
|
49
|
+
int save_mapped_ctrl_c = mapped_ctrl_c;
|
50
|
+
--- 3105,3113 ----
|
51
|
+
int
|
52
|
+
get_keystroke()
|
53
|
+
{
|
54
|
+
! char_u *buf = NULL;
|
55
|
+
! int buflen = 150;
|
56
|
+
! int maxlen;
|
57
|
+
int len = 0;
|
58
|
+
int n;
|
59
|
+
int save_mapped_ctrl_c = mapped_ctrl_c;
|
60
|
+
***************
|
61
|
+
*** 3118,3129 ****
|
62
|
+
cursor_on();
|
63
|
+
out_flush();
|
64
|
+
|
65
|
+
/* First time: blocking wait. Second time: wait up to 100ms for a
|
66
|
+
! * terminal code to complete. Leave some room for check_termcode() to
|
67
|
+
! * insert a key code into (max 5 chars plus NUL). And
|
68
|
+
! * fix_input_buffer() can triple the number of bytes. */
|
69
|
+
! n = ui_inchar(buf + len, (CBUFLEN - 6 - len) / 3,
|
70
|
+
! len == 0 ? -1L : 100L, 0);
|
71
|
+
if (n > 0)
|
72
|
+
{
|
73
|
+
/* Replace zero and CSI by a special key code. */
|
74
|
+
--- 3119,3147 ----
|
75
|
+
cursor_on();
|
76
|
+
out_flush();
|
77
|
+
|
78
|
+
+ /* Leave some room for check_termcode() to insert a key code into (max
|
79
|
+
+ * 5 chars plus NUL). And fix_input_buffer() can triple the number of
|
80
|
+
+ * bytes. */
|
81
|
+
+ maxlen = (buflen - 6 - len) / 3;
|
82
|
+
+ if (buf == NULL)
|
83
|
+
+ buf = alloc(buflen);
|
84
|
+
+ else if (maxlen < 10)
|
85
|
+
+ {
|
86
|
+
+ /* Need some more space. This migth happen when receiving a long
|
87
|
+
+ * escape sequence. */
|
88
|
+
+ buflen += 100;
|
89
|
+
+ buf = vim_realloc(buf, buflen);
|
90
|
+
+ maxlen = (buflen - 6 - len) / 3;
|
91
|
+
+ }
|
92
|
+
+ if (buf == NULL)
|
93
|
+
+ {
|
94
|
+
+ do_outofmem_msg((long_u)buflen);
|
95
|
+
+ return ESC; /* panic! */
|
96
|
+
+ }
|
97
|
+
+
|
98
|
+
/* First time: blocking wait. Second time: wait up to 100ms for a
|
99
|
+
! * terminal code to complete. */
|
100
|
+
! n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
|
101
|
+
if (n > 0)
|
102
|
+
{
|
103
|
+
/* Replace zero and CSI by a special key code. */
|
104
|
+
***************
|
105
|
+
*** 3135,3141 ****
|
106
|
+
++waited; /* keep track of the waiting time */
|
107
|
+
|
108
|
+
/* Incomplete termcode and not timed out yet: get more characters */
|
109
|
+
! if ((n = check_termcode(1, buf, len)) < 0
|
110
|
+
&& (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
|
111
|
+
continue;
|
112
|
+
|
113
|
+
--- 3153,3159 ----
|
114
|
+
++waited; /* keep track of the waiting time */
|
115
|
+
|
116
|
+
/* Incomplete termcode and not timed out yet: get more characters */
|
117
|
+
! if ((n = check_termcode(1, buf, buflen, &len)) < 0
|
118
|
+
&& (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
|
119
|
+
continue;
|
120
|
+
|
121
|
+
***************
|
122
|
+
*** 3203,3209 ****
|
123
|
+
{
|
124
|
+
if (MB_BYTE2LEN(n) > len)
|
125
|
+
continue; /* more bytes to get */
|
126
|
+
! buf[len >= CBUFLEN ? CBUFLEN - 1 : len] = NUL;
|
127
|
+
n = (*mb_ptr2char)(buf);
|
128
|
+
}
|
129
|
+
#endif
|
130
|
+
--- 3221,3227 ----
|
131
|
+
{
|
132
|
+
if (MB_BYTE2LEN(n) > len)
|
133
|
+
continue; /* more bytes to get */
|
134
|
+
! buf[len >= buflen ? buflen - 1 : len] = NUL;
|
135
|
+
n = (*mb_ptr2char)(buf);
|
136
|
+
}
|
137
|
+
#endif
|
138
|
+
***************
|
139
|
+
*** 3213,3218 ****
|
140
|
+
--- 3231,3237 ----
|
141
|
+
#endif
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
+ vim_free(buf);
|
145
|
+
|
146
|
+
mapped_ctrl_c = save_mapped_ctrl_c;
|
147
|
+
return n;
|
148
|
+
*** ../vim-7.3.430/src/term.c 2012-01-26 13:01:54.000000000 +0100
|
149
|
+
--- src/term.c 2012-02-05 21:45:09.000000000 +0100
|
150
|
+
***************
|
151
|
+
*** 3785,3798 ****
|
152
|
+
* With a match, the match is removed, the replacement code is inserted in
|
153
|
+
* typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
|
154
|
+
* returned.
|
155
|
+
! * When "buf" is not NULL, it is used instead of typebuf.tb_buf[]. "buflen" is
|
156
|
+
! * then the length of the string in buf[].
|
157
|
+
*/
|
158
|
+
int
|
159
|
+
! check_termcode(max_offset, buf, buflen)
|
160
|
+
int max_offset;
|
161
|
+
char_u *buf;
|
162
|
+
! int buflen;
|
163
|
+
{
|
164
|
+
char_u *tp;
|
165
|
+
char_u *p;
|
166
|
+
--- 3785,3800 ----
|
167
|
+
* With a match, the match is removed, the replacement code is inserted in
|
168
|
+
* typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
|
169
|
+
* returned.
|
170
|
+
! * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[].
|
171
|
+
! * "buflen" is then the length of the string in buf[] and is updated for
|
172
|
+
! * inserts and deletes.
|
173
|
+
*/
|
174
|
+
int
|
175
|
+
! check_termcode(max_offset, buf, bufsize, buflen)
|
176
|
+
int max_offset;
|
177
|
+
char_u *buf;
|
178
|
+
! int bufsize;
|
179
|
+
! int *buflen;
|
180
|
+
{
|
181
|
+
char_u *tp;
|
182
|
+
char_u *p;
|
183
|
+
***************
|
184
|
+
*** 3864,3873 ****
|
185
|
+
}
|
186
|
+
else
|
187
|
+
{
|
188
|
+
! if (offset >= buflen)
|
189
|
+
break;
|
190
|
+
tp = buf + offset;
|
191
|
+
! len = buflen - offset;
|
192
|
+
}
|
193
|
+
|
194
|
+
/*
|
195
|
+
--- 3866,3875 ----
|
196
|
+
}
|
197
|
+
else
|
198
|
+
{
|
199
|
+
! if (offset >= *buflen)
|
200
|
+
break;
|
201
|
+
tp = buf + offset;
|
202
|
+
! len = *buflen - offset;
|
203
|
+
}
|
204
|
+
|
205
|
+
/*
|
206
|
+
***************
|
207
|
+
*** 5002,5013 ****
|
208
|
+
if (extra < 0)
|
209
|
+
/* remove matched characters */
|
210
|
+
mch_memmove(buf + offset, buf + offset - extra,
|
211
|
+
! (size_t)(buflen + offset + extra));
|
212
|
+
else if (extra > 0)
|
213
|
+
! /* insert the extra space we need */
|
214
|
+
mch_memmove(buf + offset + extra, buf + offset,
|
215
|
+
! (size_t)(buflen - offset));
|
216
|
+
mch_memmove(buf + offset, string, (size_t)new_slen);
|
217
|
+
}
|
218
|
+
return retval == 0 ? (len + extra + offset) : retval;
|
219
|
+
}
|
220
|
+
--- 5004,5021 ----
|
221
|
+
if (extra < 0)
|
222
|
+
/* remove matched characters */
|
223
|
+
mch_memmove(buf + offset, buf + offset - extra,
|
224
|
+
! (size_t)(*buflen + offset + extra));
|
225
|
+
else if (extra > 0)
|
226
|
+
! {
|
227
|
+
! /* Insert the extra space we need. If there is insufficient
|
228
|
+
! * space return -1. */
|
229
|
+
! if (*buflen + extra + new_slen >= bufsize)
|
230
|
+
! return -1;
|
231
|
+
mch_memmove(buf + offset + extra, buf + offset,
|
232
|
+
! (size_t)(*buflen - offset));
|
233
|
+
! }
|
234
|
+
mch_memmove(buf + offset, string, (size_t)new_slen);
|
235
|
+
+ *buflen = *buflen + extra + new_slen;
|
236
|
+
}
|
237
|
+
return retval == 0 ? (len + extra + offset) : retval;
|
238
|
+
}
|
239
|
+
*** ../vim-7.3.430/src/proto/term.pro 2010-08-15 21:57:28.000000000 +0200
|
240
|
+
--- src/proto/term.pro 2012-02-05 21:45:16.000000000 +0100
|
241
|
+
***************
|
242
|
+
*** 50,56 ****
|
243
|
+
char_u *get_termcode __ARGS((int i));
|
244
|
+
void del_termcode __ARGS((char_u *name));
|
245
|
+
void set_mouse_topline __ARGS((win_T *wp));
|
246
|
+
! int check_termcode __ARGS((int max_offset, char_u *buf, int buflen));
|
247
|
+
char_u *replace_termcodes __ARGS((char_u *from, char_u **bufp, int from_part, int do_lt, int special));
|
248
|
+
int find_term_bykeys __ARGS((char_u *src));
|
249
|
+
void show_termcodes __ARGS((void));
|
250
|
+
--- 50,56 ----
|
251
|
+
char_u *get_termcode __ARGS((int i));
|
252
|
+
void del_termcode __ARGS((char_u *name));
|
253
|
+
void set_mouse_topline __ARGS((win_T *wp));
|
254
|
+
! int check_termcode __ARGS((int max_offset, char_u *buf, int bufsize, int *buflen));
|
255
|
+
char_u *replace_termcodes __ARGS((char_u *from, char_u **bufp, int from_part, int do_lt, int special));
|
256
|
+
int find_term_bykeys __ARGS((char_u *src));
|
257
|
+
void show_termcodes __ARGS((void));
|
258
|
+
*** ../vim-7.3.430/src/version.c 2012-02-05 20:08:30.000000000 +0100
|
259
|
+
--- src/version.c 2012-02-05 22:03:43.000000000 +0100
|
260
|
+
***************
|
261
|
+
*** 716,717 ****
|
262
|
+
--- 716,719 ----
|
263
|
+
{ /* Add new patch number below this line */
|
264
|
+
+ /**/
|
265
|
+
+ 431,
|
266
|
+
/**/
|
267
|
+
|
268
|
+
--
|
269
|
+
"You know, it's at times like this when I'm trapped in a Vogon airlock with
|
270
|
+
a man from Betelgeuse and about to die of asphyxiation in deep space that I
|
271
|
+
really wish I'd listened to what my mother told me when I was young!"
|
272
|
+
"Why, what did she tell you?"
|
273
|
+
"I don't know, I didn't listen!"
|
274
|
+
-- Arthur Dent and Ford Prefect in Douglas Adams'
|
275
|
+
"The Hitchhiker's Guide to the Galaxy"
|
276
|
+
|
277
|
+
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
278
|
+
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
279
|
+
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
280
|
+
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|