summaryrefslogtreecommitdiffstats
path: root/src/getchar.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-04-18 21:55:01 +0000
committerBram Moolenaar <Bram@vim.org>2006-04-18 21:55:01 +0000
commitc1e37901fc8486c9960d7290e521ba51e292e94b (patch)
tree5367e8f83d9d313dd73c0499fd310f57df5e605f /src/getchar.c
parenta93fa7ee7856b54d3778e613c7b7e4b76aaeb2af (diff)
updated for version 7.0e02v7.0e02
Diffstat (limited to 'src/getchar.c')
-rw-r--r--src/getchar.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/getchar.c b/src/getchar.c
index 3d851653db..0ba97b4065 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -128,6 +128,9 @@ static int vgetorpeek __ARGS((int));
static void map_free __ARGS((mapblock_T **));
static void validate_maphash __ARGS((void));
static void showmap __ARGS((mapblock_T *mp, int local));
+#ifdef FEAT_EVAL
+static char_u *eval_map_expr __ARGS((char_u *str));
+#endif
/*
* Free and clear a buffer.
@@ -2328,7 +2331,7 @@ vgetorpeek(advance)
if (tabuf.typebuf_valid)
{
vgetc_busy = 0;
- s = eval_to_string(mp->m_str, NULL, FALSE);
+ s = eval_map_expr(mp->m_str);
vgetc_busy = save_vgetc_busy;
}
else
@@ -4251,7 +4254,7 @@ check_abbr(c, ptr, col, mincol)
}
#ifdef FEAT_EVAL
if (mp->m_expr)
- s = eval_to_string(mp->m_str, NULL, FALSE);
+ s = eval_map_expr(mp->m_str);
else
#endif
s = mp->m_str;
@@ -4281,6 +4284,36 @@ check_abbr(c, ptr, col, mincol)
return FALSE;
}
+#ifdef FEAT_EVAL
+/*
+ * Evaluate the RHS of a mapping or abbreviations and take care of escaping
+ * special characters.
+ */
+ static char_u *
+eval_map_expr(str)
+ char_u *str;
+{
+ char_u *res;
+ char_u *s;
+ int len;
+
+ s = eval_to_string(str, NULL, FALSE);
+ if (s == NULL)
+ return NULL;
+
+ /* Need a buffer to hold up to three times as much. */
+ len = (int)STRLEN(s);
+ res = alloc((unsigned)(len * 3) + 1);
+ if (res != NULL)
+ {
+ STRCPY(res, s);
+ (void)fix_input_buffer(res, len, TRUE);
+ }
+ vim_free(s);
+ return res;
+}
+#endif
+
/*
* Write map commands for the current mappings to an .exrc file.
* Return FAIL on error, OK otherwise.