Karsten Hopp 9123e3
To: vim_dev@googlegroups.com
Karsten Hopp 9123e3
Subject: Patch 7.4.421
Karsten Hopp 9123e3
Fcc: outbox
Karsten Hopp 9123e3
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 9123e3
Mime-Version: 1.0
Karsten Hopp 9123e3
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 9123e3
Content-Transfer-Encoding: 8bit
Karsten Hopp 9123e3
------------
Karsten Hopp 9123e3
Karsten Hopp 9123e3
Patch 7.4.421
Karsten Hopp 9123e3
Problem:    Crash when searching for "\ze*". (Urtica Dioica)
Karsten Hopp 9123e3
Solution:   Disallow a multi after \ze and \zs.
Karsten Hopp 9123e3
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
Karsten Hopp 9123e3
Karsten Hopp 9123e3
Karsten Hopp 9123e3
*** ../vim-7.4.420/src/regexp_nfa.c	2014-05-13 19:37:19.489786520 +0200
Karsten Hopp 9123e3
--- src/regexp_nfa.c	2014-08-29 11:14:12.030416520 +0200
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 291,296 ****
Karsten Hopp 9123e3
--- 291,297 ----
Karsten Hopp 9123e3
  static int nfa_regconcat __ARGS((void));
Karsten Hopp 9123e3
  static int nfa_regbranch __ARGS((void));
Karsten Hopp 9123e3
  static int nfa_reg __ARGS((int paren));
Karsten Hopp 9123e3
+ static int re_mult_next __ARGS((char *what));
Karsten Hopp 9123e3
  #ifdef DEBUG
Karsten Hopp 9123e3
  static void nfa_set_code __ARGS((int c));
Karsten Hopp 9123e3
  static void nfa_postfix_dump __ARGS((char_u *expr, int retval));
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 1323,1332 ****
Karsten Hopp 9123e3
--- 1324,1337 ----
Karsten Hopp 9123e3
  	    {
Karsten Hopp 9123e3
  		case 's':
Karsten Hopp 9123e3
  		    EMIT(NFA_ZSTART);
Karsten Hopp 9123e3
+ 		    if (re_mult_next("\\zs") == FAIL)
Karsten Hopp 9123e3
+ 			return FAIL;
Karsten Hopp 9123e3
  		    break;
Karsten Hopp 9123e3
  		case 'e':
Karsten Hopp 9123e3
  		    EMIT(NFA_ZEND);
Karsten Hopp 9123e3
  		    nfa_has_zend = TRUE;
Karsten Hopp 9123e3
+ 		    if (re_mult_next("\\ze") == FAIL)
Karsten Hopp 9123e3
+ 			return FAIL;
Karsten Hopp 9123e3
  		    break;
Karsten Hopp 9123e3
  #ifdef FEAT_SYN_HL
Karsten Hopp 9123e3
  		case '1':
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 2276,2281 ****
Karsten Hopp 9123e3
--- 2281,2298 ----
Karsten Hopp 9123e3
      return OK;
Karsten Hopp 9123e3
  }
Karsten Hopp 9123e3
  
Karsten Hopp 9123e3
+ /*
Karsten Hopp 9123e3
+  * Used in a place where no * or \+ can follow.
Karsten Hopp 9123e3
+  */
Karsten Hopp 9123e3
+     static int
Karsten Hopp 9123e3
+ re_mult_next(what)
Karsten Hopp 9123e3
+     char *what;
Karsten Hopp 9123e3
+ {
Karsten Hopp 9123e3
+     if (re_multi_type(peekchr()) == MULTI_MULT)
Karsten Hopp 9123e3
+ 	EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what);
Karsten Hopp 9123e3
+     return OK;
Karsten Hopp 9123e3
+ }
Karsten Hopp 9123e3
+ 
Karsten Hopp 9123e3
  #ifdef DEBUG
Karsten Hopp 9123e3
  static char_u code[50];
Karsten Hopp 9123e3
  
Karsten Hopp 9123e3
*** ../vim-7.4.420/src/testdir/test64.in	2014-05-13 16:44:25.633695709 +0200
Karsten Hopp 9123e3
--- src/testdir/test64.in	2014-08-29 11:33:12.330419011 +0200
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 459,465 ****
Karsten Hopp 9123e3
  :  let text = t[2]
Karsten Hopp 9123e3
  :  let matchidx = 3
Karsten Hopp 9123e3
  :  for engine in [0, 1, 2]
Karsten Hopp 9123e3
! :    if engine == 2 && re == 0 || engine == 1 && re ==1
Karsten Hopp 9123e3
  :      continue
Karsten Hopp 9123e3
  :    endif
Karsten Hopp 9123e3
  :    let &regexpengine = engine
Karsten Hopp 9123e3
--- 459,465 ----
Karsten Hopp 9123e3
  :  let text = t[2]
Karsten Hopp 9123e3
  :  let matchidx = 3
Karsten Hopp 9123e3
  :  for engine in [0, 1, 2]
Karsten Hopp 9123e3
! :    if engine == 2 && re == 0 || engine == 1 && re == 1
Karsten Hopp 9123e3
  :      continue
Karsten Hopp 9123e3
  :    endif
Karsten Hopp 9123e3
  :    let &regexpengine = engine
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 608,613 ****
Karsten Hopp 9123e3
--- 608,624 ----
Karsten Hopp 9123e3
  "ayb20gg/..\%$
Karsten Hopp 9123e3
  "bybGo?"apo?"bp:"
Karsten Hopp 9123e3
  :"
Karsten Hopp 9123e3
+ :" Check for detecting error
Karsten Hopp 9123e3
+ :set regexpengine=2
Karsten Hopp 9123e3
+ :for pat in [' \ze*', ' \zs*']
Karsten Hopp 9123e3
+ :  try
Karsten Hopp 9123e3
+ :    let l = matchlist('x x', pat)
Karsten Hopp 9123e3
+ :    $put ='E888 NOT detected for ' . pat
Karsten Hopp 9123e3
+ :  catch
Karsten Hopp 9123e3
+ :    $put ='E888 detected for ' . pat
Karsten Hopp 9123e3
+ :  endtry
Karsten Hopp 9123e3
+ :endfor
Karsten Hopp 9123e3
+ :"
Karsten Hopp 9123e3
  :""""" Write the results """""""""""""
Karsten Hopp 9123e3
  :/\%#=1^Results/,$wq! test.out
Karsten Hopp 9123e3
  ENDTEST
Karsten Hopp 9123e3
*** ../vim-7.4.420/src/testdir/test64.ok	2014-05-13 16:44:25.633695709 +0200
Karsten Hopp 9123e3
--- src/testdir/test64.ok	2014-08-29 11:36:05.782419390 +0200
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 1097,1099 ****
Karsten Hopp 9123e3
--- 1097,1101 ----
Karsten Hopp 9123e3
  Test END
Karsten Hopp 9123e3
  EN
Karsten Hopp 9123e3
  E
Karsten Hopp 9123e3
+ E888 detected for  \ze*
Karsten Hopp 9123e3
+ E888 detected for  \zs*
Karsten Hopp 9123e3
*** ../vim-7.4.420/src/version.c	2014-08-29 10:04:32.226407390 +0200
Karsten Hopp 9123e3
--- src/version.c	2014-08-29 11:37:15.794419543 +0200
Karsten Hopp 9123e3
***************
Karsten Hopp 9123e3
*** 743,744 ****
Karsten Hopp 9123e3
--- 743,746 ----
Karsten Hopp 9123e3
  {   /* Add new patch number below this line */
Karsten Hopp 9123e3
+ /**/
Karsten Hopp 9123e3
+     421,
Karsten Hopp 9123e3
  /**/
Karsten Hopp 9123e3
Karsten Hopp 9123e3
-- 
Karsten Hopp 9123e3
From "know your smileys":
Karsten Hopp 9123e3
 :----}  You lie like Pinocchio
Karsten Hopp 9123e3
Karsten Hopp 9123e3
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 9123e3
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 9123e3
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 9123e3
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///