Patch 7.4.1755
Problem: When using getreg() on a non-existing register a NULL list is
returned. (Bjorn Linse)
Solution: Allocate an empty list. Add a test.
Files: src/eval.c, src/testdir/test_expr.vim
*** ../vim-7.4.1754/src/eval.c 2016-04-14 22:54:20.818618214 +0200
--- src/eval.c 2016-04-20 14:36:27.045220066 +0200
***************
*** 6051,6057 ****
}
/*
! * Allocate an empty list for a return value.
* Returns OK or FAIL.
*/
int
--- 6051,6057 ----
}
/*
! * Allocate an empty list for a return value, with reference count set.
* Returns OK or FAIL.
*/
int
***************
*** 13173,13179 ****
rettv->v_type = VAR_LIST;
rettv->vval.v_list = (list_T *)get_reg_contents(regname,
(arg2 ? GREG_EXPR_SRC : 0) | GREG_LIST);
! if (rettv->vval.v_list != NULL)
++rettv->vval.v_list->lv_refcount;
}
else
--- 13173,13181 ----
rettv->v_type = VAR_LIST;
rettv->vval.v_list = (list_T *)get_reg_contents(regname,
(arg2 ? GREG_EXPR_SRC : 0) | GREG_LIST);
! if (rettv->vval.v_list == NULL)
! rettv_list_alloc(rettv);
! else
++rettv->vval.v_list->lv_refcount;
}
else
*** ../vim-7.4.1754/src/testdir/test_expr.vim 2016-04-14 16:56:57.111452601
+0200
--- src/testdir/test_expr.vim 2016-04-20 14:44:25.416386321 +0200
***************
*** 74,76 ****
--- 74,85 ----
call assert_equal('a', strcharpart('axb', -1, 2))
endfunc
+
+ func Test_getreg_empty_list()
+ call assert_equal('', getreg('x'))
+ call assert_equal([], getreg('x', 1, 1))
+ let x = getreg('x', 1, 1)
+ let y = x
+ call add(x, 'foo')
+ call assert_equal(['foo'], y)
+ endfunc
*** ../vim-7.4.1754/src/version.c 2016-04-20 12:49:43.522961653 +0200
--- src/version.c 2016-04-20 14:45:14.255892513 +0200
***************
*** 750,751 ****
--- 750,753 ----
{ /* Add new patch number below this line */
+ /**/
+ 1755,
/**/
--
Computers are not intelligent. They only think they are.
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.