|
Karsten Hopp |
4c9a90 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
4c9a90 |
Subject: Patch 7.3.898
|
|
Karsten Hopp |
4c9a90 |
Fcc: outbox
|
|
Karsten Hopp |
4c9a90 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
4c9a90 |
Mime-Version: 1.0
|
|
Karsten Hopp |
4c9a90 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
4c9a90 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
4c9a90 |
------------
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
Patch 7.3.898
|
|
Karsten Hopp |
4c9a90 |
Problem: Memory leak reported by valgrind in test 91.
|
|
Karsten Hopp |
4c9a90 |
Solution: Only use default argument when needed.
|
|
Karsten Hopp |
4c9a90 |
Files: src/eval.c, src/testdir/test91.in, src/testdir/test91.ok
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
*** ../vim-7.3.897/src/eval.c 2013-04-15 13:06:15.000000000 +0200
|
|
Karsten Hopp |
4c9a90 |
--- src/eval.c 2013-04-15 15:09:17.000000000 +0200
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11120,11139 ****
|
|
Karsten Hopp |
4c9a90 |
buf_T *save_curbuf;
|
|
Karsten Hopp |
4c9a90 |
char_u *varname;
|
|
Karsten Hopp |
4c9a90 |
dictitem_T *v;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
(void)get_tv_number(&argvars[0]); /* issue errmsg if type error */
|
|
Karsten Hopp |
4c9a90 |
varname = get_tv_string_chk(&argvars[1]);
|
|
Karsten Hopp |
4c9a90 |
++emsg_off;
|
|
Karsten Hopp |
4c9a90 |
buf = get_buf_tv(&argvars[0], FALSE);
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
! if (argvars[2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
! /* set the default value */
|
|
Karsten Hopp |
4c9a90 |
! copy_tv(&argvars[2], rettv);
|
|
Karsten Hopp |
4c9a90 |
! else
|
|
Karsten Hopp |
4c9a90 |
! {
|
|
Karsten Hopp |
4c9a90 |
! rettv->v_type = VAR_STRING;
|
|
Karsten Hopp |
4c9a90 |
! rettv->vval.v_string = NULL;
|
|
Karsten Hopp |
4c9a90 |
! }
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (buf != NULL && varname != NULL)
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
--- 11120,11134 ----
|
|
Karsten Hopp |
4c9a90 |
buf_T *save_curbuf;
|
|
Karsten Hopp |
4c9a90 |
char_u *varname;
|
|
Karsten Hopp |
4c9a90 |
dictitem_T *v;
|
|
Karsten Hopp |
4c9a90 |
+ int done = FALSE;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
(void)get_tv_number(&argvars[0]); /* issue errmsg if type error */
|
|
Karsten Hopp |
4c9a90 |
varname = get_tv_string_chk(&argvars[1]);
|
|
Karsten Hopp |
4c9a90 |
++emsg_off;
|
|
Karsten Hopp |
4c9a90 |
buf = get_buf_tv(&argvars[0], FALSE);
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
! rettv->v_type = VAR_STRING;
|
|
Karsten Hopp |
4c9a90 |
! rettv->vval.v_string = NULL;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (buf != NULL && varname != NULL)
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11142,11152 ****
|
|
Karsten Hopp |
4c9a90 |
curbuf = buf;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (*varname == '&') /* buffer-local-option */
|
|
Karsten Hopp |
4c9a90 |
! get_option_tv(&varname, rettv, TRUE);
|
|
Karsten Hopp |
4c9a90 |
else if (STRCMP(varname, "changedtick") == 0)
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
rettv->v_type = VAR_NUMBER;
|
|
Karsten Hopp |
4c9a90 |
rettv->vval.v_number = curbuf->b_changedtick;
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
else
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
--- 11137,11151 ----
|
|
Karsten Hopp |
4c9a90 |
curbuf = buf;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (*varname == '&') /* buffer-local-option */
|
|
Karsten Hopp |
4c9a90 |
! {
|
|
Karsten Hopp |
4c9a90 |
! if (get_option_tv(&varname, rettv, TRUE) == OK)
|
|
Karsten Hopp |
4c9a90 |
! done = TRUE;
|
|
Karsten Hopp |
4c9a90 |
! }
|
|
Karsten Hopp |
4c9a90 |
else if (STRCMP(varname, "changedtick") == 0)
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
rettv->v_type = VAR_NUMBER;
|
|
Karsten Hopp |
4c9a90 |
rettv->vval.v_number = curbuf->b_changedtick;
|
|
Karsten Hopp |
4c9a90 |
+ done = TRUE;
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
else
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11155,11167 ****
|
|
Karsten Hopp |
4c9a90 |
--- 11154,11173 ----
|
|
Karsten Hopp |
4c9a90 |
v = find_var_in_ht(&curbuf->b_vars->dv_hashtab,
|
|
Karsten Hopp |
4c9a90 |
'b', varname, FALSE);
|
|
Karsten Hopp |
4c9a90 |
if (v != NULL)
|
|
Karsten Hopp |
4c9a90 |
+ {
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&v->di_tv, rettv);
|
|
Karsten Hopp |
4c9a90 |
+ done = TRUE;
|
|
Karsten Hopp |
4c9a90 |
+ }
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
/* restore previous notion of curbuf */
|
|
Karsten Hopp |
4c9a90 |
curbuf = save_curbuf;
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
+ if (!done && argvars[2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
+ /* use the default value */
|
|
Karsten Hopp |
4c9a90 |
+ copy_tv(&argvars[2], rettv);
|
|
Karsten Hopp |
4c9a90 |
+
|
|
Karsten Hopp |
4c9a90 |
--emsg_off;
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11767,11772 ****
|
|
Karsten Hopp |
4c9a90 |
--- 11773,11779 ----
|
|
Karsten Hopp |
4c9a90 |
tabpage_T *tp;
|
|
Karsten Hopp |
4c9a90 |
dictitem_T *v;
|
|
Karsten Hopp |
4c9a90 |
char_u *varname;
|
|
Karsten Hopp |
4c9a90 |
+ int done = FALSE;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
rettv->v_type = VAR_STRING;
|
|
Karsten Hopp |
4c9a90 |
rettv->vval.v_string = NULL;
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11778,11788 ****
|
|
Karsten Hopp |
4c9a90 |
/* look up the variable */
|
|
Karsten Hopp |
4c9a90 |
v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 0, varname, FALSE);
|
|
Karsten Hopp |
4c9a90 |
if (v != NULL)
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&v->di_tv, rettv);
|
|
Karsten Hopp |
4c9a90 |
! else if (argvars[2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
! copy_tv(&argvars[2], rettv);
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
! else if (argvars[2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&argvars[2], rettv);
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
--- 11785,11797 ----
|
|
Karsten Hopp |
4c9a90 |
/* look up the variable */
|
|
Karsten Hopp |
4c9a90 |
v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 0, varname, FALSE);
|
|
Karsten Hopp |
4c9a90 |
if (v != NULL)
|
|
Karsten Hopp |
4c9a90 |
+ {
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&v->di_tv, rettv);
|
|
Karsten Hopp |
4c9a90 |
! done = TRUE;
|
|
Karsten Hopp |
4c9a90 |
! }
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
!
|
|
Karsten Hopp |
4c9a90 |
! if (!done && argvars[2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&argvars[2], rettv);
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11894,11899 ****
|
|
Karsten Hopp |
4c9a90 |
--- 11903,11909 ----
|
|
Karsten Hopp |
4c9a90 |
char_u *varname;
|
|
Karsten Hopp |
4c9a90 |
dictitem_T *v;
|
|
Karsten Hopp |
4c9a90 |
tabpage_T *tp;
|
|
Karsten Hopp |
4c9a90 |
+ int done = FALSE;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
#ifdef FEAT_WINDOWS
|
|
Karsten Hopp |
4c9a90 |
if (off == 1)
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11905,11918 ****
|
|
Karsten Hopp |
4c9a90 |
varname = get_tv_string_chk(&argvars[off + 1]);
|
|
Karsten Hopp |
4c9a90 |
++emsg_off;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
! if (argvars[off + 2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
! /* set the default return value */
|
|
Karsten Hopp |
4c9a90 |
! copy_tv(&argvars[off + 2], rettv);
|
|
Karsten Hopp |
4c9a90 |
! else
|
|
Karsten Hopp |
4c9a90 |
! {
|
|
Karsten Hopp |
4c9a90 |
! rettv->v_type = VAR_STRING;
|
|
Karsten Hopp |
4c9a90 |
! rettv->vval.v_string = NULL;
|
|
Karsten Hopp |
4c9a90 |
! }
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (win != NULL && varname != NULL)
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
--- 11915,11922 ----
|
|
Karsten Hopp |
4c9a90 |
varname = get_tv_string_chk(&argvars[off + 1]);
|
|
Karsten Hopp |
4c9a90 |
++emsg_off;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
! rettv->v_type = VAR_STRING;
|
|
Karsten Hopp |
4c9a90 |
! rettv->vval.v_string = NULL;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (win != NULL && varname != NULL)
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11923,11936 ****
|
|
Karsten Hopp |
4c9a90 |
curbuf = win->w_buffer;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (*varname == '&') /* window-local-option */
|
|
Karsten Hopp |
4c9a90 |
! get_option_tv(&varname, rettv, 1);
|
|
Karsten Hopp |
4c9a90 |
else
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
/* Look up the variable. */
|
|
Karsten Hopp |
4c9a90 |
/* Let getwinvar({nr}, "") return the "w:" dictionary. */
|
|
Karsten Hopp |
4c9a90 |
v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w', varname, FALSE);
|
|
Karsten Hopp |
4c9a90 |
if (v != NULL)
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&v->di_tv, rettv);
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
/* restore previous notion of curwin */
|
|
Karsten Hopp |
4c9a90 |
--- 11927,11946 ----
|
|
Karsten Hopp |
4c9a90 |
curbuf = win->w_buffer;
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
if (*varname == '&') /* window-local-option */
|
|
Karsten Hopp |
4c9a90 |
! {
|
|
Karsten Hopp |
4c9a90 |
! if (get_option_tv(&varname, rettv, 1) == OK)
|
|
Karsten Hopp |
4c9a90 |
! done = TRUE;
|
|
Karsten Hopp |
4c9a90 |
! }
|
|
Karsten Hopp |
4c9a90 |
else
|
|
Karsten Hopp |
4c9a90 |
{
|
|
Karsten Hopp |
4c9a90 |
/* Look up the variable. */
|
|
Karsten Hopp |
4c9a90 |
/* Let getwinvar({nr}, "") return the "w:" dictionary. */
|
|
Karsten Hopp |
4c9a90 |
v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w', varname, FALSE);
|
|
Karsten Hopp |
4c9a90 |
if (v != NULL)
|
|
Karsten Hopp |
4c9a90 |
+ {
|
|
Karsten Hopp |
4c9a90 |
copy_tv(&v->di_tv, rettv);
|
|
Karsten Hopp |
4c9a90 |
+ done = TRUE;
|
|
Karsten Hopp |
4c9a90 |
+ }
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
/* restore previous notion of curwin */
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 11938,11943 ****
|
|
Karsten Hopp |
4c9a90 |
--- 11948,11957 ----
|
|
Karsten Hopp |
4c9a90 |
curbuf = curwin->w_buffer;
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
+ if (!done && argvars[off + 2].v_type != VAR_UNKNOWN)
|
|
Karsten Hopp |
4c9a90 |
+ /* use the default return value */
|
|
Karsten Hopp |
4c9a90 |
+ copy_tv(&argvars[off + 2], rettv);
|
|
Karsten Hopp |
4c9a90 |
+
|
|
Karsten Hopp |
4c9a90 |
--emsg_off;
|
|
Karsten Hopp |
4c9a90 |
}
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
*** ../vim-7.3.897/src/testdir/test91.in 2013-02-20 21:11:14.000000000 +0100
|
|
Karsten Hopp |
4c9a90 |
--- src/testdir/test91.in 2013-04-15 14:59:31.000000000 +0200
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 4,12 ****
|
|
Karsten Hopp |
4c9a90 |
STARTTEST
|
|
Karsten Hopp |
4c9a90 |
:so small.vim
|
|
Karsten Hopp |
4c9a90 |
:"
|
|
Karsten Hopp |
4c9a90 |
! :" test for getbufvar()
|
|
Karsten Hopp |
4c9a90 |
! :let b:var_num = 1234
|
|
Karsten Hopp |
4c9a90 |
! :let def_num = 5678
|
|
Karsten Hopp |
4c9a90 |
:$put =string(getbufvar(1, 'var_num'))
|
|
Karsten Hopp |
4c9a90 |
:$put =string(getbufvar(1, 'var_num', def_num))
|
|
Karsten Hopp |
4c9a90 |
:$put =string(getbufvar(1, ''))
|
|
Karsten Hopp |
4c9a90 |
--- 4,13 ----
|
|
Karsten Hopp |
4c9a90 |
STARTTEST
|
|
Karsten Hopp |
4c9a90 |
:so small.vim
|
|
Karsten Hopp |
4c9a90 |
:"
|
|
Karsten Hopp |
4c9a90 |
! :" Test for getbufvar()
|
|
Karsten Hopp |
4c9a90 |
! :" Use strings to test for memory leaks.
|
|
Karsten Hopp |
4c9a90 |
! :let b:var_num = '1234'
|
|
Karsten Hopp |
4c9a90 |
! :let def_num = '5678'
|
|
Karsten Hopp |
4c9a90 |
:$put =string(getbufvar(1, 'var_num'))
|
|
Karsten Hopp |
4c9a90 |
:$put =string(getbufvar(1, 'var_num', def_num))
|
|
Karsten Hopp |
4c9a90 |
:$put =string(getbufvar(1, ''))
|
|
Karsten Hopp |
4c9a90 |
*** ../vim-7.3.897/src/testdir/test91.ok 2013-02-20 21:11:14.000000000 +0100
|
|
Karsten Hopp |
4c9a90 |
--- src/testdir/test91.ok 2013-04-15 15:02:45.000000000 +0200
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 1,13 ****
|
|
Karsten Hopp |
4c9a90 |
start:
|
|
Karsten Hopp |
4c9a90 |
! 1234
|
|
Karsten Hopp |
4c9a90 |
! 1234
|
|
Karsten Hopp |
4c9a90 |
! {'var_num': 1234}
|
|
Karsten Hopp |
4c9a90 |
! {'var_num': 1234}
|
|
Karsten Hopp |
4c9a90 |
! 5678
|
|
Karsten Hopp |
4c9a90 |
{}
|
|
Karsten Hopp |
4c9a90 |
{}
|
|
Karsten Hopp |
4c9a90 |
''
|
|
Karsten Hopp |
4c9a90 |
! 5678
|
|
Karsten Hopp |
4c9a90 |
0
|
|
Karsten Hopp |
4c9a90 |
0
|
|
Karsten Hopp |
4c9a90 |
'Dance'
|
|
Karsten Hopp |
4c9a90 |
--- 1,13 ----
|
|
Karsten Hopp |
4c9a90 |
start:
|
|
Karsten Hopp |
4c9a90 |
! '1234'
|
|
Karsten Hopp |
4c9a90 |
! '1234'
|
|
Karsten Hopp |
4c9a90 |
! {'var_num': '1234'}
|
|
Karsten Hopp |
4c9a90 |
! {'var_num': '1234'}
|
|
Karsten Hopp |
4c9a90 |
! '5678'
|
|
Karsten Hopp |
4c9a90 |
{}
|
|
Karsten Hopp |
4c9a90 |
{}
|
|
Karsten Hopp |
4c9a90 |
''
|
|
Karsten Hopp |
4c9a90 |
! '5678'
|
|
Karsten Hopp |
4c9a90 |
0
|
|
Karsten Hopp |
4c9a90 |
0
|
|
Karsten Hopp |
4c9a90 |
'Dance'
|
|
Karsten Hopp |
4c9a90 |
*** ../vim-7.3.897/src/version.c 2013-04-15 14:44:53.000000000 +0200
|
|
Karsten Hopp |
4c9a90 |
--- src/version.c 2013-04-15 15:14:22.000000000 +0200
|
|
Karsten Hopp |
4c9a90 |
***************
|
|
Karsten Hopp |
4c9a90 |
*** 730,731 ****
|
|
Karsten Hopp |
4c9a90 |
--- 730,733 ----
|
|
Karsten Hopp |
4c9a90 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
4c9a90 |
+ /**/
|
|
Karsten Hopp |
4c9a90 |
+ 898,
|
|
Karsten Hopp |
4c9a90 |
/**/
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
--
|
|
Karsten Hopp |
4c9a90 |
If Apple would build a car...
|
|
Karsten Hopp |
4c9a90 |
... it would be powered by the sun, be reliable, five times
|
|
Karsten Hopp |
4c9a90 |
as fast and twice as easy to drive; but would only run on
|
|
Karsten Hopp |
4c9a90 |
five percent of the roads.
|
|
Karsten Hopp |
4c9a90 |
|
|
Karsten Hopp |
4c9a90 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
4c9a90 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
4c9a90 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
4c9a90 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|