diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-07-07 23:04:18 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-07-07 23:04:18 +0200 |
commit | bc5d6dd1dd1dc3a06e4e655fc9479529db288365 (patch) | |
tree | a1a4a52ccd792948a0da290701ed3fbc14b34ed5 /src/eval.c | |
parent | bf2cc5f36d5ffd5de445e6970602000c7869b65a (diff) |
patch 7.4.1999v7.4.1999
Problem: evalcmd() doesn't work recursively.
Solution: Use redir_evalcmd instead of redir_vname.
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/eval.c b/src/eval.c index 74ed263d51..445b6b91c4 100644 --- a/src/eval.c +++ b/src/eval.c @@ -11345,6 +11345,28 @@ f_eval(typval_T *argvars, typval_T *rettv) EMSG(_(e_trailing)); } +static garray_T redir_evalcmd_ga; + +/* + * Append "value[value_len]" to the evalcmd() output. + */ + void +evalcmd_redir_str(char_u *value, int value_len) +{ + int len; + + if (value_len == -1) + len = (int)STRLEN(value); /* Append the entire string */ + else + len = value_len; /* Append only "value_len" characters */ + if (ga_grow(&redir_evalcmd_ga, len) == OK) + { + mch_memmove((char *)redir_evalcmd_ga.ga_data + + redir_evalcmd_ga.ga_len, value, len); + redir_evalcmd_ga.ga_len += len; + } +} + /* * "evalcmd()" function */ @@ -11352,6 +11374,9 @@ f_eval(typval_T *argvars, typval_T *rettv) f_evalcmd(typval_T *argvars, typval_T *rettv) { char_u *s; + int save_msg_silent = msg_silent; + int save_redir_evalcmd = redir_evalcmd; + garray_T save_ga; rettv->vval.v_string = NULL; rettv->v_type = VAR_STRING; @@ -11359,20 +11384,20 @@ f_evalcmd(typval_T *argvars, typval_T *rettv) s = get_tv_string_chk(&argvars[0]); if (s != NULL) { - redir_vname = TRUE; - redir_lval = (lval_T *)&redir_lval; - ga_init2(&redir_ga, (int)sizeof(char), 500); + if (redir_evalcmd) + save_ga = redir_evalcmd_ga; + ga_init2(&redir_evalcmd_ga, (int)sizeof(char), 500); + redir_evalcmd = TRUE; - if (do_cmdline_cmd(s) == OK) - rettv->vval.v_string = redir_ga.ga_data; - else - vim_free(redir_ga.ga_data); + ++msg_silent; + do_cmdline_cmd(s); + rettv->vval.v_string = redir_evalcmd_ga.ga_data; + msg_silent = save_msg_silent; - redir_ga.ga_data = NULL; - redir_vname = FALSE; - redir_lval = NULL; + redir_evalcmd = save_redir_evalcmd; + if (redir_evalcmd) + redir_evalcmd_ga = save_ga; } - } /* |