|
36 | 36 | { |
37 | 37 | NFA_SPLIT = -1024, |
38 | 38 | NFA_MATCH, |
39 | | - NFA_SKIP_CHAR, /* matches a 0-length char */ |
| 39 | + NFA_EMPTY, /* matches 0-length */ |
40 | 40 |
|
41 | 41 | NFA_START_COLL, /* [abc] start */ |
42 | 42 | NFA_END_COLL, /* [abc] end */ |
@@ -2005,8 +2005,8 @@ nfa_regpiece() |
2005 | 2005 | { |
2006 | 2006 | /* Ignore result of previous call to nfa_regatom() */ |
2007 | 2007 | post_ptr = post_start + my_post_start; |
2008 | | - /* NFA_SKIP_CHAR has 0-length and works everywhere */ |
2009 | | - EMIT(NFA_SKIP_CHAR); |
| 2008 | + /* NFA_EMPTY is 0-length and works everywhere */ |
| 2009 | + EMIT(NFA_EMPTY); |
2010 | 2010 | return OK; |
2011 | 2011 | } |
2012 | 2012 |
|
@@ -2170,16 +2170,16 @@ nfa_regbranch() |
2170 | 2170 | old_post_pos = (int)(post_ptr - post_start); |
2171 | 2171 | if (nfa_regconcat() == FAIL) |
2172 | 2172 | return FAIL; |
2173 | | - /* if concat is empty, skip a input char. But do emit a node */ |
| 2173 | + /* if concat is empty do emit a node */ |
2174 | 2174 | if (old_post_pos == (int)(post_ptr - post_start)) |
2175 | | - EMIT(NFA_SKIP_CHAR); |
| 2175 | + EMIT(NFA_EMPTY); |
2176 | 2176 | EMIT(NFA_CONCAT); |
2177 | 2177 | ch = peekchr(); |
2178 | 2178 | } |
2179 | 2179 |
|
2180 | | - /* Even if a branch is empty, emit one node for it */ |
| 2180 | + /* if a branch is empty, emit one node for it */ |
2181 | 2181 | if (old_post_pos == (int)(post_ptr - post_start)) |
2182 | | - EMIT(NFA_SKIP_CHAR); |
| 2182 | + EMIT(NFA_EMPTY); |
2183 | 2183 |
|
2184 | 2184 | return OK; |
2185 | 2185 | } |
@@ -2423,7 +2423,7 @@ nfa_set_code(c) |
2423 | 2423 | case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break; |
2424 | 2424 | case NFA_QUEST: STRCPY(code, "NFA_QUEST"); break; |
2425 | 2425 | case NFA_QUEST_NONGREEDY: STRCPY(code, "NFA_QUEST_NON_GREEDY"); break; |
2426 | | - case NFA_SKIP_CHAR: STRCPY(code, "NFA_SKIP_CHAR"); break; |
| 2426 | + case NFA_EMPTY: STRCPY(code, "NFA_EMPTY"); break; |
2427 | 2427 | case NFA_OR: STRCPY(code, "NFA_OR"); break; |
2428 | 2428 |
|
2429 | 2429 | case NFA_START_COLL: STRCPY(code, "NFA_START_COLL"); break; |
@@ -3067,7 +3067,7 @@ nfa_max_width(startstate, depth) |
3067 | 3067 | case NFA_ZSTART: |
3068 | 3068 | case NFA_ZEND: |
3069 | 3069 | case NFA_OPT_CHARS: |
3070 | | - case NFA_SKIP_CHAR: |
| 3070 | + case NFA_EMPTY: |
3071 | 3071 | case NFA_START_PATTERN: |
3072 | 3072 | case NFA_END_PATTERN: |
3073 | 3073 | case NFA_COMPOSING: |
@@ -3265,15 +3265,14 @@ post2nfa(postfix, end, nfa_calc_size) |
3265 | 3265 | PUSH(frag(e1.start, e2.out)); |
3266 | 3266 | break; |
3267 | 3267 |
|
3268 | | - case NFA_SKIP_CHAR: |
3269 | | - /* Symbol of 0-length, Used in a repetition |
3270 | | - * with max/min count of 0 */ |
| 3268 | + case NFA_EMPTY: |
| 3269 | + /* 0-length, used in a repetition with max/min count of 0 */ |
3271 | 3270 | if (nfa_calc_size == TRUE) |
3272 | 3271 | { |
3273 | 3272 | nstate++; |
3274 | 3273 | break; |
3275 | 3274 | } |
3276 | | - s = alloc_state(NFA_SKIP_CHAR, NULL, NULL); |
| 3275 | + s = alloc_state(NFA_EMPTY, NULL, NULL); |
3277 | 3276 | if (s == NULL) |
3278 | 3277 | goto theend; |
3279 | 3278 | PUSH(frag(s, list1(&s->out))); |
@@ -4209,7 +4208,7 @@ addstate(l, state, subs_arg, pim, off) |
4209 | 4208 | case NFA_MOPEN: |
4210 | 4209 | case NFA_ZEND: |
4211 | 4210 | case NFA_SPLIT: |
4212 | | - case NFA_SKIP_CHAR: |
| 4211 | + case NFA_EMPTY: |
4213 | 4212 | /* These nodes are not added themselves but their "out" and/or |
4214 | 4213 | * "out1" may be added below. */ |
4215 | 4214 | break; |
@@ -4337,7 +4336,7 @@ addstate(l, state, subs_arg, pim, off) |
4337 | 4336 | subs = addstate(l, state->out1, subs, pim, off); |
4338 | 4337 | break; |
4339 | 4338 |
|
4340 | | - case NFA_SKIP_CHAR: |
| 4339 | + case NFA_EMPTY: |
4341 | 4340 | case NFA_NOPEN: |
4342 | 4341 | case NFA_NCLOSE: |
4343 | 4342 | subs = addstate(l, state->out, subs, pim, off); |
@@ -5604,9 +5603,13 @@ nfa_regmatch(prog, start, submatch, m) |
5604 | 5603 | { |
5605 | 5604 | int in_use = m->norm.in_use; |
5606 | 5605 |
|
5607 | | - /* Copy submatch info for the recursive call, so that |
5608 | | - * \1 can be matched. */ |
| 5606 | + /* Copy submatch info for the recursive call, opposite |
| 5607 | + * of what happens on success below. */ |
5609 | 5608 | copy_sub_off(&m->norm, &t->subs.norm); |
| 5609 | +#ifdef FEAT_SYN_HL |
| 5610 | + if (nfa_has_zsubexpr) |
| 5611 | + copy_sub_off(&m->synt, &t->subs.synt); |
| 5612 | +#endif |
5610 | 5613 |
|
5611 | 5614 | /* |
5612 | 5615 | * First try matching the invisible match, then what |
@@ -5713,6 +5716,13 @@ nfa_regmatch(prog, start, submatch, m) |
5713 | 5716 | #endif |
5714 | 5717 | break; |
5715 | 5718 | } |
| 5719 | + /* Copy submatch info to the recursive call, opposite of what |
| 5720 | + * happens afterwards. */ |
| 5721 | + copy_sub_off(&m->norm, &t->subs.norm); |
| 5722 | +#ifdef FEAT_SYN_HL |
| 5723 | + if (nfa_has_zsubexpr) |
| 5724 | + copy_sub_off(&m->synt, &t->subs.synt); |
| 5725 | +#endif |
5716 | 5726 |
|
5717 | 5727 | /* First try matching the pattern. */ |
5718 | 5728 | result = recursive_regmatch(t->state, NULL, prog, |
|
0 commit comments