comparison src/regexp_nfa.c @ 4696:ed4e689bbea1 v7.3.1095

updated for version 7.3.1095 Problem: Compiler warnings for shadowed variables. (Christian Brabandt) Solution: Rename new_state() to alloc_state(). Remove unnecessary declaration.
author Bram Moolenaar <bram@vim.org>
date Sun, 02 Jun 2013 16:40:55 +0200
parents efc4fb311d5d
children 832bf8136d86
comparison
equal deleted inserted replaced
4695:d7fb00c28228 4696:ed4e689bbea1
245 static int *post_end; 245 static int *post_end;
246 static int *post_ptr; 246 static int *post_ptr;
247 247
248 static int nstate; /* Number of states in the NFA. Also used when 248 static int nstate; /* Number of states in the NFA. Also used when
249 * executing. */ 249 * executing. */
250 static int istate; /* Index in the state vector, used in new_state() */ 250 static int istate; /* Index in the state vector, used in alloc_state() */
251 251
252 /* If not NULL match must end at this position */ 252 /* If not NULL match must end at this position */
253 static save_se_T *nfa_endp = NULL; 253 static save_se_T *nfa_endp = NULL;
254 254
255 static int nfa_regcomp_start __ARGS((char_u*expr, int re_flags)); 255 static int nfa_regcomp_start __ARGS((char_u*expr, int re_flags));
266 static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state)); 266 static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state));
267 static void nfa_print_state2 __ARGS((FILE *debugf, nfa_state_T *state, garray_T *indent)); 267 static void nfa_print_state2 __ARGS((FILE *debugf, nfa_state_T *state, garray_T *indent));
268 static void nfa_dump __ARGS((nfa_regprog_T *prog)); 268 static void nfa_dump __ARGS((nfa_regprog_T *prog));
269 #endif 269 #endif
270 static int *re2post __ARGS((void)); 270 static int *re2post __ARGS((void));
271 static nfa_state_T *new_state __ARGS((int c, nfa_state_T *out, nfa_state_T *out1)); 271 static nfa_state_T *alloc_state __ARGS((int c, nfa_state_T *out, nfa_state_T *out1));
272 static nfa_state_T *post2nfa __ARGS((int *postfix, int *end, int nfa_calc_size)); 272 static nfa_state_T *post2nfa __ARGS((int *postfix, int *end, int nfa_calc_size));
273 static int check_char_class __ARGS((int class, int c)); 273 static int check_char_class __ARGS((int class, int c));
274 static void st_error __ARGS((int *postfix, int *end, int *p)); 274 static void st_error __ARGS((int *postfix, int *end, int *p));
275 static void nfa_set_neg_listids __ARGS((nfa_state_T *start)); 275 static void nfa_set_neg_listids __ARGS((nfa_state_T *start));
276 static void nfa_set_null_listids __ARGS((nfa_state_T *start)); 276 static void nfa_set_null_listids __ARGS((nfa_state_T *start));
2132 2132
2133 /* 2133 /*
2134 * Allocate and initialize nfa_state_T. 2134 * Allocate and initialize nfa_state_T.
2135 */ 2135 */
2136 static nfa_state_T * 2136 static nfa_state_T *
2137 new_state(c, out, out1) 2137 alloc_state(c, out, out1)
2138 int c; 2138 int c;
2139 nfa_state_T *out; 2139 nfa_state_T *out;
2140 nfa_state_T *out1; 2140 nfa_state_T *out1;
2141 { 2141 {
2142 nfa_state_T *s; 2142 nfa_state_T *s;
2429 nstate++; 2429 nstate++;
2430 break; 2430 break;
2431 } 2431 }
2432 e2 = POP(); 2432 e2 = POP();
2433 e1 = POP(); 2433 e1 = POP();
2434 s = new_state(NFA_SPLIT, e1.start, e2.start); 2434 s = alloc_state(NFA_SPLIT, e1.start, e2.start);
2435 if (s == NULL) 2435 if (s == NULL)
2436 goto theend; 2436 goto theend;
2437 PUSH(frag(s, append(e1.out, e2.out))); 2437 PUSH(frag(s, append(e1.out, e2.out)));
2438 break; 2438 break;
2439 2439
2443 { 2443 {
2444 nstate++; 2444 nstate++;
2445 break; 2445 break;
2446 } 2446 }
2447 e = POP(); 2447 e = POP();
2448 s = new_state(NFA_SPLIT, e.start, NULL); 2448 s = alloc_state(NFA_SPLIT, e.start, NULL);
2449 if (s == NULL) 2449 if (s == NULL)
2450 goto theend; 2450 goto theend;
2451 patch(e.out, s); 2451 patch(e.out, s);
2452 PUSH(frag(s, list1(&s->out1))); 2452 PUSH(frag(s, list1(&s->out1)));
2453 break; 2453 break;
2458 { 2458 {
2459 nstate++; 2459 nstate++;
2460 break; 2460 break;
2461 } 2461 }
2462 e = POP(); 2462 e = POP();
2463 s = new_state(NFA_SPLIT, NULL, e.start); 2463 s = alloc_state(NFA_SPLIT, NULL, e.start);
2464 if (s == NULL) 2464 if (s == NULL)
2465 goto theend; 2465 goto theend;
2466 patch(e.out, s); 2466 patch(e.out, s);
2467 PUSH(frag(s, list1(&s->out))); 2467 PUSH(frag(s, list1(&s->out)));
2468 break; 2468 break;
2473 { 2473 {
2474 nstate++; 2474 nstate++;
2475 break; 2475 break;
2476 } 2476 }
2477 e = POP(); 2477 e = POP();
2478 s = new_state(NFA_SPLIT, e.start, NULL); 2478 s = alloc_state(NFA_SPLIT, e.start, NULL);
2479 if (s == NULL) 2479 if (s == NULL)
2480 goto theend; 2480 goto theend;
2481 PUSH(frag(s, append(e.out, list1(&s->out1)))); 2481 PUSH(frag(s, append(e.out, list1(&s->out1))));
2482 break; 2482 break;
2483 2483
2487 { 2487 {
2488 nstate++; 2488 nstate++;
2489 break; 2489 break;
2490 } 2490 }
2491 e = POP(); 2491 e = POP();
2492 s = new_state(NFA_SPLIT, NULL, e.start); 2492 s = alloc_state(NFA_SPLIT, NULL, e.start);
2493 if (s == NULL) 2493 if (s == NULL)
2494 goto theend; 2494 goto theend;
2495 PUSH(frag(s, append(e.out, list1(&s->out)))); 2495 PUSH(frag(s, append(e.out, list1(&s->out))));
2496 break; 2496 break;
2497 2497
2501 if (nfa_calc_size == TRUE) 2501 if (nfa_calc_size == TRUE)
2502 { 2502 {
2503 nstate++; 2503 nstate++;
2504 break; 2504 break;
2505 } 2505 }
2506 s = new_state(NFA_SKIP_CHAR, NULL, NULL); 2506 s = alloc_state(NFA_SKIP_CHAR, NULL, NULL);
2507 if (s == NULL) 2507 if (s == NULL)
2508 goto theend; 2508 goto theend;
2509 PUSH(frag(s, list1(&s->out))); 2509 PUSH(frag(s, list1(&s->out)));
2510 break; 2510 break;
2511 2511
2524 { 2524 {
2525 nstate += 2; 2525 nstate += 2;
2526 break; 2526 break;
2527 } 2527 }
2528 e = POP(); 2528 e = POP();
2529 s1 = new_state(NFA_END_INVISIBLE, NULL, NULL); 2529 s1 = alloc_state(NFA_END_INVISIBLE, NULL, NULL);
2530 if (s1 == NULL) 2530 if (s1 == NULL)
2531 goto theend; 2531 goto theend;
2532 patch(e.out, s1); 2532 patch(e.out, s1);
2533 2533
2534 s = new_state(NFA_START_INVISIBLE, e.start, s1); 2534 s = alloc_state(NFA_START_INVISIBLE, e.start, s1);
2535 if (s == NULL) 2535 if (s == NULL)
2536 goto theend; 2536 goto theend;
2537 if (*p == NFA_PREV_ATOM_NO_WIDTH_NEG 2537 if (*p == NFA_PREV_ATOM_NO_WIDTH_NEG
2538 || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG) 2538 || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG)
2539 { 2539 {
2620 * the empty regexp "". In this case, the NFA will be 2620 * the empty regexp "". In this case, the NFA will be
2621 * NFA_MOPEN -> NFA_MCLOSE. Note that this also allows 2621 * NFA_MOPEN -> NFA_MCLOSE. Note that this also allows
2622 * empty groups of parenthesis, and empty mbyte chars */ 2622 * empty groups of parenthesis, and empty mbyte chars */
2623 if (stackp == stack) 2623 if (stackp == stack)
2624 { 2624 {
2625 s = new_state(mopen, NULL, NULL); 2625 s = alloc_state(mopen, NULL, NULL);
2626 if (s == NULL) 2626 if (s == NULL)
2627 goto theend; 2627 goto theend;
2628 s1 = new_state(mclose, NULL, NULL); 2628 s1 = alloc_state(mclose, NULL, NULL);
2629 if (s1 == NULL) 2629 if (s1 == NULL)
2630 goto theend; 2630 goto theend;
2631 patch(list1(&s->out), s1); 2631 patch(list1(&s->out), s1);
2632 PUSH(frag(s, list1(&s1->out))); 2632 PUSH(frag(s, list1(&s1->out)));
2633 break; 2633 break;
2634 } 2634 }
2635 2635
2636 /* At least one node was emitted before NFA_MOPEN, so 2636 /* At least one node was emitted before NFA_MOPEN, so
2637 * at least one node will be between NFA_MOPEN and NFA_MCLOSE */ 2637 * at least one node will be between NFA_MOPEN and NFA_MCLOSE */
2638 e = POP(); 2638 e = POP();
2639 s = new_state(mopen, e.start, NULL); /* `(' */ 2639 s = alloc_state(mopen, e.start, NULL); /* `(' */
2640 if (s == NULL) 2640 if (s == NULL)
2641 goto theend; 2641 goto theend;
2642 2642
2643 s1 = new_state(mclose, NULL, NULL); /* `)' */ 2643 s1 = alloc_state(mclose, NULL, NULL); /* `)' */
2644 if (s1 == NULL) 2644 if (s1 == NULL)
2645 goto theend; 2645 goto theend;
2646 patch(e.out, s1); 2646 patch(e.out, s1);
2647 2647
2648 #ifdef FEAT_MBYTE 2648 #ifdef FEAT_MBYTE
2677 if (nfa_calc_size == TRUE) 2677 if (nfa_calc_size == TRUE)
2678 { 2678 {
2679 nstate += 2; 2679 nstate += 2;
2680 break; 2680 break;
2681 } 2681 }
2682 s = new_state(*p, NULL, NULL); 2682 s = alloc_state(*p, NULL, NULL);
2683 if (s == NULL) 2683 if (s == NULL)
2684 goto theend; 2684 goto theend;
2685 s1 = new_state(NFA_SKIP, NULL, NULL); 2685 s1 = alloc_state(NFA_SKIP, NULL, NULL);
2686 if (s1 == NULL) 2686 if (s1 == NULL)
2687 goto theend; 2687 goto theend;
2688 patch(list1(&s->out), s1); 2688 patch(list1(&s->out), s1);
2689 PUSH(frag(s, list1(&s1->out))); 2689 PUSH(frag(s, list1(&s1->out)));
2690 break; 2690 break;
2702 { 2702 {
2703 nstate += 1; 2703 nstate += 1;
2704 break; 2704 break;
2705 } 2705 }
2706 e1 = POP(); 2706 e1 = POP();
2707 s = new_state(*p, NULL, NULL); 2707 s = alloc_state(*p, NULL, NULL);
2708 if (s == NULL) 2708 if (s == NULL)
2709 goto theend; 2709 goto theend;
2710 s->val = e1.start->c; 2710 s->val = e1.start->c;
2711 PUSH(frag(s, list1(&s->out))); 2711 PUSH(frag(s, list1(&s->out)));
2712 break; 2712 break;
2718 if (nfa_calc_size == TRUE) 2718 if (nfa_calc_size == TRUE)
2719 { 2719 {
2720 nstate++; 2720 nstate++;
2721 break; 2721 break;
2722 } 2722 }
2723 s = new_state(*p, NULL, NULL); 2723 s = alloc_state(*p, NULL, NULL);
2724 if (s == NULL) 2724 if (s == NULL)
2725 goto theend; 2725 goto theend;
2726 PUSH(frag(s, list1(&s->out))); 2726 PUSH(frag(s, list1(&s->out)));
2727 break; 2727 break;
2728 2728
4740 unref_extmatch(re_extmatch_out); 4740 unref_extmatch(re_extmatch_out);
4741 re_extmatch_out = NULL; 4741 re_extmatch_out = NULL;
4742 4742
4743 if (prog->reghasz == REX_SET) 4743 if (prog->reghasz == REX_SET)
4744 { 4744 {
4745 int i;
4746
4747 cleanup_zsubexpr(); 4745 cleanup_zsubexpr();
4748 re_extmatch_out = make_extmatch(); 4746 re_extmatch_out = make_extmatch();
4749 for (i = 0; i < subs.synt.in_use; i++) 4747 for (i = 0; i < subs.synt.in_use; i++)
4750 { 4748 {
4751 if (REG_MULTI) 4749 if (REG_MULTI)