vim-patch:partial:8.1.1981: the evalfunc.c file is too big (#24490)

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.

08c308aeb5

Undo functions only. Cmdline functions have already been moved.
A lot of container functions have been added to eval/funcs.c instead of
list.c in previously ported Vim 8.2.x patches, so deal with that later.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2023-07-26 15:18:09 +08:00 committed by GitHub
parent 14d047ad2f
commit b8b7782037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 39 deletions

View File

@ -114,7 +114,6 @@
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/vim.h"
#include "nvim/window.h"
@ -8629,43 +8628,6 @@ static void f_type(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
rettv->vval.v_number = n;
}
/// "undofile(name)" function
static void f_undofile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
rettv->v_type = VAR_STRING;
const char *const 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 *ffname = FullName_save(fname, true);
if (ffname != NULL) {
rettv->vval.v_string = u_get_undo_file_name(ffname, false);
}
xfree(ffname);
}
}
/// "undotree()" function
static void f_undotree(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
tv_dict_alloc_ret(rettv);
dict_T *dict = rettv->vval.v_dict;
tv_dict_add_nr(dict, S_LEN("synced"), (varnumber_T)curbuf->b_u_synced);
tv_dict_add_nr(dict, S_LEN("seq_last"), (varnumber_T)curbuf->b_u_seq_last);
tv_dict_add_nr(dict, S_LEN("save_last"),
(varnumber_T)curbuf->b_u_save_nr_last);
tv_dict_add_nr(dict, S_LEN("seq_cur"), (varnumber_T)curbuf->b_u_seq_cur);
tv_dict_add_nr(dict, S_LEN("time_cur"), (varnumber_T)curbuf->b_u_time_cur);
tv_dict_add_nr(dict, S_LEN("save_cur"), (varnumber_T)curbuf->b_u_save_nr_cur);
tv_dict_add_list(dict, S_LEN("entries"), u_eval_tree(curbuf->b_u_oldhead));
}
/// "virtcol(string, bool)" function
static void f_virtcol(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{

View File

@ -39,6 +39,7 @@ hashpipe:write([[
#include "nvim/strings.h"
#include "nvim/sign.h"
#include "nvim/testing.h"
#include "nvim/undo.h"
]])

View File

@ -3118,7 +3118,7 @@ bool curbufIsChanged(void)
/// @param[in] first_uhp Undo blocks list to start with.
///
/// @return [allocated] List with a representation of undo blocks.
list_T *u_eval_tree(const u_header_T *const first_uhp)
static list_T *u_eval_tree(const u_header_T *const first_uhp)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET
{
list_T *const list = tv_list_alloc(kListLenMayKnow);
@ -3148,6 +3148,42 @@ list_T *u_eval_tree(const u_header_T *const first_uhp)
return list;
}
/// "undofile(name)" function
void f_undofile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
rettv->v_type = VAR_STRING;
const char *const 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 *ffname = FullName_save(fname, true);
if (ffname != NULL) {
rettv->vval.v_string = u_get_undo_file_name(ffname, false);
}
xfree(ffname);
}
}
/// "undotree()" function
void f_undotree(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
tv_dict_alloc_ret(rettv);
dict_T *dict = rettv->vval.v_dict;
tv_dict_add_nr(dict, S_LEN("synced"), (varnumber_T)curbuf->b_u_synced);
tv_dict_add_nr(dict, S_LEN("seq_last"), (varnumber_T)curbuf->b_u_seq_last);
tv_dict_add_nr(dict, S_LEN("save_last"), (varnumber_T)curbuf->b_u_save_nr_last);
tv_dict_add_nr(dict, S_LEN("seq_cur"), (varnumber_T)curbuf->b_u_seq_cur);
tv_dict_add_nr(dict, S_LEN("time_cur"), (varnumber_T)curbuf->b_u_time_cur);
tv_dict_add_nr(dict, S_LEN("save_cur"), (varnumber_T)curbuf->b_u_save_nr_cur);
tv_dict_add_list(dict, S_LEN("entries"), u_eval_tree(curbuf->b_u_oldhead));
}
// Given the buffer, Return the undo header. If none is set, set one first.
// NULL will be returned if e.g undolevels = -1 (undo disabled)
u_header_T *u_force_get_undo_header(buf_T *buf)