Patch 8.1.1345
Problem: Stuck in sandbox with ":s/../\=Function/gn".
Solution: Don't skip over code to restore sandbox. (Christian Brabandt)
Files: src/ex_cmds.c, src/testdir/test_substitute.vim
*** ../vim-8.1.1344/src/ex_cmds.c 2019-05-15 22:45:33.956067651 +0200
--- src/ex_cmds.c 2019-05-18 13:39:18.862210027 +0200
***************
*** 5555,5582 ****
#ifdef FEAT_EVAL
if (subflags.do_count)
{
! /* prevent accidentally changing the buffer by a function */
! save_ma = curbuf->b_p_ma;
curbuf->b_p_ma = FALSE;
sandbox++;
}
! /* Save flags for recursion. They can change for e.g.
! * :s/^/\=execute("s#^##gn") */
subflags_save = subflags;
#endif
! /* get length of substitution part */
sublen = vim_regsub_multi(®match,
sub_firstlnum - regmatch.startpos[0].lnum,
sub, sub_firstline, FALSE, p_magic, TRUE);
#ifdef FEAT_EVAL
// If getting the substitute string caused an error, don't do
// the replacement.
- if (aborting())
- goto skip;
-
// Don't keep flags set by a recursive call.
subflags = subflags_save;
! if (subflags.do_count)
{
curbuf->b_p_ma = save_ma;
if (sandbox > 0)
--- 5555,5579 ----
#ifdef FEAT_EVAL
if (subflags.do_count)
{
! // prevent accidentally changing the buffer by a function
curbuf->b_p_ma = FALSE;
sandbox++;
}
! // Save flags for recursion. They can change for e.g.
! // :s/^/\=execute("s#^##gn")
subflags_save = subflags;
+ save_ma = curbuf->b_p_ma;
#endif
! // get length of substitution part
sublen = vim_regsub_multi(®match,
sub_firstlnum - regmatch.startpos[0].lnum,
sub, sub_firstline, FALSE, p_magic, TRUE);
#ifdef FEAT_EVAL
// If getting the substitute string caused an error, don't do
// the replacement.
// Don't keep flags set by a recursive call.
subflags = subflags_save;
! if (aborting() || subflags.do_count)
{
curbuf->b_p_ma = save_ma;
if (sandbox > 0)
*** ../vim-8.1.1344/src/testdir/test_substitute.vim 2019-04-27
18:00:29.851064563 +0200
--- src/testdir/test_substitute.vim 2019-05-18 13:35:12.383650094 +0200
***************
*** 638,643 ****
--- 638,654 ----
call assert_equal(1, error_caught)
call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+ " Same, but using "n" flag so that "sandbox" gets set
+ call setline(1, ['1 aaa', '2 aaa', '3 aaa'])
+ let error_caught = 0
+ try
+ %s/aaa/\=Foo()/gn
+ catch
+ let error_caught = 1
+ endtry
+ call assert_equal(1, error_caught)
+ call assert_equal(['1 aaa', '2 aaa', '3 aaa'], getline(1, 3))
+
bwipe!
endfunc
*** ../vim-8.1.1344/src/version.c 2019-05-18 13:05:12.470334000 +0200
--- src/version.c 2019-05-18 13:40:32.629781025 +0200
***************
*** 769,770 ****
--- 769,772 ----
{ /* Add new patch number below this line */
+ /**/
+ 1345,
/**/
--
For large projects, Team Leaders use sophisticated project management software
to keep track of who's doing what. The software collects the lies and guesses
of the project team and organizes them in to instantly outdated charts that
are too boring to look at closely. This is called "planning".
(Scott Adams - The Dilbert principle)
/// 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201905181141.x4IBfg6M002697%40masaka.moolenaar.net.
For more options, visit https://groups.google.com/d/optout.