|
Karsten Hopp |
c72e4f |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
c72e4f |
Subject: Patch 7.3.431
|
|
Karsten Hopp |
c72e4f |
Fcc: outbox
|
|
Karsten Hopp |
c72e4f |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
c72e4f |
Mime-Version: 1.0
|
|
Karsten Hopp |
c72e4f |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
c72e4f |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
c72e4f |
------------
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
Patch 7.3.431
|
|
Karsten Hopp |
c72e4f |
Problem: Fetching a key at a prompt may be confused by escape sequences.
|
|
Karsten Hopp |
c72e4f |
Especially when getting a prompt at a VimEnter autocommand.
|
|
Karsten Hopp |
c72e4f |
(Alex Efros)
|
|
Karsten Hopp |
c72e4f |
Solution: Properly handle escape sequences deleted by check_termcode().
|
|
Karsten Hopp |
c72e4f |
Files: src/getchar.c, src/misc1.c, src/term.c, src/proto/term.pro
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
*** ../vim-7.3.430/src/getchar.c 2012-02-05 01:18:41.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
--- src/getchar.c 2012-02-05 22:04:33.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 2282,2288 ****
|
|
Karsten Hopp |
c72e4f |
typebuf.tb_off] == RM_YES))
|
|
Karsten Hopp |
c72e4f |
&& !timedout)
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
! keylen = check_termcode(max_mlen + 1, NULL, 0);
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/* If no termcode matched but 'pastetoggle'
|
|
Karsten Hopp |
c72e4f |
* matched partially it's like an incomplete key
|
|
Karsten Hopp |
c72e4f |
--- 2282,2289 ----
|
|
Karsten Hopp |
c72e4f |
typebuf.tb_off] == RM_YES))
|
|
Karsten Hopp |
c72e4f |
&& !timedout)
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
! keylen = check_termcode(max_mlen + 1,
|
|
Karsten Hopp |
c72e4f |
! NULL, 0, NULL);
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/* If no termcode matched but 'pastetoggle'
|
|
Karsten Hopp |
c72e4f |
* matched partially it's like an incomplete key
|
|
Karsten Hopp |
c72e4f |
*** ../vim-7.3.430/src/misc1.c 2012-01-10 18:37:53.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
--- src/misc1.c 2012-02-05 21:59:53.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3105,3112 ****
|
|
Karsten Hopp |
c72e4f |
int
|
|
Karsten Hopp |
c72e4f |
get_keystroke()
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
! #define CBUFLEN 151
|
|
Karsten Hopp |
c72e4f |
! char_u buf[CBUFLEN];
|
|
Karsten Hopp |
c72e4f |
int len = 0;
|
|
Karsten Hopp |
c72e4f |
int n;
|
|
Karsten Hopp |
c72e4f |
int save_mapped_ctrl_c = mapped_ctrl_c;
|
|
Karsten Hopp |
c72e4f |
--- 3105,3113 ----
|
|
Karsten Hopp |
c72e4f |
int
|
|
Karsten Hopp |
c72e4f |
get_keystroke()
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
! char_u *buf = NULL;
|
|
Karsten Hopp |
c72e4f |
! int buflen = 150;
|
|
Karsten Hopp |
c72e4f |
! int maxlen;
|
|
Karsten Hopp |
c72e4f |
int len = 0;
|
|
Karsten Hopp |
c72e4f |
int n;
|
|
Karsten Hopp |
c72e4f |
int save_mapped_ctrl_c = mapped_ctrl_c;
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3118,3129 ****
|
|
Karsten Hopp |
c72e4f |
cursor_on();
|
|
Karsten Hopp |
c72e4f |
out_flush();
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/* First time: blocking wait. Second time: wait up to 100ms for a
|
|
Karsten Hopp |
c72e4f |
! * terminal code to complete. Leave some room for check_termcode() to
|
|
Karsten Hopp |
c72e4f |
! * insert a key code into (max 5 chars plus NUL). And
|
|
Karsten Hopp |
c72e4f |
! * fix_input_buffer() can triple the number of bytes. */
|
|
Karsten Hopp |
c72e4f |
! n = ui_inchar(buf + len, (CBUFLEN - 6 - len) / 3,
|
|
Karsten Hopp |
c72e4f |
! len == 0 ? -1L : 100L, 0);
|
|
Karsten Hopp |
c72e4f |
if (n > 0)
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
/* Replace zero and CSI by a special key code. */
|
|
Karsten Hopp |
c72e4f |
--- 3119,3147 ----
|
|
Karsten Hopp |
c72e4f |
cursor_on();
|
|
Karsten Hopp |
c72e4f |
out_flush();
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
+ /* Leave some room for check_termcode() to insert a key code into (max
|
|
Karsten Hopp |
c72e4f |
+ * 5 chars plus NUL). And fix_input_buffer() can triple the number of
|
|
Karsten Hopp |
c72e4f |
+ * bytes. */
|
|
Karsten Hopp |
c72e4f |
+ maxlen = (buflen - 6 - len) / 3;
|
|
Karsten Hopp |
c72e4f |
+ if (buf == NULL)
|
|
Karsten Hopp |
c72e4f |
+ buf = alloc(buflen);
|
|
Karsten Hopp |
c72e4f |
+ else if (maxlen < 10)
|
|
Karsten Hopp |
c72e4f |
+ {
|
|
Karsten Hopp |
c72e4f |
+ /* Need some more space. This migth happen when receiving a long
|
|
Karsten Hopp |
c72e4f |
+ * escape sequence. */
|
|
Karsten Hopp |
c72e4f |
+ buflen += 100;
|
|
Karsten Hopp |
c72e4f |
+ buf = vim_realloc(buf, buflen);
|
|
Karsten Hopp |
c72e4f |
+ maxlen = (buflen - 6 - len) / 3;
|
|
Karsten Hopp |
c72e4f |
+ }
|
|
Karsten Hopp |
c72e4f |
+ if (buf == NULL)
|
|
Karsten Hopp |
c72e4f |
+ {
|
|
Karsten Hopp |
c72e4f |
+ do_outofmem_msg((long_u)buflen);
|
|
Karsten Hopp |
c72e4f |
+ return ESC; /* panic! */
|
|
Karsten Hopp |
c72e4f |
+ }
|
|
Karsten Hopp |
c72e4f |
+
|
|
Karsten Hopp |
c72e4f |
/* First time: blocking wait. Second time: wait up to 100ms for a
|
|
Karsten Hopp |
c72e4f |
! * terminal code to complete. */
|
|
Karsten Hopp |
c72e4f |
! n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
|
|
Karsten Hopp |
c72e4f |
if (n > 0)
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
/* Replace zero and CSI by a special key code. */
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3135,3141 ****
|
|
Karsten Hopp |
c72e4f |
++waited; /* keep track of the waiting time */
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/* Incomplete termcode and not timed out yet: get more characters */
|
|
Karsten Hopp |
c72e4f |
! if ((n = check_termcode(1, buf, len)) < 0
|
|
Karsten Hopp |
c72e4f |
&& (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
|
|
Karsten Hopp |
c72e4f |
continue;
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
--- 3153,3159 ----
|
|
Karsten Hopp |
c72e4f |
++waited; /* keep track of the waiting time */
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/* Incomplete termcode and not timed out yet: get more characters */
|
|
Karsten Hopp |
c72e4f |
! if ((n = check_termcode(1, buf, buflen, &len)) < 0
|
|
Karsten Hopp |
c72e4f |
&& (!p_ttimeout || waited * 100L < (p_ttm < 0 ? p_tm : p_ttm)))
|
|
Karsten Hopp |
c72e4f |
continue;
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3203,3209 ****
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
if (MB_BYTE2LEN(n) > len)
|
|
Karsten Hopp |
c72e4f |
continue; /* more bytes to get */
|
|
Karsten Hopp |
c72e4f |
! buf[len >= CBUFLEN ? CBUFLEN - 1 : len] = NUL;
|
|
Karsten Hopp |
c72e4f |
n = (*mb_ptr2char)(buf);
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
#endif
|
|
Karsten Hopp |
c72e4f |
--- 3221,3227 ----
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
if (MB_BYTE2LEN(n) > len)
|
|
Karsten Hopp |
c72e4f |
continue; /* more bytes to get */
|
|
Karsten Hopp |
c72e4f |
! buf[len >= buflen ? buflen - 1 : len] = NUL;
|
|
Karsten Hopp |
c72e4f |
n = (*mb_ptr2char)(buf);
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
#endif
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3213,3218 ****
|
|
Karsten Hopp |
c72e4f |
--- 3231,3237 ----
|
|
Karsten Hopp |
c72e4f |
#endif
|
|
Karsten Hopp |
c72e4f |
break;
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
+ vim_free(buf);
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
mapped_ctrl_c = save_mapped_ctrl_c;
|
|
Karsten Hopp |
c72e4f |
return n;
|
|
Karsten Hopp |
c72e4f |
*** ../vim-7.3.430/src/term.c 2012-01-26 13:01:54.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
--- src/term.c 2012-02-05 21:45:09.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3785,3798 ****
|
|
Karsten Hopp |
c72e4f |
* With a match, the match is removed, the replacement code is inserted in
|
|
Karsten Hopp |
c72e4f |
* typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
|
|
Karsten Hopp |
c72e4f |
* returned.
|
|
Karsten Hopp |
c72e4f |
! * When "buf" is not NULL, it is used instead of typebuf.tb_buf[]. "buflen" is
|
|
Karsten Hopp |
c72e4f |
! * then the length of the string in buf[].
|
|
Karsten Hopp |
c72e4f |
*/
|
|
Karsten Hopp |
c72e4f |
int
|
|
Karsten Hopp |
c72e4f |
! check_termcode(max_offset, buf, buflen)
|
|
Karsten Hopp |
c72e4f |
int max_offset;
|
|
Karsten Hopp |
c72e4f |
char_u *buf;
|
|
Karsten Hopp |
c72e4f |
! int buflen;
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
char_u *tp;
|
|
Karsten Hopp |
c72e4f |
char_u *p;
|
|
Karsten Hopp |
c72e4f |
--- 3785,3800 ----
|
|
Karsten Hopp |
c72e4f |
* With a match, the match is removed, the replacement code is inserted in
|
|
Karsten Hopp |
c72e4f |
* typebuf.tb_buf[] and the number of characters in typebuf.tb_buf[] is
|
|
Karsten Hopp |
c72e4f |
* returned.
|
|
Karsten Hopp |
c72e4f |
! * When "buf" is not NULL, buf[bufsize] is used instead of typebuf.tb_buf[].
|
|
Karsten Hopp |
c72e4f |
! * "buflen" is then the length of the string in buf[] and is updated for
|
|
Karsten Hopp |
c72e4f |
! * inserts and deletes.
|
|
Karsten Hopp |
c72e4f |
*/
|
|
Karsten Hopp |
c72e4f |
int
|
|
Karsten Hopp |
c72e4f |
! check_termcode(max_offset, buf, bufsize, buflen)
|
|
Karsten Hopp |
c72e4f |
int max_offset;
|
|
Karsten Hopp |
c72e4f |
char_u *buf;
|
|
Karsten Hopp |
c72e4f |
! int bufsize;
|
|
Karsten Hopp |
c72e4f |
! int *buflen;
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
char_u *tp;
|
|
Karsten Hopp |
c72e4f |
char_u *p;
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 3864,3873 ****
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
else
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
! if (offset >= buflen)
|
|
Karsten Hopp |
c72e4f |
break;
|
|
Karsten Hopp |
c72e4f |
tp = buf + offset;
|
|
Karsten Hopp |
c72e4f |
! len = buflen - offset;
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/*
|
|
Karsten Hopp |
c72e4f |
--- 3866,3875 ----
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
else
|
|
Karsten Hopp |
c72e4f |
{
|
|
Karsten Hopp |
c72e4f |
! if (offset >= *buflen)
|
|
Karsten Hopp |
c72e4f |
break;
|
|
Karsten Hopp |
c72e4f |
tp = buf + offset;
|
|
Karsten Hopp |
c72e4f |
! len = *buflen - offset;
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/*
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 5002,5013 ****
|
|
Karsten Hopp |
c72e4f |
if (extra < 0)
|
|
Karsten Hopp |
c72e4f |
/* remove matched characters */
|
|
Karsten Hopp |
c72e4f |
mch_memmove(buf + offset, buf + offset - extra,
|
|
Karsten Hopp |
c72e4f |
! (size_t)(buflen + offset + extra));
|
|
Karsten Hopp |
c72e4f |
else if (extra > 0)
|
|
Karsten Hopp |
c72e4f |
! /* insert the extra space we need */
|
|
Karsten Hopp |
c72e4f |
mch_memmove(buf + offset + extra, buf + offset,
|
|
Karsten Hopp |
c72e4f |
! (size_t)(buflen - offset));
|
|
Karsten Hopp |
c72e4f |
mch_memmove(buf + offset, string, (size_t)new_slen);
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
return retval == 0 ? (len + extra + offset) : retval;
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
--- 5004,5021 ----
|
|
Karsten Hopp |
c72e4f |
if (extra < 0)
|
|
Karsten Hopp |
c72e4f |
/* remove matched characters */
|
|
Karsten Hopp |
c72e4f |
mch_memmove(buf + offset, buf + offset - extra,
|
|
Karsten Hopp |
c72e4f |
! (size_t)(*buflen + offset + extra));
|
|
Karsten Hopp |
c72e4f |
else if (extra > 0)
|
|
Karsten Hopp |
c72e4f |
! {
|
|
Karsten Hopp |
c72e4f |
! /* Insert the extra space we need. If there is insufficient
|
|
Karsten Hopp |
c72e4f |
! * space return -1. */
|
|
Karsten Hopp |
c72e4f |
! if (*buflen + extra + new_slen >= bufsize)
|
|
Karsten Hopp |
c72e4f |
! return -1;
|
|
Karsten Hopp |
c72e4f |
mch_memmove(buf + offset + extra, buf + offset,
|
|
Karsten Hopp |
c72e4f |
! (size_t)(*buflen - offset));
|
|
Karsten Hopp |
c72e4f |
! }
|
|
Karsten Hopp |
c72e4f |
mch_memmove(buf + offset, string, (size_t)new_slen);
|
|
Karsten Hopp |
c72e4f |
+ *buflen = *buflen + extra + new_slen;
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
return retval == 0 ? (len + extra + offset) : retval;
|
|
Karsten Hopp |
c72e4f |
}
|
|
Karsten Hopp |
c72e4f |
*** ../vim-7.3.430/src/proto/term.pro 2010-08-15 21:57:28.000000000 +0200
|
|
Karsten Hopp |
c72e4f |
--- src/proto/term.pro 2012-02-05 21:45:16.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 50,56 ****
|
|
Karsten Hopp |
c72e4f |
char_u *get_termcode __ARGS((int i));
|
|
Karsten Hopp |
c72e4f |
void del_termcode __ARGS((char_u *name));
|
|
Karsten Hopp |
c72e4f |
void set_mouse_topline __ARGS((win_T *wp));
|
|
Karsten Hopp |
c72e4f |
! int check_termcode __ARGS((int max_offset, char_u *buf, int buflen));
|
|
Karsten Hopp |
c72e4f |
char_u *replace_termcodes __ARGS((char_u *from, char_u **bufp, int from_part, int do_lt, int special));
|
|
Karsten Hopp |
c72e4f |
int find_term_bykeys __ARGS((char_u *src));
|
|
Karsten Hopp |
c72e4f |
void show_termcodes __ARGS((void));
|
|
Karsten Hopp |
c72e4f |
--- 50,56 ----
|
|
Karsten Hopp |
c72e4f |
char_u *get_termcode __ARGS((int i));
|
|
Karsten Hopp |
c72e4f |
void del_termcode __ARGS((char_u *name));
|
|
Karsten Hopp |
c72e4f |
void set_mouse_topline __ARGS((win_T *wp));
|
|
Karsten Hopp |
c72e4f |
! int check_termcode __ARGS((int max_offset, char_u *buf, int bufsize, int *buflen));
|
|
Karsten Hopp |
c72e4f |
char_u *replace_termcodes __ARGS((char_u *from, char_u **bufp, int from_part, int do_lt, int special));
|
|
Karsten Hopp |
c72e4f |
int find_term_bykeys __ARGS((char_u *src));
|
|
Karsten Hopp |
c72e4f |
void show_termcodes __ARGS((void));
|
|
Karsten Hopp |
c72e4f |
*** ../vim-7.3.430/src/version.c 2012-02-05 20:08:30.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
--- src/version.c 2012-02-05 22:03:43.000000000 +0100
|
|
Karsten Hopp |
c72e4f |
***************
|
|
Karsten Hopp |
c72e4f |
*** 716,717 ****
|
|
Karsten Hopp |
c72e4f |
--- 716,719 ----
|
|
Karsten Hopp |
c72e4f |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
c72e4f |
+ /**/
|
|
Karsten Hopp |
c72e4f |
+ 431,
|
|
Karsten Hopp |
c72e4f |
/**/
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
--
|
|
Karsten Hopp |
c72e4f |
"You know, it's at times like this when I'm trapped in a Vogon airlock with
|
|
Karsten Hopp |
c72e4f |
a man from Betelgeuse and about to die of asphyxiation in deep space that I
|
|
Karsten Hopp |
c72e4f |
really wish I'd listened to what my mother told me when I was young!"
|
|
Karsten Hopp |
c72e4f |
"Why, what did she tell you?"
|
|
Karsten Hopp |
c72e4f |
"I don't know, I didn't listen!"
|
|
Karsten Hopp |
c72e4f |
-- Arthur Dent and Ford Prefect in Douglas Adams'
|
|
Karsten Hopp |
c72e4f |
"The Hitchhiker's Guide to the Galaxy"
|
|
Karsten Hopp |
c72e4f |
|
|
Karsten Hopp |
c72e4f |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
c72e4f |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
c72e4f |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
c72e4f |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|