From 08c308aeb5e7dfa18fa61f261b0bff79517a4883 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 4 Sep 2019 17:48:15 +0200 Subject: 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. --- src/undo.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'src/undo.c') diff --git a/src/undo.c b/src/undo.c index b9c203ce2..e6bce43c2 100644 --- a/src/undo.c +++ b/src/undo.c @@ -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 -- cgit v1.2.1