Patch 8.2.0473

8 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 29, 2020, 9:12:53 AM3/29/20
to vim...@googlegroups.com

Patch 8.2.0473
Problem: Variables declared in an outer scope.
Solution: Decleare variables only in the scope where they are used.
Files: src/evalvars.c


*** ../vim-8.2.0472/src/evalvars.c 2020-03-07 16:59:18.633666175 +0100
--- src/evalvars.c 2020-03-29 14:59:50.939067518 +0200
***************
*** 3461,3467 ****
f_getbufvar(typval_T *argvars, typval_T *rettv)
{
buf_T *buf;
- buf_T *save_curbuf;
char_u *varname;
dictitem_T *v;
int done = FALSE;
--- 3461,3466 ----
***************
*** 3476,3487 ****

if (buf != NULL && varname != NULL)
{
- // set curbuf to be our buf, temporarily
- save_curbuf = curbuf;
- curbuf = buf;
-
if (*varname == '&')
{
if (varname[1] == NUL)
{
// get all buffer-local options in a dict
--- 3475,3487 ----

if (buf != NULL && varname != NULL)
{
if (*varname == '&')
{
+ buf_T *save_curbuf = curbuf;
+
+ // set curbuf to be our buf, temporarily
+ curbuf = buf;
+
if (varname[1] == NUL)
{
// get all buffer-local options in a dict
***************
*** 3496,3517 ****
else if (get_option_tv(&varname, rettv, TRUE) == OK)
// buffer-local-option
done = TRUE;
}
else
{
// Look up the variable.
// Let getbufvar({nr}, "") return the "b:" dictionary.
! v = find_var_in_ht(&curbuf->b_vars->dv_hashtab,
! 'b', varname, FALSE);
if (v != NULL)
{
copy_tv(&v->di_tv, rettv);
done = TRUE;
}
}
-
- // restore previous notion of curbuf
- curbuf = save_curbuf;
}

if (!done && argvars[2].v_type != VAR_UNKNOWN)
--- 3496,3516 ----
else if (get_option_tv(&varname, rettv, TRUE) == OK)
// buffer-local-option
done = TRUE;
+
+ // restore previous notion of curbuf
+ curbuf = save_curbuf;
}
else
{
// Look up the variable.
// Let getbufvar({nr}, "") return the "b:" dictionary.
! v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', varname, FALSE);
if (v != NULL)
{
copy_tv(&v->di_tv, rettv);
done = TRUE;
}
}
}

if (!done && argvars[2].v_type != VAR_UNKNOWN)
***************
*** 3618,3628 ****
}
else
{
- buf_T *save_curbuf = curbuf;
-
bufvarname = alloc(STRLEN(varname) + 3);
if (bufvarname != NULL)
{
curbuf = buf;
STRCPY(bufvarname, "b:");
STRCPY(bufvarname + 2, varname);
--- 3617,3627 ----
}
else
{
bufvarname = alloc(STRLEN(varname) + 3);
if (bufvarname != NULL)
{
+ buf_T *save_curbuf = curbuf;
+
curbuf = buf;
STRCPY(bufvarname, "b:");
STRCPY(bufvarname + 2, varname);
*** ../vim-8.2.0472/src/version.c 2020-03-28 22:37:10.141196670 +0100
--- src/version.c 2020-03-29 15:11:58.405519340 +0200
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 473,
/**/

--
There can't be a crisis today, my schedule is already full.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages