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