mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:8.1.1933: the eval.c file is too big (#19462)
Problem: The eval.c file is too big.
Solution: Move code related to variables to evalvars.c. (Yegappan
Lakshmanan, closes vim/vim#4868)
0522ba0359
Name the new file eval/vars.c instead.
This commit is contained in:
parent
bb7853a62d
commit
9d4a4f49ef
@ -229,6 +229,10 @@ preprocess_patch() {
|
||||
LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/evalfunc\.c/\1\/eval\/funcs\.c/g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
|
||||
# Rename evalvars.c to eval/vars.c
|
||||
LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/evalfunc\.c/\1\/eval\/vars\.c/g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
|
||||
# Rename userfunc.c to eval/userfunc.c
|
||||
LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/userfunc\.c/\1\/eval\/userfunc\.c/g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nvim/edit.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/fileio.h"
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nvim/diff.h"
|
||||
#include "nvim/digraph.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
|
1661
src/nvim/eval.c
1661
src/nvim/eval.c
File diff suppressed because it is too large
Load Diff
@ -12,8 +12,6 @@
|
||||
# include "eval/executor.c.generated.h"
|
||||
#endif
|
||||
|
||||
static char *e_letwrong = N_("E734: Wrong variable type for %s=");
|
||||
|
||||
char *e_listidx = N_("E684: list index out of range: %" PRId64);
|
||||
|
||||
/// Handle tv1 += tv2, -=, *=, /=, %=, .=
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nvim/eval/funcs.h"
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/file_search.h"
|
||||
@ -3707,50 +3708,6 @@ static void f_gettabinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
}
|
||||
|
||||
/// "gettabvar()" function
|
||||
static void f_gettabvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
bool done = false;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
|
||||
const char *const varname = tv_get_string_chk(&argvars[1]);
|
||||
tabpage_T *const tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
|
||||
if (tp != NULL && varname != NULL) {
|
||||
// Set tp to be our tabpage, temporarily. Also set the window to the
|
||||
// first window in the tabpage, otherwise the window is not valid.
|
||||
win_T *const window = tp == curtab || tp->tp_firstwin == NULL
|
||||
? firstwin
|
||||
: tp->tp_firstwin;
|
||||
switchwin_T switchwin;
|
||||
if (switch_win(&switchwin, window, tp, true) == OK) {
|
||||
// look up the variable
|
||||
// Let gettabvar({nr}, "") return the "t:" dictionary.
|
||||
const dictitem_T *const v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't',
|
||||
varname, strlen(varname),
|
||||
false);
|
||||
if (v != NULL) {
|
||||
tv_copy(&v->di_tv, rettv);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
// restore previous notion of curwin
|
||||
restore_win(&switchwin, true);
|
||||
}
|
||||
|
||||
if (!done && argvars[2].v_type != VAR_UNKNOWN) {
|
||||
tv_copy(&argvars[2], rettv);
|
||||
}
|
||||
}
|
||||
|
||||
/// "gettabwinvar()" function
|
||||
static void f_gettabwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
getwinvar(argvars, rettv, 1);
|
||||
}
|
||||
|
||||
/// "gettagstack()" function
|
||||
static void f_gettagstack(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
@ -3974,12 +3931,6 @@ static void f_getwinposy(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
rettv->vval.v_number = -1;
|
||||
}
|
||||
|
||||
/// "getwinvar()" function
|
||||
static void f_getwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
getwinvar(argvars, rettv, 0);
|
||||
}
|
||||
|
||||
/// "glob()" function
|
||||
static void f_glob(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
@ -8856,43 +8807,6 @@ free_lstval:
|
||||
}
|
||||
}
|
||||
|
||||
/// "settabvar()" function
|
||||
static void f_settabvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
rettv->vval.v_number = 0;
|
||||
|
||||
if (check_secure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
tabpage_T *const tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
|
||||
const char *const varname = tv_get_string_chk(&argvars[1]);
|
||||
typval_T *const varp = &argvars[2];
|
||||
|
||||
if (varname != NULL && tp != NULL) {
|
||||
tabpage_T *const save_curtab = curtab;
|
||||
goto_tabpage_tp(tp, false, false);
|
||||
|
||||
const size_t varname_len = strlen(varname);
|
||||
char *const tabvarname = xmalloc(varname_len + 3);
|
||||
memcpy(tabvarname, "t:", 2);
|
||||
memcpy(tabvarname + 2, varname, varname_len + 1);
|
||||
set_var(tabvarname, varname_len + 2, varp, true);
|
||||
xfree(tabvarname);
|
||||
|
||||
// Restore current tabpage.
|
||||
if (valid_tabpage(save_curtab)) {
|
||||
goto_tabpage_tp(save_curtab, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// "settabwinvar()" function
|
||||
static void f_settabwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
setwinvar(argvars, rettv, 1);
|
||||
}
|
||||
|
||||
/// "settagstack()" function
|
||||
static void f_settagstack(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
@ -8946,12 +8860,6 @@ static void f_settagstack(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
}
|
||||
|
||||
/// "setwinvar()" function
|
||||
static void f_setwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
setwinvar(argvars, rettv, 0);
|
||||
}
|
||||
|
||||
/// f_sha256 - sha256({string}) function
|
||||
static void f_sha256(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/eval/typval_encode.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/gettext.h"
|
||||
#include "nvim/globals.h"
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/encode.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
|
1715
src/nvim/eval/vars.c
Normal file
1715
src/nvim/eval/vars.c
Normal file
File diff suppressed because it is too large
Load Diff
10
src/nvim/eval/vars.h
Normal file
10
src/nvim/eval/vars.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef NVIM_EVAL_VARS_H
|
||||
#define NVIM_EVAL_VARS_H
|
||||
|
||||
#include "nvim/eval/funcs.h" // For FunPtr
|
||||
#include "nvim/ex_cmds_defs.h" // For exarg_T
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "eval/vars.h.generated.h"
|
||||
#endif
|
||||
#endif // NVIM_EVAL_VARS_H
|
@ -24,6 +24,7 @@
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/debugger.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_eval.h"
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "nvim/edit.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/userfunc.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/event/rstream.h"
|
||||
#include "nvim/event/wstream.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
|
@ -941,6 +941,9 @@ EXTERN char e_loclist[] INIT(= N_("E776: No location list"));
|
||||
EXTERN char e_re_damg[] INIT(= N_("E43: Damaged match string"));
|
||||
EXTERN char e_re_corr[] INIT(= N_("E44: Corrupted regexp program"));
|
||||
EXTERN char e_readonly[] INIT(= N_("E45: 'readonly' option is set (add ! to override)"));
|
||||
EXTERN char e_letwrong[] INIT(= N_("E734: Wrong variable type for %s="));
|
||||
EXTERN char e_illvar[] INIT(= N_("E461: Illegal variable name: %s"));
|
||||
EXTERN char e_cannot_mod[] INIT(= N_("E995: Cannot modify existing variable"));
|
||||
EXTERN char e_readonlyvar[] INIT(= N_("E46: Cannot change read-only variable \"%.*s\""));
|
||||
EXTERN char e_stringreq[] INIT(= N_("E928: String required"));
|
||||
EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required"));
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nvim/autocmd.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/cursor_shape.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/fold.h"
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/highlight_group.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/edit.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/keycodes.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/message.h"
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nvim/edit.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/typval.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "nvim/charset.h"
|
||||
#include "nvim/cursor_shape.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/fileio.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nvim/diff.h"
|
||||
#include "nvim/edit.h"
|
||||
#include "nvim/eval.h"
|
||||
#include "nvim/eval/vars.h"
|
||||
#include "nvim/ex_cmds.h"
|
||||
#include "nvim/ex_cmds2.h"
|
||||
#include "nvim/ex_docmd.h"
|
||||
|
Loading…
Reference in New Issue
Block a user