Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
9588:58eb7e194286 | 9589:bf204ab1ce7d |
---|---|
11059 char_u subbuf[NUMBUFLEN]; | 11059 char_u subbuf[NUMBUFLEN]; |
11060 char_u flagsbuf[NUMBUFLEN]; | 11060 char_u flagsbuf[NUMBUFLEN]; |
11061 | 11061 |
11062 char_u *str = get_tv_string_chk(&argvars[0]); | 11062 char_u *str = get_tv_string_chk(&argvars[0]); |
11063 char_u *pat = get_tv_string_buf_chk(&argvars[1], patbuf); | 11063 char_u *pat = get_tv_string_buf_chk(&argvars[1], patbuf); |
11064 char_u *sub = get_tv_string_buf_chk(&argvars[2], subbuf); | 11064 char_u *sub = NULL; |
11065 typval_T *expr = NULL; | |
11065 char_u *flg = get_tv_string_buf_chk(&argvars[3], flagsbuf); | 11066 char_u *flg = get_tv_string_buf_chk(&argvars[3], flagsbuf); |
11066 | 11067 |
11068 if (argvars[2].v_type == VAR_FUNC || argvars[2].v_type == VAR_PARTIAL) | |
11069 expr = &argvars[2]; | |
11070 else | |
11071 sub = get_tv_string_buf_chk(&argvars[2], subbuf); | |
11072 | |
11067 rettv->v_type = VAR_STRING; | 11073 rettv->v_type = VAR_STRING; |
11068 if (str == NULL || pat == NULL || sub == NULL || flg == NULL) | 11074 if (str == NULL || pat == NULL || (sub == NULL && expr == NULL) |
11075 || flg == NULL) | |
11069 rettv->vval.v_string = NULL; | 11076 rettv->vval.v_string = NULL; |
11070 else | 11077 else |
11071 rettv->vval.v_string = do_string_sub(str, pat, sub, flg); | 11078 rettv->vval.v_string = do_string_sub(str, pat, sub, expr, flg); |
11072 } | 11079 } |
11073 | 11080 |
11074 /* | 11081 /* |
11075 * "synID(lnum, col, trans)" function | 11082 * "synID(lnum, col, trans)" function |
11076 */ | 11083 */ |