comparison src/eval.c @ 6197:4176c48c7dd5 v7.4.434

updated for version 7.4.434 Problem: gettabvar() is not consistent with getwinvar() and getbufvar(). Solution: Return a dict with all variables when the varname is empty. (Yasuhiro Matsumoto)
author Bram Moolenaar <bram@vim.org>
date Tue, 09 Sep 2014 16:13:08 +0200
parents fca35aa9380a
children 8c3c067b4ae3
comparison
equal deleted inserted replaced
6196:01350c53b37d 6197:4176c48c7dd5
12069 static void 12069 static void
12070 f_gettabvar(argvars, rettv) 12070 f_gettabvar(argvars, rettv)
12071 typval_T *argvars; 12071 typval_T *argvars;
12072 typval_T *rettv; 12072 typval_T *rettv;
12073 { 12073 {
12074 tabpage_T *tp; 12074 win_T *win, *oldcurwin;
12075 tabpage_T *tp, *oldtabpage;
12075 dictitem_T *v; 12076 dictitem_T *v;
12076 char_u *varname; 12077 char_u *varname;
12077 int done = FALSE; 12078 int done = FALSE;
12078 12079
12079 rettv->v_type = VAR_STRING; 12080 rettv->v_type = VAR_STRING;
12081 12082
12082 varname = get_tv_string_chk(&argvars[1]); 12083 varname = get_tv_string_chk(&argvars[1]);
12083 tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL)); 12084 tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL));
12084 if (tp != NULL && varname != NULL) 12085 if (tp != NULL && varname != NULL)
12085 { 12086 {
12087 /* Set curwin to be our win, temporarily. Also set the tabpage,
12088 * otherwise the window is not valid. */
12089 switch_win(&oldcurwin, &oldtabpage, win, tp, TRUE);
12090
12086 /* look up the variable */ 12091 /* look up the variable */
12087 v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 0, varname, FALSE); 12092 /* Let gettabvar({nr}, "") return the "t:" dictionary. */
12093 v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 't', varname, FALSE);
12088 if (v != NULL) 12094 if (v != NULL)
12089 { 12095 {
12090 copy_tv(&v->di_tv, rettv); 12096 copy_tv(&v->di_tv, rettv);
12091 done = TRUE; 12097 done = TRUE;
12092 } 12098 }
12099
12100 /* restore previous notion of curwin */
12101 restore_win(oldcurwin, oldtabpage, TRUE);
12093 } 12102 }
12094 12103
12095 if (!done && argvars[2].v_type != VAR_UNKNOWN) 12104 if (!done && argvars[2].v_type != VAR_UNKNOWN)
12096 copy_tv(&argvars[2], rettv); 12105 copy_tv(&argvars[2], rettv);
12097 } 12106 }