1
0
forked from aniani/vim

patch 8.1.1981: the evalfunc.c file is too big

Problem:    The evalfunc.c file is too big.
Solution:   Move undo functions to undo.c.  Move cmdline functions to
            ex_getln.c.  Move some container functions to list.c.
This commit is contained in:
Bram Moolenaar
2019-09-04 17:48:15 +02:00
parent 0f63ed33fd
commit 08c308aeb5
8 changed files with 492 additions and 502 deletions

View File

@@ -3572,6 +3572,7 @@ curbufIsChanged(void)
}
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* For undotree(): Append the list of undo blocks at "first_uhp" to "list".
* Recursive.
@@ -3612,4 +3613,62 @@ u_eval_tree(u_header_T *first_uhp, list_T *list)
uhp = uhp->uh_prev.ptr;
}
}
/*
* "undofile(name)" function
*/
void
f_undofile(typval_T *argvars UNUSED, typval_T *rettv)
{
rettv->v_type = VAR_STRING;
#ifdef FEAT_PERSISTENT_UNDO
{
char_u *fname = tv_get_string(&argvars[0]);
if (*fname == NUL)
{
/* If there is no file name there will be no undo file. */
rettv->vval.v_string = NULL;
}
else
{
char_u *ffname = FullName_save(fname, TRUE);
if (ffname != NULL)
rettv->vval.v_string = u_get_undo_file_name(ffname, FALSE);
vim_free(ffname);
}
}
#else
rettv->vval.v_string = NULL;
#endif
}
/*
* "undotree()" function
*/
void
f_undotree(typval_T *argvars UNUSED, typval_T *rettv)
{
if (rettv_dict_alloc(rettv) == OK)
{
dict_T *dict = rettv->vval.v_dict;
list_T *list;
dict_add_number(dict, "synced", (long)curbuf->b_u_synced);
dict_add_number(dict, "seq_last", curbuf->b_u_seq_last);
dict_add_number(dict, "save_last", (long)curbuf->b_u_save_nr_last);
dict_add_number(dict, "seq_cur", curbuf->b_u_seq_cur);
dict_add_number(dict, "time_cur", (long)curbuf->b_u_time_cur);
dict_add_number(dict, "save_cur", (long)curbuf->b_u_save_nr_cur);
list = list_alloc();
if (list != NULL)
{
u_eval_tree(curbuf->b_u_oldhead, list);
dict_add_list(dict, "entries", list);
}
}
}
#endif