Karsten Hopp bcd0f0
To: vim_dev@googlegroups.com
Karsten Hopp bcd0f0
Subject: Patch 7.3.1243
Karsten Hopp bcd0f0
Fcc: outbox
Karsten Hopp bcd0f0
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp bcd0f0
Mime-Version: 1.0
Karsten Hopp bcd0f0
Content-Type: text/plain; charset=UTF-8
Karsten Hopp bcd0f0
Content-Transfer-Encoding: 8bit
Karsten Hopp bcd0f0
------------
Karsten Hopp bcd0f0
Karsten Hopp bcd0f0
Patch 7.3.1243
Karsten Hopp bcd0f0
Problem:    New regexp engine: back references in look-behind match don't
Karsten Hopp bcd0f0
	    work. (Lech Lorens)
Karsten Hopp bcd0f0
Solution:   Copy the submatches before a recursive match. Also fix
Karsten Hopp bcd0f0
	    function prototypes.
Karsten Hopp bcd0f0
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
Karsten Hopp bcd0f0
Karsten Hopp bcd0f0
Karsten Hopp bcd0f0
*** ../vim-7.3.1242/src/regexp_nfa.c	2013-06-21 18:31:16.000000000 +0200
Karsten Hopp bcd0f0
--- src/regexp_nfa.c	2013-06-26 12:32:19.000000000 +0200
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 290,299 ****
Karsten Hopp bcd0f0
  #endif
Karsten Hopp bcd0f0
  static int *re2post __ARGS((void));
Karsten Hopp bcd0f0
  static nfa_state_T *alloc_state __ARGS((int c, nfa_state_T *out, nfa_state_T *out1));
Karsten Hopp bcd0f0
  static nfa_state_T *post2nfa __ARGS((int *postfix, int *end, int nfa_calc_size));
Karsten Hopp bcd0f0
  static void nfa_postprocess __ARGS((nfa_regprog_T *prog));
Karsten Hopp bcd0f0
  static int check_char_class __ARGS((int class, int c));
Karsten Hopp bcd0f0
- static void st_error __ARGS((int *postfix, int *end, int *p));
Karsten Hopp bcd0f0
  static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list));
Karsten Hopp bcd0f0
  static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list));
Karsten Hopp bcd0f0
  static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos));
Karsten Hopp bcd0f0
--- 290,300 ----
Karsten Hopp bcd0f0
  #endif
Karsten Hopp bcd0f0
  static int *re2post __ARGS((void));
Karsten Hopp bcd0f0
  static nfa_state_T *alloc_state __ARGS((int c, nfa_state_T *out, nfa_state_T *out1));
Karsten Hopp bcd0f0
+ static void st_error __ARGS((int *postfix, int *end, int *p));
Karsten Hopp bcd0f0
+ static int nfa_max_width __ARGS((nfa_state_T *startstate, int depth));
Karsten Hopp bcd0f0
  static nfa_state_T *post2nfa __ARGS((int *postfix, int *end, int nfa_calc_size));
Karsten Hopp bcd0f0
  static void nfa_postprocess __ARGS((nfa_regprog_T *prog));
Karsten Hopp bcd0f0
  static int check_char_class __ARGS((int class, int c));
Karsten Hopp bcd0f0
  static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list));
Karsten Hopp bcd0f0
  static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list));
Karsten Hopp bcd0f0
  static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos));
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 3469,3474 ****
Karsten Hopp bcd0f0
--- 3470,3476 ----
Karsten Hopp bcd0f0
  #ifdef ENABLE_LOG
Karsten Hopp bcd0f0
  static void log_subsexpr __ARGS((regsubs_T *subs));
Karsten Hopp bcd0f0
  static void log_subexpr __ARGS((regsub_T *sub));
Karsten Hopp bcd0f0
+ static char *pim_info __ARGS((nfa_pim_T *pim));
Karsten Hopp bcd0f0
  
Karsten Hopp bcd0f0
      static void
Karsten Hopp bcd0f0
  log_subsexpr(subs)
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 3508,3514 ****
Karsten Hopp bcd0f0
  }
Karsten Hopp bcd0f0
  
Karsten Hopp bcd0f0
      static char *
Karsten Hopp bcd0f0
! pim_info(nfa_pim_T *pim)
Karsten Hopp bcd0f0
  {
Karsten Hopp bcd0f0
      static char buf[30];
Karsten Hopp bcd0f0
  
Karsten Hopp bcd0f0
--- 3510,3517 ----
Karsten Hopp bcd0f0
  }
Karsten Hopp bcd0f0
  
Karsten Hopp bcd0f0
      static char *
Karsten Hopp bcd0f0
! pim_info(pim)
Karsten Hopp bcd0f0
!     nfa_pim_T *pim;
Karsten Hopp bcd0f0
  {
Karsten Hopp bcd0f0
      static char buf[30];
Karsten Hopp bcd0f0
  
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 3532,3537 ****
Karsten Hopp bcd0f0
--- 3535,3541 ----
Karsten Hopp bcd0f0
  static void copy_sub __ARGS((regsub_T *to, regsub_T *from));
Karsten Hopp bcd0f0
  static void copy_sub_off __ARGS((regsub_T *to, regsub_T *from));
Karsten Hopp bcd0f0
  static int sub_equal __ARGS((regsub_T *sub1, regsub_T *sub2));
Karsten Hopp bcd0f0
+ static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen));
Karsten Hopp bcd0f0
  static int has_state_with_pos __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs));
Karsten Hopp bcd0f0
  static int state_in_list __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs));
Karsten Hopp bcd0f0
  static void addstate __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int off));
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 4319,4326 ****
Karsten Hopp bcd0f0
      return FAIL;
Karsten Hopp bcd0f0
  }
Karsten Hopp bcd0f0
  
Karsten Hopp bcd0f0
- static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen));
Karsten Hopp bcd0f0
- 
Karsten Hopp bcd0f0
  /*
Karsten Hopp bcd0f0
   * Check for a match with subexpression "subidx".
Karsten Hopp bcd0f0
   * Return TRUE if it matches.
Karsten Hopp bcd0f0
--- 4323,4328 ----
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 5195,5200 ****
Karsten Hopp bcd0f0
--- 5197,5206 ----
Karsten Hopp bcd0f0
  			 || t->state->c == NFA_START_INVISIBLE_BEFORE_FIRST
Karsten Hopp bcd0f0
  			 || t->state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)
Karsten Hopp bcd0f0
  		    {
Karsten Hopp bcd0f0
+ 			/* Copy submatch info for the recursive call, so that
Karsten Hopp bcd0f0
+ 			 * \1 can be matched. */
Karsten Hopp bcd0f0
+ 			copy_sub_off(&m->norm, &t->subs.norm);
Karsten Hopp bcd0f0
+ 
Karsten Hopp bcd0f0
  			/*
Karsten Hopp bcd0f0
  			 * First try matching the invisible match, then what
Karsten Hopp bcd0f0
  			 * follows.
Karsten Hopp bcd0f0
*** ../vim-7.3.1242/src/testdir/test64.in	2013-06-17 22:04:34.000000000 +0200
Karsten Hopp bcd0f0
--- src/testdir/test64.in	2013-06-26 12:31:31.000000000 +0200
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 380,385 ****
Karsten Hopp bcd0f0
--- 380,388 ----
Karsten Hopp bcd0f0
  :call add(tl, [2, '\(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9', 'xabcddefghiabcddefghix', 'abcddefghiabcddefghi', 'a', 'b', 'c', 'dd', 'e', 'f', 'g', 'h', 'i'])
Karsten Hopp bcd0f0
  :call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', ''])
Karsten Hopp bcd0f0
  :call add(tl, [2, '^.\(.\).\_..\1.', "aaa\naaa\nb", "aaa\naaa", 'a'])
Karsten Hopp bcd0f0
+ :call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ :call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ :call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<=$', 'foo.bat/foo.bat', 'foo.bat/foo.bat', 'bat', 'bat'])
Karsten Hopp bcd0f0
  :"
Karsten Hopp bcd0f0
  :"""" Look-behind with limit
Karsten Hopp bcd0f0
  :call add(tl, [2, '<\@<=span.', 'xxspanxx
Karsten Hopp bcd0f0
*** ../vim-7.3.1242/src/testdir/test64.ok	2013-06-17 22:04:34.000000000 +0200
Karsten Hopp bcd0f0
--- src/testdir/test64.ok	2013-06-26 12:31:36.000000000 +0200
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 866,871 ****
Karsten Hopp bcd0f0
--- 866,880 ----
Karsten Hopp bcd0f0
  OK 0 - ^.\(.\).\_..\1.
Karsten Hopp bcd0f0
  OK 1 - ^.\(.\).\_..\1.
Karsten Hopp bcd0f0
  OK 2 - ^.\(.\).\_..\1.
Karsten Hopp bcd0f0
+ OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@
Karsten Hopp bcd0f0
+ OK 0 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
Karsten Hopp bcd0f0
+ OK 1 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
Karsten Hopp bcd0f0
+ OK 2 - ^.*\.\(.*\)/.\+\(\1\)\@<=$
Karsten Hopp bcd0f0
  OK 0 - <\@<=span.
Karsten Hopp bcd0f0
  OK 1 - <\@<=span.
Karsten Hopp bcd0f0
  OK 2 - <\@<=span.
Karsten Hopp bcd0f0
*** ../vim-7.3.1242/src/version.c	2013-06-24 22:33:26.000000000 +0200
Karsten Hopp bcd0f0
--- src/version.c	2013-06-26 12:41:02.000000000 +0200
Karsten Hopp bcd0f0
***************
Karsten Hopp bcd0f0
*** 730,731 ****
Karsten Hopp bcd0f0
--- 730,733 ----
Karsten Hopp bcd0f0
  {   /* Add new patch number below this line */
Karsten Hopp bcd0f0
+ /**/
Karsten Hopp bcd0f0
+     1243,
Karsten Hopp bcd0f0
  /**/
Karsten Hopp bcd0f0
Karsten Hopp bcd0f0
-- 
Karsten Hopp bcd0f0
You cannot propel yourself forward by patting yourself on the back.
Karsten Hopp bcd0f0
Karsten Hopp bcd0f0
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp bcd0f0
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp bcd0f0
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp bcd0f0
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///