Re: Patch 7.4.2219

2016-08-17 Fir de Conversatie Bram Moolenaar

Andy Wokula wrote:

> Am 16.08.2016 um 21:04 schrieb Bram Moolenaar:
> > 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
> 
> What about recursive sub-replace-\= ?
> 
> (fixed as well?  related at all?  already fixed?)

Well, try to come up with an example that doesn't work.

-- 
The History of every major Galactic Civilization tends to pass through
three distinct and recognizable phases, those of Survival, Inquiry and
Sophistication, otherwise known as the How, Why and Where phases.
For instance, the first phase is characterized by the question 'How can
we eat?' the second by the question 'Why do we eat?' and the third by
the question 'Where shall we have lunch?'
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Patch 7.4.2219

2016-08-17 Fir de Conversatie 'Andy Wokula' via vim_dev

Am 16.08.2016 um 21:04 schrieb Bram Moolenaar:

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


What about recursive sub-replace-\= ?

(fixed as well?  related at all?  already fixed?)

--
Andy

--
--
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Patch 7.4.2219

2016-08-16 Fir de Conversatie Bram Moolenaar

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