|
Karsten Hopp |
cf262a |
To: vim-dev@vim.org
|
|
Karsten Hopp |
cf262a |
Subject: Patch 7.2.347
|
|
Karsten Hopp |
cf262a |
Fcc: outbox
|
|
Karsten Hopp |
cf262a |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
cf262a |
Mime-Version: 1.0
|
|
Karsten Hopp |
cf262a |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
cf262a |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
cf262a |
------------
|
|
Karsten Hopp |
cf262a |
|
|
Karsten Hopp |
cf262a |
Patch 7.2.347
|
|
Karsten Hopp |
cf262a |
Problem: Crash when executing <expr> mapping redefines that same mapping.
|
|
Karsten Hopp |
cf262a |
Solution: Save the values used before evaluating the expression.
|
|
Karsten Hopp |
cf262a |
Files: src/getchar.c
|
|
Karsten Hopp |
cf262a |
|
|
Karsten Hopp |
cf262a |
|
|
Karsten Hopp |
cf262a |
*** ../vim-7.2.346/src/getchar.c 2009-11-11 16:23:37.000000000 +0100
|
|
Karsten Hopp |
cf262a |
--- src/getchar.c 2010-01-27 17:30:42.000000000 +0100
|
|
Karsten Hopp |
cf262a |
***************
|
|
Karsten Hopp |
cf262a |
*** 2389,2394 ****
|
|
Karsten Hopp |
cf262a |
--- 2389,2405 ----
|
|
Karsten Hopp |
cf262a |
/* complete match */
|
|
Karsten Hopp |
cf262a |
if (keylen >= 0 && keylen <= typebuf.tb_len)
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
+ #ifdef FEAT_EVAL
|
|
Karsten Hopp |
cf262a |
+ int save_m_expr;
|
|
Karsten Hopp |
cf262a |
+ int save_m_noremap;
|
|
Karsten Hopp |
cf262a |
+ int save_m_silent;
|
|
Karsten Hopp |
cf262a |
+ char_u *save_m_keys;
|
|
Karsten Hopp |
cf262a |
+ char_u *save_m_str;
|
|
Karsten Hopp |
cf262a |
+ #else
|
|
Karsten Hopp |
cf262a |
+ # define save_m_noremap mp->m_noremap
|
|
Karsten Hopp |
cf262a |
+ # define save_m_silent mp->m_silent
|
|
Karsten Hopp |
cf262a |
+ #endif
|
|
Karsten Hopp |
cf262a |
+
|
|
Karsten Hopp |
cf262a |
/* write chars to script file(s) */
|
|
Karsten Hopp |
cf262a |
if (keylen > typebuf.tb_maplen)
|
|
Karsten Hopp |
cf262a |
gotchars(typebuf.tb_buf + typebuf.tb_off
|
|
Karsten Hopp |
cf262a |
***************
|
|
Karsten Hopp |
cf262a |
*** 2431,2436 ****
|
|
Karsten Hopp |
cf262a |
--- 2442,2457 ----
|
|
Karsten Hopp |
cf262a |
#endif
|
|
Karsten Hopp |
cf262a |
|
|
Karsten Hopp |
cf262a |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
cf262a |
+ /* Copy the values from *mp that are used, because
|
|
Karsten Hopp |
cf262a |
+ * evaluating the expression may invoke a function
|
|
Karsten Hopp |
cf262a |
+ * that redefines the mapping, thereby making *mp
|
|
Karsten Hopp |
cf262a |
+ * invalid. */
|
|
Karsten Hopp |
cf262a |
+ save_m_expr = mp->m_expr;
|
|
Karsten Hopp |
cf262a |
+ save_m_noremap = mp->m_noremap;
|
|
Karsten Hopp |
cf262a |
+ save_m_silent = mp->m_silent;
|
|
Karsten Hopp |
cf262a |
+ save_m_keys = NULL; /* only saved when needed */
|
|
Karsten Hopp |
cf262a |
+ save_m_str = NULL; /* only saved when needed */
|
|
Karsten Hopp |
cf262a |
+
|
|
Karsten Hopp |
cf262a |
/*
|
|
Karsten Hopp |
cf262a |
* Handle ":map <expr>": evaluate the {rhs} as an
|
|
Karsten Hopp |
cf262a |
* expression. Save and restore the typeahead so that
|
|
Karsten Hopp |
cf262a |
***************
|
|
Karsten Hopp |
cf262a |
*** 2446,2452 ****
|
|
Karsten Hopp |
cf262a |
if (tabuf.typebuf_valid)
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
vgetc_busy = 0;
|
|
Karsten Hopp |
cf262a |
! s = eval_map_expr(mp->m_str, NUL);
|
|
Karsten Hopp |
cf262a |
vgetc_busy = save_vgetc_busy;
|
|
Karsten Hopp |
cf262a |
}
|
|
Karsten Hopp |
cf262a |
else
|
|
Karsten Hopp |
cf262a |
--- 2467,2475 ----
|
|
Karsten Hopp |
cf262a |
if (tabuf.typebuf_valid)
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
vgetc_busy = 0;
|
|
Karsten Hopp |
cf262a |
! save_m_keys = vim_strsave(mp->m_keys);
|
|
Karsten Hopp |
cf262a |
! save_m_str = vim_strsave(mp->m_str);
|
|
Karsten Hopp |
cf262a |
! s = eval_map_expr(save_m_str, NUL);
|
|
Karsten Hopp |
cf262a |
vgetc_busy = save_vgetc_busy;
|
|
Karsten Hopp |
cf262a |
}
|
|
Karsten Hopp |
cf262a |
else
|
|
Karsten Hopp |
cf262a |
***************
|
|
Karsten Hopp |
cf262a |
*** 2470,2486 ****
|
|
Karsten Hopp |
cf262a |
else
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
i = ins_typebuf(s,
|
|
Karsten Hopp |
cf262a |
! mp->m_noremap != REMAP_YES
|
|
Karsten Hopp |
cf262a |
! ? mp->m_noremap
|
|
Karsten Hopp |
cf262a |
! : STRNCMP(s, mp->m_keys,
|
|
Karsten Hopp |
cf262a |
(size_t)keylen) != 0
|
|
Karsten Hopp |
cf262a |
? REMAP_YES : REMAP_SKIP,
|
|
Karsten Hopp |
cf262a |
! 0, TRUE, cmd_silent || mp->m_silent);
|
|
Karsten Hopp |
cf262a |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
cf262a |
! if (mp->m_expr)
|
|
Karsten Hopp |
cf262a |
vim_free(s);
|
|
Karsten Hopp |
cf262a |
#endif
|
|
Karsten Hopp |
cf262a |
}
|
|
Karsten Hopp |
cf262a |
if (i == FAIL)
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
c = -1;
|
|
Karsten Hopp |
cf262a |
--- 2493,2517 ----
|
|
Karsten Hopp |
cf262a |
else
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
i = ins_typebuf(s,
|
|
Karsten Hopp |
cf262a |
! save_m_noremap != REMAP_YES
|
|
Karsten Hopp |
cf262a |
! ? save_m_noremap
|
|
Karsten Hopp |
cf262a |
! : STRNCMP(s,
|
|
Karsten Hopp |
cf262a |
! #ifdef FEAT_EVAL
|
|
Karsten Hopp |
cf262a |
! save_m_keys != NULL ? save_m_keys :
|
|
Karsten Hopp |
cf262a |
! #endif
|
|
Karsten Hopp |
cf262a |
! mp->m_keys,
|
|
Karsten Hopp |
cf262a |
(size_t)keylen) != 0
|
|
Karsten Hopp |
cf262a |
? REMAP_YES : REMAP_SKIP,
|
|
Karsten Hopp |
cf262a |
! 0, TRUE, cmd_silent || save_m_silent);
|
|
Karsten Hopp |
cf262a |
#ifdef FEAT_EVAL
|
|
Karsten Hopp |
cf262a |
! if (save_m_expr)
|
|
Karsten Hopp |
cf262a |
vim_free(s);
|
|
Karsten Hopp |
cf262a |
#endif
|
|
Karsten Hopp |
cf262a |
}
|
|
Karsten Hopp |
cf262a |
+ #ifdef FEAT_EVAL
|
|
Karsten Hopp |
cf262a |
+ vim_free(save_m_keys);
|
|
Karsten Hopp |
cf262a |
+ vim_free(save_m_str);
|
|
Karsten Hopp |
cf262a |
+ #endif
|
|
Karsten Hopp |
cf262a |
if (i == FAIL)
|
|
Karsten Hopp |
cf262a |
{
|
|
Karsten Hopp |
cf262a |
c = -1;
|
|
Karsten Hopp |
cf262a |
*** ../vim-7.2.346/src/version.c 2010-01-27 16:31:00.000000000 +0100
|
|
Karsten Hopp |
cf262a |
--- src/version.c 2010-01-27 17:27:32.000000000 +0100
|
|
Karsten Hopp |
cf262a |
***************
|
|
Karsten Hopp |
cf262a |
*** 683,684 ****
|
|
Karsten Hopp |
cf262a |
--- 683,686 ----
|
|
Karsten Hopp |
cf262a |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
cf262a |
+ /**/
|
|
Karsten Hopp |
cf262a |
+ 347,
|
|
Karsten Hopp |
cf262a |
/**/
|
|
Karsten Hopp |
cf262a |
|
|
Karsten Hopp |
cf262a |
--
|
|
Karsten Hopp |
cf262a |
hundred-and-one symptoms of being an internet addict:
|
|
Karsten Hopp |
cf262a |
156. You forget your friend's name but not her e-mail address.
|
|
Karsten Hopp |
cf262a |
|
|
Karsten Hopp |
cf262a |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
cf262a |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
cf262a |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
cf262a |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|