summaryrefslogtreecommitdiff
path: root/src/ex_getln.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-08-13 19:12:07 +0200
committerBram Moolenaar <Bram@vim.org>2010-08-13 19:12:07 +0200
commit673b87b57745c99670be3fe97754ec05012645f0 (patch)
treec3e260e15c03b803ccae32cd5c33deba626aea38 /src/ex_getln.c
parent35a3423c6ae785bf739319e1ec416b2de1462a8c (diff)
downloadvim-git-673b87b57745c99670be3fe97754ec05012645f0.tar.gz
Now really fix using expressions in the command line (hopefully).
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r--src/ex_getln.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 1cf678543..821a79c2c 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -662,7 +662,8 @@ getcmdline(firstc, count, indent)
#ifdef FEAT_EVAL
else if (c == 'e')
{
- char_u *p = NULL;
+ char_u *p = NULL;
+ int len;
/*
* Replace the command line with the result of an expression.
@@ -687,10 +688,11 @@ getcmdline(firstc, count, indent)
p = get_expr_line();
--textlock;
restore_cmdline(&save_ccline);
+ len = (int)STRLEN(p);
- if (p != NULL && realloc_cmdbuff((int)STRLEN(p) + 1) == OK)
+ if (p != NULL && realloc_cmdbuff(len + 1) == OK)
{
- ccline.cmdlen = (int)STRLEN(p);
+ ccline.cmdlen = len;
STRCPY(ccline.cmdbuff, p);
vim_free(p);
@@ -2520,6 +2522,9 @@ realloc_cmdbuff(len)
{
char_u *p;
+ if (len < ccline.cmdbufflen)
+ return OK; /* no need to resize */
+
p = ccline.cmdbuff;
alloc_cmdbuff(len); /* will get some more */
if (ccline.cmdbuff == NULL) /* out of memory */
@@ -2744,7 +2749,7 @@ put_on_cmdline(str, len, redraw)
/* Check if ccline.cmdbuff needs to be longer */
if (ccline.cmdlen + len + 1 >= ccline.cmdbufflen)
- retval = realloc_cmdbuff(ccline.cmdlen + len);
+ retval = realloc_cmdbuff(ccline.cmdlen + len + 1);
else
retval = OK;
if (retval == OK)
@@ -3335,9 +3340,9 @@ nextwild(xp, type, options)
if (p2 != NULL && !got_int)
{
difflen = (int)STRLEN(p2) - xp->xp_pattern_len;
- if (ccline.cmdlen + difflen > ccline.cmdbufflen - 4)
+ if (ccline.cmdlen + difflen + 4 > ccline.cmdbufflen)
{
- v = realloc_cmdbuff(ccline.cmdlen + difflen);
+ v = realloc_cmdbuff(ccline.cmdlen + difflen + 4);
xp->xp_pattern = ccline.cmdbuff + i;
}
else