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