1
0
forked from aniani/vim

patch 8.2.0209: function a bit far away from where it's used

Problem:    Function a bit far away from where it's used.
Solution:   Move function close to where it's used. (Ken Takata, closes #5569)
This commit is contained in:
Bram Moolenaar
2020-02-04 22:32:59 +01:00
parent d816cd94d8
commit 80147dda4f
3 changed files with 42 additions and 40 deletions

View File

@@ -1255,41 +1255,6 @@ f_isdirectory(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = mch_isdir(tv_get_string(&argvars[0]));
}
/*
* Evaluate "expr" (= "context") for readdir().
*/
static int
readdir_checkitem(void *context, char_u *name)
{
typval_T *expr = (typval_T *)context;
typval_T save_val;
typval_T rettv;
typval_T argv[2];
int retval = 0;
int error = FALSE;
if (expr->v_type == VAR_UNKNOWN)
return 1;
prepare_vimvar(VV_VAL, &save_val);
set_vim_var_string(VV_VAL, name, -1);
argv[0].v_type = VAR_STRING;
argv[0].vval.v_string = name;
if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL)
goto theend;
retval = tv_get_number_chk(&rettv, &error);
if (error)
retval = -1;
clear_tv(&rettv);
theend:
set_vim_var_string(VV_VAL, NULL, 0);
restore_vimvar(VV_VAL, &save_val);
return retval;
}
/*
* Create the directory in which "dir" is located, and higher levels when
* needed.
@@ -1385,6 +1350,41 @@ f_pathshorten(typval_T *argvars, typval_T *rettv)
}
}
/*
* Evaluate "expr" (= "context") for readdir().
*/
static int
readdir_checkitem(void *context, char_u *name)
{
typval_T *expr = (typval_T *)context;
typval_T save_val;
typval_T rettv;
typval_T argv[2];
int retval = 0;
int error = FALSE;
if (expr->v_type == VAR_UNKNOWN)
return 1;
prepare_vimvar(VV_VAL, &save_val);
set_vim_var_string(VV_VAL, name, -1);
argv[0].v_type = VAR_STRING;
argv[0].vval.v_string = name;
if (eval_expr_typval(expr, argv, 1, &rettv) == FAIL)
goto theend;
retval = tv_get_number_chk(&rettv, &error);
if (error)
retval = -1;
clear_tv(&rettv);
theend:
set_vim_var_string(VV_VAL, NULL, 0);
restore_vimvar(VV_VAL, &save_val);
return retval;
}
/*
* "readdir()" function
*/