Skip to content

Commit

Permalink
patch 8.0.0345: islocked('d.changedtick') does not work
Browse files Browse the repository at this point in the history
Problem:    islocked('d.changedtick') does not work.
Solution:   Make it work.
  • Loading branch information
brammool committed Feb 21, 2017
1 parent 49439c4 commit 3a25773
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/buffer.c
Expand Up @@ -884,7 +884,7 @@ init_changedtick(buf_T *buf)

if (di != NULL)
{
di->di_flags |= DI_FLAGS_LOCK | DI_FLAGS_FIX | DI_FLAGS_RO;
di->di_flags |= DI_FLAGS_FIX | DI_FLAGS_RO;
di->di_tv.v_type = VAR_NUMBER;
di->di_tv.v_lock = VAR_FIXED;
di->di_tv.vval.v_number = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/eval.c
Expand Up @@ -1811,6 +1811,7 @@ ex_let_one(
*
* flags:
* GLV_QUIET: do not give error messages
* GLV_READ_ONLY: will not change the variable
* GLV_NO_AUTOLOAD: do not use script autoloading
*
* Returns a pointer to just after the name, including indexes.
Expand Down Expand Up @@ -2078,7 +2079,8 @@ get_lval(
break;
}
/* existing variable, need to check if it can be changed */
else if (var_check_ro(lp->ll_di->di_flags, name, FALSE))
else if ((flags & GLV_READ_ONLY) == 0
&& var_check_ro(lp->ll_di->di_flags, name, FALSE))
{
clear_tv(&var1);
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/evalfunc.c
Expand Up @@ -6561,7 +6561,7 @@ f_islocked(typval_T *argvars, typval_T *rettv)

rettv->vval.v_number = -1;
end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
GLV_NO_AUTOLOAD, FNE_CHECK_START);
GLV_NO_AUTOLOAD | GLV_READ_ONLY, FNE_CHECK_START);
if (end != NULL && lv.ll_name != NULL)
{
if (*end != NUL)
Expand Down
6 changes: 6 additions & 0 deletions src/testdir/test_changedtick.vim
Expand Up @@ -32,6 +32,12 @@ func Test_changedtick_bdel()
call assert_equal(v + 1, getbufvar(bnr, 'changedtick'))
endfunc

func Test_changedtick_islocked()
call assert_equal(0, islocked('b:changedtick'))
let d = b:
call assert_equal(0, islocked('d.changedtick'))
endfunc

func Test_changedtick_fixed()
call assert_fails('let b:changedtick = 4', 'E46:')
call assert_fails('let b:["changedtick"] = 4', 'E46:')
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -764,6 +764,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
345,
/**/
344,
/**/
Expand Down
2 changes: 2 additions & 0 deletions src/vim.h
Expand Up @@ -2474,10 +2474,12 @@ typedef enum {
#define TFN_QUIET 2 /* no error messages */
#define TFN_NO_AUTOLOAD 4 /* do not use script autoloading */
#define TFN_NO_DEREF 8 /* do not dereference a Funcref */
#define TFN_READ_ONLY 16 /* will not change the var */

/* Values for get_lval() flags argument: */
#define GLV_QUIET TFN_QUIET /* no error messages */
#define GLV_NO_AUTOLOAD TFN_NO_AUTOLOAD /* do not use script autoloading */
#define GLV_READ_ONLY TFN_READ_ONLY /* will not change the var */

#define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not
be freed. */
Expand Down

0 comments on commit 3a25773

Please sign in to comment.