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