Mercurial > vim
changeset 2557:029ace8dff7d vim73
Now really fix using expressions in the command line (hopefully).
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 13 Aug 2010 19:12:07 +0200 |
parents | e065501c703a |
children | 3908363237a9 |
files | src/ex_getln.c |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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); - - if (p != NULL && realloc_cmdbuff((int)STRLEN(p) + 1) == OK) + len = (int)STRLEN(p); + + 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