Mercurial > vim
diff src/evalfunc.c @ 9589:bf204ab1ce7d v7.4.2072
commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 19 19:10:51 2016 +0200
patch 7.4.2072
Problem: substitute() does not support a Funcref argument.
Solution: Support a Funcref like it supports a string starting with "\=".
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Jul 2016 19:15:06 +0200 |
parents | 05a56bbe34a1 |
children | 172131507c85 |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -11061,14 +11061,21 @@ f_substitute(typval_T *argvars, typval_T char_u *str = get_tv_string_chk(&argvars[0]); char_u *pat = get_tv_string_buf_chk(&argvars[1], patbuf); - char_u *sub = get_tv_string_buf_chk(&argvars[2], subbuf); + char_u *sub = NULL; + typval_T *expr = NULL; char_u *flg = get_tv_string_buf_chk(&argvars[3], flagsbuf); + if (argvars[2].v_type == VAR_FUNC || argvars[2].v_type == VAR_PARTIAL) + expr = &argvars[2]; + else + sub = get_tv_string_buf_chk(&argvars[2], subbuf); + rettv->v_type = VAR_STRING; - if (str == NULL || pat == NULL || sub == NULL || flg == NULL) + if (str == NULL || pat == NULL || (sub == NULL && expr == NULL) + || flg == NULL) rettv->vval.v_string = NULL; else - rettv->vval.v_string = do_string_sub(str, pat, sub, flg); + rettv->vval.v_string = do_string_sub(str, pat, sub, expr, flg); } /*