From 057e36ea1975bc0da720593e60407263bcb25806 Mon Sep 17 00:00:00 2001 From: oni-link Date: Thu, 22 May 2014 12:41:41 +0200 Subject: vim-patch:7.4.290 #753 Problem: A non-greedy match followed by a branch is too greedy. (Ingo Karkat) Solution: Add NFA_MATCH when it is already in the state list if the position differs. https://code.google.com/p/vim/source/detail?r=b871734bf54ea185dbd2cc759d86dbfbe21cde26 --- src/nvim/regexp_nfa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/nvim/regexp_nfa.c') diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index a4e7f1df13..8781e06649 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -3877,8 +3877,10 @@ addstate ( if (state->lastlist[nfa_ll_index] == l->id && state->c != NFA_SKIP) { /* This state is already in the list, don't add it again, * unless it is an MOPEN that is used for a backreference or - * when there is a PIM. */ - if (!nfa_has_backref && pim == NULL && !l->has_pim) { + * when there is a PIM. For NFA_MATCH check the position, + * lower position is preferred. */ + if (!nfa_has_backref && pim == NULL && !l->has_pim + && state->c != NFA_MATCH) { skip_add: #ifdef REGEXP_DEBUG nfa_set_code(state->c); -- cgit