On Do, 16 Jun 2016, fritzophrenic wrote:

> > Can you please set verbose before searching?
> 
> I did "gvim -N -u NONE -i NONE" then ":set verbose=15". Searching for 
> "\%(|\u.*\)\@<=[^|\t]\+$" in a long line with no uppercase characters still 
> matches, and I get no messages at all. 
> 
> > I wonder if this happens, because the NFA engine stops because it returns 
> > NFA_TOO_EXPENSIVE and then the retry with the old engine is somehow 
> > confused?
> 
> I don't think so (and I guess I proved it with the verbose setting, unless I 
> did that wrong), because I can force the new engine with \%#=2 or by setting 
> 'regexpengine', and the pattern works as expected.

Okay, I checked the problem. My suspicion was correct, that patch 
7.4.494 causes this problem, because after recursive_regmatch() returns 
NFA_TOO_EXPENSIVE nfa_listid will be restored from save_nfa_listid and 
then the exit condition in nfa_regmatch does not match anymore.

Attached is a patch, including a test.
(attachment won't be visible in github, see the thread 
https://groups.google.com/d/msg/vim_dev/BE0ISqcD3aI/ZGeOMrFQJgAJ for the 
patch)

Best,
Christian
-- 
Die beste kurzfristige Erfolgsmeldung ist das Mienenspiel deines
Bankdirektors.
                -- Helmar Nahr

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From e1580984bd0299422be8e9a5fc4edfc87154dd5a Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Tue, 28 Jun 2016 19:54:53 +0200
Subject: [PATCH] do not restore nfa_listid state, when pattern too expensive

Currently, nfa_listid is restored after a call to recursive_regmatch,
which may cause the exit condition in nfa_regmatch()

if (prog->re_engine == AUTOMATIC_ENGINE && nfa_listid >= NFA_MAX_STATES)

to fail. In that case, the automatic engine might find an wrong match.

fixes #867

Add a test for that bug.
---
 src/regexp_nfa.c      | 7 +++++--
 src/testdir/test64.in | 3 ++-
 src/testdir/test64.ok | 3 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 6b83699..87efef3 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -5210,9 +5210,12 @@ recursive_regmatch(
     if (REG_MULTI)
 	regline = reg_getline(reglnum);
     reginput = regline + save_reginput_col;
-    nfa_match = save_nfa_match;
+    if (result != NFA_TOO_EXPENSIVE)
+    {
+	nfa_match = save_nfa_match;
+	nfa_listid = save_nfa_listid;
+    }
     nfa_endp = save_nfa_endp;
-    nfa_listid = save_nfa_listid;
 
 #ifdef ENABLE_LOG
     log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
diff --git a/src/testdir/test64.in b/src/testdir/test64.in
index fd19d3a..360418c 100644
--- a/src/testdir/test64.in
+++ b/src/testdir/test64.in
@@ -578,7 +578,7 @@ Gop:"
 :" Check patterns matching cursor position.
 :func! Postest()
  new
- call setline(1, ['ffooooo', 'boboooo', 'zoooooo', 'koooooo', 'moooooo', "\t\t\tfoo", 'abababababababfoo', 'bababababababafoo', '********_'])
+ call setline(1, ['ffooooo', 'boboooo', 'zoooooo', 'koooooo', 'moooooo', "\t\t\tfoo", 'abababababababfoo', 'bababababababafoo', '********_', '        xxxxxxxxxxxx    xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx  xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx  xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx'])
  call setpos('.', [0, 1, 0, 0])
  s/\%>3c.//g
  call setpos('.', [0, 2, 4, 0])
@@ -590,6 +590,7 @@ Gop:"
  %s/\%>6l\%3c./!/g
  %s/\%>7l\%12c./?/g
  %s/\%>7l\%<9l\%>5v\%<8v./#/g
+ $s/\%(|\u.*\)\@<=[^|\t]\+$//ge
  1,$yank
  quit!
 endfunc
diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok
index 92f06ea..c218f8e 100644
--- a/src/testdir/test64.ok
+++ b/src/testdir/test64.ok
@@ -1076,6 +1076,7 @@ moooooo
 ab!babababababfoo
 ba!ab##abab?bafoo
 **!*****_
+  !     xxx?xxxxxxxx    xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx  xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx  xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx
 -1-
 ffo
 bob
@@ -1086,6 +1087,7 @@ moooooo
 ab!babababababfoo
 ba!ab##abab?bafoo
 **!*****_
+  !     xxx?xxxxxxxx    xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx  xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx  xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx
 -2-
 ffo
 bob
@@ -1096,6 +1098,7 @@ moooooo
 ab!babababababfoo
 ba!ab##abab?bafoo
 **!*****_
+  !     xxx?xxxxxxxx    xxxx xxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxx xxxxx xxxxxxx xx xxxx xxxxxxxx xxxx xxxxxxxxxxx xxx xxxxxxx xxxxxxxxx xx xxxxxx xx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxx xxxxxxxx xxxxxxxxx xxxx xxx xxxx xxx xxx xxxxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxxx xx xxxxx xxx xxxxxxxx xxxxxx xxx xxx xxxxxxxxx xxxxxxx x xxxxxxxxx xx xxxxxx xxxxxxx  xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxx xxx xxxxxxxx xxxxxxx  xxxx xxx xxxxxx xxxxx xxxxx xx xxxxxx xxxxxxx xxx xxxxxxxxxxxx xxxx xxxxxxxxx xxxxxx xxxxxx xxxxx xxx xxxxxxx xxxxxxxxxxxxxxxx xxxxxxxxx  xxxxxxxxxx xxxx xx xxxxxxxx xxx xxxxxxxxxxx xxxxx
 Test
 Test END
 EN
-- 
2.1.4

Raspunde prin e-mail lui