Patch 7.4.2219
Problem:Recursive call to substitute gets stuck in sandbox. (Nikolai
Pavlov)
Solution: Handle the recursive call. (Christian Brabandt, closes #950)
Add a test.
Files: src/ex_cmds.c, src/testdir/test_regexp_latin.vim
*** ../vim-7.4.2218/src/ex_cmds.c 2016-07-30 23:18:44.644927811 +0200
--- src/ex_cmds.c 2016-08-16 20:58:17.915413520 +0200
***
*** 4747,4752
--- 4747,4766
static char_u *old_sub = NULL;/* previous substitute pattern */
static intglobal_need_beginline; /* call beginline() after ":g" */
+ /*
+ * Flags that are kept between calls to :substitute.
+ */
+ typedef struct {
+ int do_all; /* do multiple substitutions per line */
+ int do_ask; /* ask for confirmation */
+ int do_count; /* count only */
+ int do_error; /* if false, ignore errors */
+ int do_print; /* print last line with subs. */
+ int do_list;/* list last line with subs. */
+ int do_number; /* list last line with line nr*/
+ int do_ic; /* ignore case flag */
+ } subflags_T;
+
/* do_sub()
*
* Perform a substitution from line eap->line1 to line eap->line2 using the
***
*** 4762,4775
linenr_T lnum;
long i = 0;
regmmatch_T regmatch;
! static intdo_all = FALSE; /* do multiple substitutions
per line */
! static intdo_ask = FALSE; /* ask for confirmation */
! static intdo_count = FALSE; /* count only */
! static intdo_error = TRUE;/* if false, ignore errors */
! static intdo_print = FALSE; /* print last line with subs. */
! static intdo_list = FALSE;/* list last line with subs. */
! static intdo_number = FALSE; /* list last line with line nr*/
! static intdo_ic = 0; /* ignore case flag */
int save_do_all;/* remember user specified 'g'
flag */
int save_do_ask;/* remember user specified 'c'
flag */
char_u*pat = NULL, *sub = NULL; /* init for GCC */
--- 4776,4786
linenr_T lnum;
long i = 0;
regmmatch_T regmatch;
! static subflags_T subflags = {FALSE, FALSE, FALSE, TRUE, FALSE,
! FALSE, FALSE, 0};
! #ifdef FEAT_EVAL
! subflags_Tsubflags_save;
! #endif
int save_do_all;/* remember user specified 'g'
flag */
int save_do_ask;/* remember user specified 'c'
flag */
char_u*pat = NULL, *sub = NULL; /* init for GCC */
***
*** 4957,4972
if (!p_ed)
{
if (p_gd) /* default is global on */
! do_all = TRUE;
else
! do_all = FALSE;
! do_ask = FALSE;
}
! do_error = TRUE;
! do_print = FALSE;
! do_count = FALSE;
! do_number = FALSE;
! do_ic = 0;
}
while (*cmd)
{
--- 4968,4983
if (!p_ed)
{
if (p_gd) /* default is global on */
! subflags.do_all = TRUE;
else
! subflags.do_all = FALSE;
! subflags.do_ask = FALSE;
}
! subflags.do_error = TRUE;
! subflags.do_print = FALSE;
! subflags.do_count = FALSE;
! subflags.do_number = FALSE;
! subflags.do_ic = 0;
}
while (*cmd)
{
***
*** 4975,5014
* 'r' is never inverted.
*/
if (*cmd == 'g')
! do_all = !do_all;
else if (*cmd == 'c')
! do_ask = !do_ask;
else if (*cmd == 'n')
! do_count = TRUE;
else if (*cmd == 'e')
! do_error = !do_error;
else if (*cmd == 'r') /* use last used regexp */
which_pat = RE_LAST;
else if (*cmd == 'p')
! do_print = TRUE;
else if (*cmd == '#')
{
! do_print = TRUE;
! do_number = TRUE;
}
else if (*cmd == 'l')
{
! do_print = TRUE;
! do_list = TRUE;
}
else if (*cmd == 'i') /* ignore case */
! do_ic = 'i';
else if (*cmd == 'I') /* don't ignore case */
! do_ic = 'I';
else
break;
++cmd;
}
! if (do_count)
! do_ask = FALSE;
! save_do_all = do_all;
! save_do_ask = do_ask;
/*
* check for a trailing count
--- 4986,5025
* 'r' is never