diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-12-16 19:59:37 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-12-16 19:59:37 +0100 |
commit | 890dd05492d88d48eee1dda7f7a1811d027ce7ca (patch) | |
tree | 94ff6a4e197a1c1947b5a311f92c2ce88c7c3dab /src/regexp_nfa.c | |
parent | a1d5c154dbd5fbe317726bbf2ba99632b91878f4 (diff) | |
download | vim-git-890dd05492d88d48eee1dda7f7a1811d027ce7ca.tar.gz |
patch 8.0.1397: pattern with \& following nothing gives an errorv8.0.1397
Problem: Pattern with \& following nothing gives an error.
Solution: Emit an empty node when needed.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r-- | src/regexp_nfa.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index feb17bcaf..afd42383c 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -2321,7 +2321,6 @@ nfa_regconcat(void) static int nfa_regbranch(void) { - int ch; int old_post_pos; old_post_pos = (int)(post_ptr - post_start); @@ -2330,11 +2329,13 @@ nfa_regbranch(void) if (nfa_regconcat() == FAIL) return FAIL; - ch = peekchr(); /* Try next concats */ - while (ch == Magic('&')) + while (peekchr() == Magic('&')) { skipchr(); + /* if concat is empty do emit a node */ + if (old_post_pos == (int)(post_ptr - post_start)) + EMIT(NFA_EMPTY); EMIT(NFA_NOPEN); EMIT(NFA_PREV_ATOM_NO_WIDTH); old_post_pos = (int)(post_ptr - post_start); @@ -2344,7 +2345,6 @@ nfa_regbranch(void) if (old_post_pos == (int)(post_ptr - post_start)) EMIT(NFA_EMPTY); EMIT(NFA_CONCAT); - ch = peekchr(); } /* if a branch is empty, emit one node for it */ |