summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.290
blob: e2e1e62bb7dbacde758a3d5ef36478fe67292c30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
To: vim_dev@googlegroups.com
Subject: Patch 7.4.290
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.290
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.
Files:	    src/testdir/test64.in, src/testdir/test64.ok, src/regexp_nfa.c


*** ../vim-7.4.289/src/testdir/test64.in	2014-05-13 15:56:45.017670668 +0200
--- src/testdir/test64.in	2014-05-13 16:15:57.213680754 +0200
***************
*** 238,244 ****
  :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'])
  :"
  :" Test Character classes
  :call add(tl, [2, '\d\+e\d\d','test 10e23 fd','10e23'])
--- 238,248 ----
  :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, '^\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,476 ****
  :    try
  :      let l = matchlist(text, pat)
  :    catch
! :      $put ='ERROR: 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] . '\"'
  :    elseif len(l) > 0 && len(t) == matchidx
! :      $put ='ERROR: 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] . '\"'
  :    else
  :      $put ='OK ' . engine . ' - ' . pat
  :    endif
--- 466,480 ----
  :    try
  :      let l = matchlist(text, pat)
  :    catch
! :      $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 ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"'
  :    elseif len(l) > 0 && len(t) == matchidx
! :      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match'
  :    elseif len(t) > matchidx && l[0] != t[matchidx]
! :      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"'
  :    else
  :      $put ='OK ' . engine . ' - ' . pat
  :    endif
***************
*** 483,489 ****
  :          let e = t[matchidx + i]
  :        endif
  :        if l[i] != e
! :          $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
  :        endif
  :      endfor
  :      unlet i
--- 487,493 ----
  :          let e = t[matchidx + i]
  :        endif
  :        if l[i] != e
! :          $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
  :        endif
  :      endfor
  :      unlet i
*** ../vim-7.4.289/src/testdir/test64.ok	2014-05-13 15:56:45.017670668 +0200
--- src/testdir/test64.ok	2014-05-13 16:39:35.077693166 +0200
***************
*** 533,538 ****
--- 533,550 ----
  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
*** ../vim-7.4.289/src/regexp_nfa.c	2014-05-13 15:56:45.021670668 +0200
--- src/regexp_nfa.c	2014-05-13 16:37:58.481692320 +0200
***************
*** 4324,4331 ****
  	    {
  		/* 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)
  		{
  skip_add:
  #ifdef ENABLE_LOG
--- 4324,4333 ----
  	    {
  		/* 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. 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
*** ../vim-7.4.289/src/version.c	2014-05-13 15:56:45.025670668 +0200
--- src/version.c	2014-05-13 16:13:33.953679500 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     290,
  /**/

-- 
Although the scythe isn't pre-eminent among the weapons of war, anyone who
has been on the wrong end of, say, a peasants' revolt will know that in
skilled hands it is fearsome.
					-- (Terry Pratchett, Mort)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///