diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-04-03 20:31:20 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-04-13 12:00:33 -0400 |
commit | 366e75b6be57220b28f2abc22add19d5df33b5a3 (patch) | |
tree | 4f25349d7bec857e0644c187037b2147a37783fe /src | |
parent | d74a28d716d2d65fe5b92a6366145f1edbfbdf07 (diff) | |
download | rneovim-366e75b6be57220b28f2abc22add19d5df33b5a3.tar.gz rneovim-366e75b6be57220b28f2abc22add19d5df33b5a3.tar.bz2 rneovim-366e75b6be57220b28f2abc22add19d5df33b5a3.zip |
vim-patch:8.2.0473: variables declared in an outer scope
Problem: Variables declared in an outer scope.
Solution: Decleare variables only in the scope where they are used.
https://github.com/vim/vim/commit/8601545338581c01e328cdc3a72c0b12d92c54cf
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/funcs.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index d97fba8992..8f16855d0b 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2807,11 +2807,12 @@ static void f_getbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr) buf_T *const buf = tv_get_buf(&argvars[0], false); if (buf != NULL && varname != NULL) { - // set curbuf to be our buf, temporarily - buf_T *const save_curbuf = curbuf; - curbuf = buf; - if (*varname == '&') { // buffer-local-option + buf_T *const save_curbuf = curbuf; + + // set curbuf to be our buf, temporarily + curbuf = buf; + if (varname[1] == NUL) { // get all buffer-local options in a dict dict_T *opts = get_winbuf_options(true); @@ -2824,19 +2825,19 @@ static void f_getbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr) // 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. - dictitem_T *const v = find_var_in_ht(&curbuf->b_vars->dv_hashtab, 'b', + dictitem_T *const v = find_var_in_ht(&buf->b_vars->dv_hashtab, 'b', varname, strlen(varname), false); if (v != NULL) { tv_copy(&v->di_tv, rettv); done = true; } } - - // restore previous notion of curbuf - curbuf = save_curbuf; } emsg_off--; @@ -7824,10 +7825,9 @@ static void f_setbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr) // reset notion of buffer aucmd_restbuf(&aco); } else { - buf_T *save_curbuf = curbuf; - const size_t varname_len = STRLEN(varname); char *const bufvarname = xmalloc(varname_len + 3); + buf_T *const save_curbuf = curbuf; curbuf = buf; memcpy(bufvarname, "b:", 2); memcpy(bufvarname + 2, varname, varname_len + 1); |