mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
eval: add const to f_gettabvar() variables
This commit is contained in:
parent
e6127a49db
commit
c233277737
@ -10210,25 +10210,26 @@ static void f_gettabinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
static void f_gettabvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_gettabvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
win_T *oldcurwin;
|
win_T *oldcurwin;
|
||||||
tabpage_T *tp, *oldtabpage;
|
tabpage_T *oldtabpage;
|
||||||
dictitem_T *v;
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = NULL;
|
rettv->vval.v_string = NULL;
|
||||||
|
|
||||||
const char *const varname = tv_get_string_chk(&argvars[1]);
|
const char *const varname = tv_get_string_chk(&argvars[1]);
|
||||||
tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
|
tabpage_T *const tp = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
|
||||||
if (tp != NULL && varname != NULL) {
|
if (tp != NULL && varname != NULL) {
|
||||||
// Set tp to be our tabpage, temporarily. Also set the window to the
|
// Set tp to be our tabpage, temporarily. Also set the window to the
|
||||||
// first window in the tabpage, otherwise the window is not valid.
|
// first window in the tabpage, otherwise the window is not valid.
|
||||||
win_T *window = tp == curtab || tp->tp_firstwin == NULL ? firstwin
|
win_T *const window = tp == curtab || tp->tp_firstwin == NULL
|
||||||
: tp->tp_firstwin;
|
? firstwin
|
||||||
|
: tp->tp_firstwin;
|
||||||
if (switch_win(&oldcurwin, &oldtabpage, window, tp, true) == OK) {
|
if (switch_win(&oldcurwin, &oldtabpage, window, tp, true) == OK) {
|
||||||
// look up the variable
|
// look up the variable
|
||||||
// Let gettabvar({nr}, "") return the "t:" dictionary.
|
// Let gettabvar({nr}, "") return the "t:" dictionary.
|
||||||
v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't',
|
const dictitem_T *const v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't',
|
||||||
varname, strlen(varname), false);
|
varname, strlen(varname),
|
||||||
|
false);
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
tv_copy(&v->di_tv, rettv);
|
tv_copy(&v->di_tv, rettv);
|
||||||
done = true;
|
done = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user