aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp_nfa.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-12 18:06:17 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-12 18:09:43 -0400
commitcfb2383c26847e9332d1283fa15753b09d322f2f (patch)
treebf9ec7c1ab53da9996f07d0007f42d97eee15584 /src/nvim/regexp_nfa.c
parent3fd2efdb26a50e252aa0c463ecd4f44755fbd744 (diff)
downloadrneovim-cfb2383c26847e9332d1283fa15753b09d322f2f.tar.gz
rneovim-cfb2383c26847e9332d1283fa15753b09d322f2f.tar.bz2
rneovim-cfb2383c26847e9332d1283fa15753b09d322f2f.zip
vim-patch:8.0.1397: pattern with \& following nothing gives an error
Problem: Pattern with \& following nothing gives an error. Solution: Emit an empty node when needed. https://github.com/vim/vim/commit/890dd05492d88d48eee1dda7f7a1811d027ce7ca
Diffstat (limited to 'src/nvim/regexp_nfa.c')
-rw-r--r--src/nvim/regexp_nfa.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 3b905f5efc..2536de27c1 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -2131,7 +2131,6 @@ static int nfa_regconcat(void)
*/
static int nfa_regbranch(void)
{
- int ch;
int old_post_pos;
old_post_pos = (int)(post_ptr - post_start);
@@ -2140,10 +2139,13 @@ static int 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);
@@ -2153,7 +2155,6 @@ static int 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 */