comparison src/regexp_nfa.c @ 6170:3ee39fe2df7d v7.4.421

updated for version 7.4.421 Problem: Crash when searching for "\ze*". (Urtica Dioica) Solution: Disallow a multi after \ze and \zs.
author Bram Moolenaar <bram@vim.org>
date Fri, 29 Aug 2014 11:56:32 +0200
parents 10fc95f48546
children 8515b42f939c
comparison
equal deleted inserted replaced
6169:5f3c1d1bfe9d 6170:3ee39fe2df7d
289 static int nfa_regatom __ARGS((void)); 289 static int nfa_regatom __ARGS((void));
290 static int nfa_regpiece __ARGS((void)); 290 static int nfa_regpiece __ARGS((void));
291 static int nfa_regconcat __ARGS((void)); 291 static int nfa_regconcat __ARGS((void));
292 static int nfa_regbranch __ARGS((void)); 292 static int nfa_regbranch __ARGS((void));
293 static int nfa_reg __ARGS((int paren)); 293 static int nfa_reg __ARGS((int paren));
294 static int re_mult_next __ARGS((char *what));
294 #ifdef DEBUG 295 #ifdef DEBUG
295 static void nfa_set_code __ARGS((int c)); 296 static void nfa_set_code __ARGS((int c));
296 static void nfa_postfix_dump __ARGS((char_u *expr, int retval)); 297 static void nfa_postfix_dump __ARGS((char_u *expr, int retval));
297 static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state)); 298 static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state));
298 static void nfa_print_state2 __ARGS((FILE *debugf, nfa_state_T *state, garray_T *indent)); 299 static void nfa_print_state2 __ARGS((FILE *debugf, nfa_state_T *state, garray_T *indent));
1321 c = no_Magic(getchr()); 1322 c = no_Magic(getchr());
1322 switch (c) 1323 switch (c)
1323 { 1324 {
1324 case 's': 1325 case 's':
1325 EMIT(NFA_ZSTART); 1326 EMIT(NFA_ZSTART);
1327 if (re_mult_next("\\zs") == FAIL)
1328 return FAIL;
1326 break; 1329 break;
1327 case 'e': 1330 case 'e':
1328 EMIT(NFA_ZEND); 1331 EMIT(NFA_ZEND);
1329 nfa_has_zend = TRUE; 1332 nfa_has_zend = TRUE;
1333 if (re_mult_next("\\ze") == FAIL)
1334 return FAIL;
1330 break; 1335 break;
1331 #ifdef FEAT_SYN_HL 1336 #ifdef FEAT_SYN_HL
1332 case '1': 1337 case '1':
1333 case '2': 1338 case '2':
1334 case '3': 1339 case '3':
2274 #endif 2279 #endif
2275 2280
2276 return OK; 2281 return OK;
2277 } 2282 }
2278 2283
2284 /*
2285 * Used in a place where no * or \+ can follow.
2286 */
2287 static int
2288 re_mult_next(what)
2289 char *what;
2290 {
2291 if (re_multi_type(peekchr()) == MULTI_MULT)
2292 EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what);
2293 return OK;
2294 }
2295
2279 #ifdef DEBUG 2296 #ifdef DEBUG
2280 static char_u code[50]; 2297 static char_u code[50];
2281 2298
2282 static void 2299 static void
2283 nfa_set_code(c) 2300 nfa_set_code(c)