summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.262
blob: ef29032e2bce47b8ac4a785827ad52b520aaee6b (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
To: vim_dev@googlegroups.com
Subject: Patch 7.4.262
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.262
Problem:    Duplicate code in regexec().
Solution:   Add line_lbr flag to regexec_nl().
Files:	    src/regexp.c, src/regexp_nfa.c, src/regexp.h


*** ../vim-7.4.261/src/regexp.c	2014-04-23 18:48:43.546854558 +0200
--- src/regexp.c	2014-04-23 18:59:38.606838773 +0200
***************
*** 3709,3733 ****
  /* TRUE if using multi-line regexp. */
  #define REG_MULTI	(reg_match == NULL)
  
! static int  bt_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
  
  /*
   * Match a regexp against a string.
   * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
   * Uses curbuf for line count and 'iskeyword'.
   *
   * Return TRUE if there is a match, FALSE if not.
   */
      static int
! bt_regexec(rmp, line, col)
      regmatch_T	*rmp;
      char_u	*line;	/* string to match against */
      colnr_T	col;	/* column to start looking for match */
  {
      reg_match = rmp;
      reg_mmatch = NULL;
      reg_maxline = 0;
!     reg_line_lbr = FALSE;
      reg_buf = curbuf;
      reg_win = NULL;
      ireg_ic = rmp->rm_ic;
--- 3709,3736 ----
  /* TRUE if using multi-line regexp. */
  #define REG_MULTI	(reg_match == NULL)
  
! static int  bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
! 
  
  /*
   * Match a regexp against a string.
   * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
   * Uses curbuf for line count and 'iskeyword'.
+  * if "line_lbr" is TRUE  consider a "\n" in "line" to be a line break.
   *
   * Return TRUE if there is a match, FALSE if not.
   */
      static int
! bt_regexec_nl(rmp, line, col, line_lbr)
      regmatch_T	*rmp;
      char_u	*line;	/* string to match against */
      colnr_T	col;	/* column to start looking for match */
+     int		line_lbr;
  {
      reg_match = rmp;
      reg_mmatch = NULL;
      reg_maxline = 0;
!     reg_line_lbr = line_lbr;
      reg_buf = curbuf;
      reg_win = NULL;
      ireg_ic = rmp->rm_ic;
***************
*** 3738,3772 ****
      return (bt_regexec_both(line, col, NULL) != 0);
  }
  
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
- 
- static int  bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
- 
- /*
-  * Like vim_regexec(), but consider a "\n" in "line" to be a line break.
-  */
-     static int
- bt_regexec_nl(rmp, line, col)
-     regmatch_T	*rmp;
-     char_u	*line;	/* string to match against */
-     colnr_T	col;	/* column to start looking for match */
- {
-     reg_match = rmp;
-     reg_mmatch = NULL;
-     reg_maxline = 0;
-     reg_line_lbr = TRUE;
-     reg_buf = curbuf;
-     reg_win = NULL;
-     ireg_ic = rmp->rm_ic;
- #ifdef FEAT_MBYTE
-     ireg_icombine = FALSE;
- #endif
-     ireg_maxcol = 0;
-     return (bt_regexec_both(line, col, NULL) != 0);
- }
- #endif
- 
  static long bt_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
  
  /*
--- 3741,3746 ----
***************
*** 7985,7995 ****
  {
      bt_regcomp,
      bt_regfree,
-     bt_regexec,
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
      bt_regexec_nl,
- #endif
      bt_regexec_multi
  #ifdef DEBUG
      ,(char_u *)""
--- 7959,7965 ----
***************
*** 8003,8013 ****
  {
      nfa_regcomp,
      nfa_regfree,
-     nfa_regexec,
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
      nfa_regexec_nl,
- #endif
      nfa_regexec_multi
  #ifdef DEBUG
      ,(char_u *)""
--- 7973,7979 ----
***************
*** 8131,8137 ****
      char_u      *line;  /* string to match against */
      colnr_T     col;    /* column to start looking for match */
  {
!     return rmp->regprog->engine->regexec(rmp, line, col);
  }
  
  #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
--- 8097,8103 ----
      char_u      *line;  /* string to match against */
      colnr_T     col;    /* column to start looking for match */
  {
!     return rmp->regprog->engine->regexec_nl(rmp, line, col, FALSE);
  }
  
  #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
***************
*** 8145,8151 ****
      char_u *line;
      colnr_T col;
  {
!     return rmp->regprog->engine->regexec_nl(rmp, line, col);
  }
  #endif
  
--- 8111,8117 ----
      char_u *line;
      colnr_T col;
  {
!     return rmp->regprog->engine->regexec_nl(rmp, line, col, TRUE);
  }
  #endif
  
*** ../vim-7.4.261/src/regexp_nfa.c	2014-04-06 21:33:39.675363743 +0200
--- src/regexp_nfa.c	2014-04-23 19:00:44.354837189 +0200
***************
*** 311,317 ****
  static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
  static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
  static void nfa_regfree __ARGS((regprog_T *prog));
! static int nfa_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
  static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
  static int match_follows __ARGS((nfa_state_T *startstate, int depth));
  static int failure_chance __ARGS((nfa_state_T *state, int depth));
--- 311,317 ----
  static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
  static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
  static void nfa_regfree __ARGS((regprog_T *prog));
! static int  nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
  static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
  static int match_follows __ARGS((nfa_state_T *startstate, int depth));
  static int failure_chance __ARGS((nfa_state_T *state, int depth));
***************
*** 7060,7078 ****
   * Match a regexp against a string.
   * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
   * Uses curbuf for line count and 'iskeyword'.
   *
   * Return TRUE if there is a match, FALSE if not.
   */
      static int
! nfa_regexec(rmp, line, col)
      regmatch_T	*rmp;
      char_u	*line;	/* string to match against */
      colnr_T	col;	/* column to start looking for match */
  {
      reg_match = rmp;
      reg_mmatch = NULL;
      reg_maxline = 0;
!     reg_line_lbr = FALSE;
      reg_buf = curbuf;
      reg_win = NULL;
      ireg_ic = rmp->rm_ic;
--- 7060,7080 ----
   * Match a regexp against a string.
   * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
   * Uses curbuf for line count and 'iskeyword'.
+  * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
   *
   * Return TRUE if there is a match, FALSE if not.
   */
      static int
! nfa_regexec_nl(rmp, line, col, line_lbr)
      regmatch_T	*rmp;
      char_u	*line;	/* string to match against */
      colnr_T	col;	/* column to start looking for match */
+     int		line_lbr;
  {
      reg_match = rmp;
      reg_mmatch = NULL;
      reg_maxline = 0;
!     reg_line_lbr = line_lbr;
      reg_buf = curbuf;
      reg_win = NULL;
      ireg_ic = rmp->rm_ic;
***************
*** 7083,7117 ****
      return (nfa_regexec_both(line, col) != 0);
  }
  
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
- 
- static int  nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
- 
- /*
-  * Like nfa_regexec(), but consider a "\n" in "line" to be a line break.
-  */
-     static int
- nfa_regexec_nl(rmp, line, col)
-     regmatch_T	*rmp;
-     char_u	*line;	/* string to match against */
-     colnr_T	col;	/* column to start looking for match */
- {
-     reg_match = rmp;
-     reg_mmatch = NULL;
-     reg_maxline = 0;
-     reg_line_lbr = TRUE;
-     reg_buf = curbuf;
-     reg_win = NULL;
-     ireg_ic = rmp->rm_ic;
- #ifdef FEAT_MBYTE
-     ireg_icombine = FALSE;
- #endif
-     ireg_maxcol = 0;
-     return (nfa_regexec_both(line, col) != 0);
- }
- #endif
- 
  
  /*
   * Match a regexp against multiple lines.
--- 7085,7090 ----
*** ../vim-7.4.261/src/regexp.h	2013-06-11 10:53:14.000000000 +0200
--- src/regexp.h	2014-04-23 18:58:18.614840701 +0200
***************
*** 149,159 ****
  {
      regprog_T	*(*regcomp)(char_u*, int);
      void	(*regfree)(regprog_T *);
!     int		(*regexec)(regmatch_T*, char_u*, colnr_T);
! #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
! 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
!     int		(*regexec_nl)(regmatch_T*, char_u*, colnr_T);
! #endif
      long	(*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
  #ifdef DEBUG
      char_u	*expr;
--- 149,155 ----
  {
      regprog_T	*(*regcomp)(char_u*, int);
      void	(*regfree)(regprog_T *);
!     int		(*regexec_nl)(regmatch_T*, char_u*, colnr_T, int);
      long	(*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
  #ifdef DEBUG
      char_u	*expr;
*** ../vim-7.4.261/src/version.c	2014-04-23 18:48:43.546854558 +0200
--- src/version.c	2014-04-23 18:52:20.102849340 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     262,
  /**/

-- 
From "know your smileys":
 ~#:-(	I just washed my hair, and I can't do nuthin' with it.

 /// 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    ///