diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-09-25 18:16:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-09-25 18:16:38 +0200 |
commit | f211884fa151a3c39b1a85a115d6d88ce85bbe54 (patch) | |
tree | f0c0f08921f79390a278b9c15336fe4438b8c8ff /src/regexp_nfa.c | |
parent | 699c12076de7d8811045cd2b98df78d7108b68ed (diff) | |
download | vim-git-f211884fa151a3c39b1a85a115d6d88ce85bbe54.tar.gz |
updated for version 7.4.037v7.4.037
Problem: Using "\ze" in a sub-pattern does not result in the end of the
match to be set. (Axel Bender)
Solution: Copy the end of match position when a recursive match was
successful.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r-- | src/regexp_nfa.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index cd58b618e..216459c4d 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -3822,6 +3822,7 @@ static void copy_pim __ARGS((nfa_pim_T *to, nfa_pim_T *from)); static void clear_sub __ARGS((regsub_T *sub)); static void copy_sub __ARGS((regsub_T *to, regsub_T *from)); static void copy_sub_off __ARGS((regsub_T *to, regsub_T *from)); +static void copy_ze_off __ARGS((regsub_T *to, regsub_T *from)); static int sub_equal __ARGS((regsub_T *sub1, regsub_T *sub2)); static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen)); static int has_state_with_pos __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim)); @@ -3909,6 +3910,29 @@ copy_sub_off(to, from) } /* + * Like copy_sub() but only do the end of the main match if \ze is present. + */ + static void +copy_ze_off(to, from) + regsub_T *to; + regsub_T *from; +{ + if (nfa_has_zend) + { + if (REG_MULTI) + { + if (from->list.multi[0].end.lnum >= 0) + to->list.multi[0].end = from->list.multi[0].end; + } + else + { + if (from->list.line[0].end != NULL) + to->list.line[0].end = from->list.line[0].end; + } + } +} + +/* * Return TRUE if "sub1" and "sub2" have the same start positions. */ static int @@ -5308,6 +5332,7 @@ find_match_text(startcol, regstart, match_text) * When "nfa_endp" is not NULL it is a required end-of-match position. * * Return TRUE if there is a match, FALSE otherwise. + * When there is a match "submatch" contains the positions. * Note: Caller must ensure that: start != NULL. */ static int @@ -5633,6 +5658,9 @@ nfa_regmatch(prog, start, submatch, m) if (nfa_has_zsubexpr) copy_sub_off(&t->subs.synt, &m->synt); #endif + /* If the pattern has \ze and it matched in the + * sub pattern, use it. */ + copy_ze_off(&t->subs.norm, &m->norm); /* t->state->out1 is the corresponding * END_INVISIBLE node; Add its out to the current |