]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.290 v7.4.290
authorBram Moolenaar <Bram@vim.org>
Tue, 13 May 2014 14:44:29 +0000 (16:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 13 May 2014 14:44:29 +0000 (16:44 +0200)
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.

src/regexp_nfa.c
src/testdir/test64.in
src/testdir/test64.ok
src/version.c

index d855df33bcf95a2595029aea70ee1216b95ea2c7..3873d9ab23140a413e96dacb314fe08f6e237cc6 100644 (file)
@@ -4324,8 +4324,10 @@ addstate(l, state, subs_arg, pim, off)
            {
                /* 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 ENABLE_LOG
index e3f5d82a4ddfbae18ab034b7db486ce5b6b763e7..2abdcd1c082e8e48a6a2f0a11e9d55a01193b3fc 100644 (file)
@@ -238,7 +238,11 @@ STARTTEST
 :call add(tl, [2, '\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
 :call add(tl, [2, '\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
 :call add(tl, [2, '\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
-:call add(tl, [2, '\v(a{-1,3})+','aa','aa','a'])
+:call add(tl, [2, '\v(a{-1,3})+', 'aa', 'aa', 'a'])
+:call add(tl, [2, '^\s\{-}\zs\( x\|x$\)', ' x', ' x', ' x'])
+:call add(tl, [2, '^\s\{-}\zs\(x\| x$\)', ' x', ' x', ' x'])
+:call add(tl, [2, '^\s\{-}\ze\(x\| x$\)', ' x', '', ' x'])
+:call add(tl, [2, '^\(\s\{-}\)\(x\| x$\)', ' x', ' x', '', ' x'])
 :"
 :" Test Character classes
 :call add(tl, [2, '\d\+e\d\d','test 10e23 fd','10e23'])
@@ -462,15 +466,15 @@ STARTTEST
 :    try
 :      let l = matchlist(text, pat)
 :    catch
-:      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"'
+:      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"'
 :    endtry
 :" check the match itself
 :    if len(l) == 0 && len(t) > matchidx
-:      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"'
+:      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"'
 :    elseif len(l) > 0 && len(t) == matchidx
-:      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match'
+:      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match'
 :    elseif len(t) > matchidx && l[0] != t[matchidx]
-:      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"'
+:      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"'
 :    else
 :      $put ='OK ' . engine . ' - ' . pat
 :    endif
@@ -483,7 +487,7 @@ STARTTEST
 :          let e = t[matchidx + i]
 :        endif
 :        if l[i] != e
-:          $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
+:          $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
 :        endif
 :      endfor
 :      unlet i
index 9fb6c60b9dc0d4561f84717e80af07d3550712f8..e7d173141adf89a3136b6ed371761b4769aad3dd 100644 (file)
@@ -533,6 +533,18 @@ OK 2 - \v(a{1,2}){-2,3}
 OK 0 - \v(a{-1,3})+
 OK 1 - \v(a{-1,3})+
 OK 2 - \v(a{-1,3})+
+OK 0 - ^\s\{-}\zs\( x\|x$\)
+OK 1 - ^\s\{-}\zs\( x\|x$\)
+OK 2 - ^\s\{-}\zs\( x\|x$\)
+OK 0 - ^\s\{-}\zs\(x\| x$\)
+OK 1 - ^\s\{-}\zs\(x\| x$\)
+OK 2 - ^\s\{-}\zs\(x\| x$\)
+OK 0 - ^\s\{-}\ze\(x\| x$\)
+OK 1 - ^\s\{-}\ze\(x\| x$\)
+OK 2 - ^\s\{-}\ze\(x\| x$\)
+OK 0 - ^\(\s\{-}\)\(x\| x$\)
+OK 1 - ^\(\s\{-}\)\(x\| x$\)
+OK 2 - ^\(\s\{-}\)\(x\| x$\)
 OK 0 - \d\+e\d\d
 OK 1 - \d\+e\d\d
 OK 2 - \d\+e\d\d
index 81ce691f90636824df360faabbbba89c47ac1476..fdda82c1f5d04cc265840ab68442bb0f3d65b8d7 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    290,
 /**/
     289,
 /**/