forked from aniani/vim
patch 7.4.2090
Problem: Using submatch() in a lambda passed to substitute() is verbose. Solution: Use a static list and pass it as an optional argument to the function. Fix memory leak.
This commit is contained in:
@@ -480,7 +480,7 @@ get_func_tv(
|
||||
&argvars[i];
|
||||
}
|
||||
|
||||
ret = call_func(name, len, rettv, argcount, argvars,
|
||||
ret = call_func(name, len, rettv, argcount, argvars, NULL,
|
||||
firstline, lastline, doesrange, evaluate, partial, selfdict);
|
||||
|
||||
funcargs.ga_len -= i;
|
||||
@@ -1139,7 +1139,7 @@ func_call(
|
||||
}
|
||||
|
||||
if (item == NULL)
|
||||
r = call_func(name, (int)STRLEN(name), rettv, argc, argv,
|
||||
r = call_func(name, (int)STRLEN(name), rettv, argc, argv, NULL,
|
||||
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
||||
&dummy, TRUE, partial, selfdict);
|
||||
|
||||
@@ -1152,6 +1152,11 @@ func_call(
|
||||
|
||||
/*
|
||||
* Call a function with its resolved parameters
|
||||
*
|
||||
* "argv_func", when not NULL, can be used to fill in arguments only when the
|
||||
* invoked function uses them. It is called like this:
|
||||
* new_argcount = argv_func(current_argcount, argv, called_func_argcount)
|
||||
*
|
||||
* Return FAIL when the function can't be called, OK otherwise.
|
||||
* Also returns OK when an error was encountered while executing the function.
|
||||
*/
|
||||
@@ -1163,6 +1168,8 @@ call_func(
|
||||
int argcount_in, /* number of "argvars" */
|
||||
typval_T *argvars_in, /* vars for arguments, must have "argcount"
|
||||
PLUS ONE elements! */
|
||||
int (* argv_func)(int, typval_T *, int),
|
||||
/* function to fill in argvars */
|
||||
linenr_T firstline, /* first line of range */
|
||||
linenr_T lastline, /* last line of range */
|
||||
int *doesrange, /* return: function handled range */
|
||||
@@ -1254,6 +1261,9 @@ call_func(
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
if (argv_func != NULL)
|
||||
argcount = argv_func(argcount, argvars, fp->uf_args.ga_len);
|
||||
|
||||
if (fp->uf_flags & FC_RANGE)
|
||||
*doesrange = TRUE;
|
||||
if (argcount < fp->uf_args.ga_len)
|
||||
|
Reference in New Issue
Block a user