updated for version 7.0106
diff --git a/src/edit.c b/src/edit.c
index 25d4b58..7028dd3 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -2683,7 +2683,7 @@
args[1] = base;
args[2] = colbuf;
args[3] = (char_u *)(preproc ? "1" : "0");
- return call_vim_function(curbuf->b_p_cfu, 4, args, FALSE);
+ return (char_u *)call_func_retstr(curbuf->b_p_cfu, 4, args, FALSE);
}
/*
diff --git a/src/eval.c b/src/eval.c
index c176226..2b6703a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1272,28 +1272,29 @@
#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
/*
- * Call some vimL function and return the result as a string
+ * Call some vimL function and return the result in "*rettv".
* Uses argv[argc] for the function arguments.
+ * Returns OK or FAIL.
*/
- char_u *
-call_vim_function(func, argc, argv, safe)
+ static int
+call_vim_function(func, argc, argv, safe, rettv)
char_u *func;
int argc;
char_u **argv;
int safe; /* use the sandbox */
+ typval_T *rettv;
{
- char_u *retval = NULL;
- typval_T rettv;
typval_T *argvars;
long n;
int len;
int i;
int doesrange;
void *save_funccalp = NULL;
+ int ret;
argvars = (typval_T *)alloc((unsigned)(argc * sizeof(typval_T)));
if (argvars == NULL)
- return NULL;
+ return FAIL;
for (i = 0; i < argc; i++)
{
@@ -1325,22 +1326,72 @@
++sandbox;
}
- rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
- if (call_func(func, (int)STRLEN(func), &rettv, argc, argvars,
+ rettv->v_type = VAR_UNKNOWN; /* clear_tv() uses this */
+ ret = call_func(func, (int)STRLEN(func), rettv, argc, argvars,
curwin->w_cursor.lnum, curwin->w_cursor.lnum,
- &doesrange, TRUE, NULL) == OK)
- retval = vim_strsave(get_tv_string(&rettv));
-
- clear_tv(&rettv);
- vim_free(argvars);
-
+ &doesrange, TRUE, NULL);
if (safe)
{
--sandbox;
restore_funccal(save_funccalp);
}
+ vim_free(argvars);
+
+ if (ret == FAIL)
+ clear_tv(rettv);
+
+ return ret;
+}
+
+/*
+ * Call some vimL function and return the result as a string
+ * Uses argv[argc] for the function arguments.
+ */
+ void *
+call_func_retstr(func, argc, argv, safe)
+ char_u *func;
+ int argc;
+ char_u **argv;
+ int safe; /* use the sandbox */
+{
+ typval_T rettv;
+ char_u *retval = NULL;
+
+ if (call_vim_function(func, argc, argv, safe, &rettv) == FAIL)
+ return NULL;
+
+ retval = vim_strsave(get_tv_string(&rettv));
+
+ clear_tv(&rettv);
+
return retval;
}
+
+/*
+ * Call some vimL function and return the result as a list
+ * Uses argv[argc] for the function arguments.
+ */
+ void *
+call_func_retlist(func, argc, argv, safe)
+ char_u *func;
+ int argc;
+ char_u **argv;
+ int safe; /* use the sandbox */
+{
+ typval_T rettv;
+
+ if (call_vim_function(func, argc, argv, safe, &rettv) == FAIL)
+ return NULL;
+
+ if (rettv.v_type != VAR_LIST)
+ {
+ clear_tv(&rettv);
+ return NULL;
+ }
+
+ return rettv.vval.v_list;
+}
+
#endif
/*
@@ -1640,7 +1691,7 @@
{
/* "[var, var]": find the matching ']'. */
p = arg;
- while (1)
+ for (;;)
{
p = skipwhite(p + 1); /* skip whites after '[', ';' or ',' */
s = skip_var_one(p);
@@ -11315,7 +11366,7 @@
{
regmatch.rm_ic = p_ic;
- while (1)
+ for (;;)
{
if (l != NULL)
{
@@ -11472,7 +11523,7 @@
if (li != NULL)
{
n = get_tv_number_chk(&li->li_tv, &error);
- while (1)
+ for (;;)
{
li = li->li_next;
if (li == NULL)
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 1b99caf..9ce1fdd 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3562,7 +3562,7 @@
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
State |= LANGMAP;
- while (1)
+ for (;;)
{
msg_scroll = TRUE;
need_wait_return = FALSE;
diff --git a/src/misc1.c b/src/misc1.c
index fcc8726..9154b96 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5158,7 +5158,7 @@
linenr_T lnum = *lnump;
int retval = FALSE;
- while (1)
+ for (;;)
{
if (cin_ispreproc(line))
{
diff --git a/src/search.c b/src/search.c
index 20745d9..034d9c4 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3745,7 +3745,7 @@
{
int c;
- while (1)
+ for (;;)
{
c = line[col];
if (c == NUL)
@@ -3886,7 +3886,7 @@
* Also do this when there is a Visual area, a' may leave the cursor
* in between two strings. */
col_start = 0;
- while (1)
+ for (;;)
{
/* Find open quote character. */
col_start = find_next_quote(line, col_start, quotechar, NULL);