summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.380
blob: a8f4bcf65a1e5341da63a57b1acc7dd31c3e6a07 (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
315
316
317
318
To: vim_dev@googlegroups.com
Subject: Patch 7.3.380
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.3.380
Problem:    C-indenting wrong for a function header.
Solution:   Skip to the start paren. (Lech Lorens)
Files:	    src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok


*** ../vim-7.3.379/src/misc1.c	2011-12-14 20:05:17.000000000 +0100
--- src/misc1.c	2011-12-14 20:16:43.000000000 +0100
***************
*** 4943,4949 ****
  static int	cin_islinecomment __ARGS((char_u *));
  static int	cin_isterminated __ARGS((char_u *, int, int));
  static int	cin_isinit __ARGS((void));
! static int	cin_isfuncdecl __ARGS((char_u **, linenr_T));
  static int	cin_isif __ARGS((char_u *));
  static int	cin_iselse __ARGS((char_u *));
  static int	cin_isdo __ARGS((char_u *));
--- 4943,4949 ----
  static int	cin_islinecomment __ARGS((char_u *));
  static int	cin_isterminated __ARGS((char_u *, int, int));
  static int	cin_isinit __ARGS((void));
! static int	cin_isfuncdecl __ARGS((char_u **, linenr_T, linenr_T, int, int));
  static int	cin_isif __ARGS((char_u *));
  static int	cin_iselse __ARGS((char_u *));
  static int	cin_isdo __ARGS((char_u *));
***************
*** 5585,5605 ****
   * "sp" points to a string with the line.  When looking at other lines it must
   * be restored to the line.  When it's NULL fetch lines here.
   * "lnum" is where we start looking.
   */
      static int
! cin_isfuncdecl(sp, first_lnum)
      char_u	**sp;
      linenr_T	first_lnum;
  {
      char_u	*s;
      linenr_T	lnum = first_lnum;
      int		retval = FALSE;
  
      if (sp == NULL)
  	s = ml_get(lnum);
      else
  	s = *sp;
  
      /* Ignore line starting with #. */
      if (cin_ispreproc(s))
  	return FALSE;
--- 5585,5621 ----
   * "sp" points to a string with the line.  When looking at other lines it must
   * be restored to the line.  When it's NULL fetch lines here.
   * "lnum" is where we start looking.
+  * "min_lnum" is the line before which we will not be looking.
   */
      static int
! cin_isfuncdecl(sp, first_lnum, min_lnum, ind_maxparen, ind_maxcomment)
      char_u	**sp;
      linenr_T	first_lnum;
+     linenr_T	min_lnum;
+     int		ind_maxparen;
+     int		ind_maxcomment;
  {
      char_u	*s;
      linenr_T	lnum = first_lnum;
      int		retval = FALSE;
+     pos_T	*trypos;
+     int		just_started = TRUE;
  
      if (sp == NULL)
  	s = ml_get(lnum);
      else
  	s = *sp;
  
+     if (find_last_paren(s, '(', ')')
+ 	&& (trypos = find_match_paren(ind_maxparen, ind_maxcomment)) != NULL)
+     {
+ 	lnum = trypos->lnum;
+ 	if (lnum < min_lnum)
+ 	    return FALSE;
+ 
+ 	s = ml_get(lnum);
+     }
+ 
      /* Ignore line starting with #. */
      if (cin_ispreproc(s))
  	return FALSE;
***************
*** 5650,5662 ****
  	    /* Require a comma at end of the line or a comma or ')' at the
  	     * start of next line. */
  	    s = skipwhite(s);
! 	    if (!comma && *s != ',' && *s != ')')
  		break;
  	}
  	else if (cin_iscomment(s))	/* ignore comments */
  	    s = cin_skipcomment(s);
  	else
  	    ++s;
      }
  
  done:
--- 5666,5682 ----
  	    /* Require a comma at end of the line or a comma or ')' at the
  	     * start of next line. */
  	    s = skipwhite(s);
! 	    if (!just_started && (!comma && *s != ',' && *s != ')'))
  		break;
+ 	    just_started = FALSE;
  	}
  	else if (cin_iscomment(s))	/* ignore comments */
  	    s = cin_skipcomment(s);
  	else
+ 	{
  	    ++s;
+ 	    just_started = FALSE;
+ 	}
      }
  
  done:
***************
*** 7158,7164 ****
  			 * (it's a variable declaration).
  			 */
  			if (start_brace != BRACE_IN_COL0
! 				|| !cin_isfuncdecl(&l, curwin->w_cursor.lnum))
  			{
  			    /* if the line is terminated with another ','
  			     * it is a continued variable initialization.
--- 7178,7185 ----
  			 * (it's a variable declaration).
  			 */
  			if (start_brace != BRACE_IN_COL0
! 				|| !cin_isfuncdecl(&l, curwin->w_cursor.lnum,
! 					     0, ind_maxparen, ind_maxcomment))
  			{
  			    /* if the line is terminated with another ','
  			     * it is a continued variable initialization.
***************
*** 8019,8025 ****
  		&& vim_strchr(theline, '}') == NULL
  		&& !cin_ends_in(theline, (char_u *)":", NULL)
  		&& !cin_ends_in(theline, (char_u *)",", NULL)
! 		&& cin_isfuncdecl(NULL, cur_curpos.lnum + 1)
  		&& !cin_isterminated(theline, FALSE, TRUE))
  	{
  	    amount = ind_func_type;
--- 8040,8048 ----
  		&& vim_strchr(theline, '}') == NULL
  		&& !cin_ends_in(theline, (char_u *)":", NULL)
  		&& !cin_ends_in(theline, (char_u *)",", NULL)
! 		&& cin_isfuncdecl(NULL, cur_curpos.lnum + 1,
! 				  cur_curpos.lnum + 1,
! 				  ind_maxparen, ind_maxcomment)
  		&& !cin_isterminated(theline, FALSE, TRUE))
  	{
  	    amount = ind_func_type;
***************
*** 8125,8131 ****
  		 * If the line looks like a function declaration, and we're
  		 * not in a comment, put it the left margin.
  		 */
! 		if (cin_isfuncdecl(NULL, cur_curpos.lnum))  /* XXX */
  		    break;
  		l = ml_get_curline();
  
--- 8148,8155 ----
  		 * If the line looks like a function declaration, and we're
  		 * not in a comment, put it the left margin.
  		 */
! 		if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0,
! 				   ind_maxparen, ind_maxcomment))  /* XXX */
  		    break;
  		l = ml_get_curline();
  
***************
*** 8173,8179 ****
  		 * line (and the ones that follow) needs to be indented as
  		 * parameters.
  		 */
! 		if (cin_isfuncdecl(&l, curwin->w_cursor.lnum))
  		{
  		    amount = ind_param;
  		    break;
--- 8197,8204 ----
  		 * line (and the ones that follow) needs to be indented as
  		 * parameters.
  		 */
! 		if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0,
! 				   ind_maxparen, ind_maxcomment))
  		{
  		    amount = ind_param;
  		    break;
*** ../vim-7.3.379/src/testdir/test3.in	2011-12-14 20:05:17.000000000 +0100
--- src/testdir/test3.in	2011-12-14 20:11:24.000000000 +0100
***************
*** 1429,1435 ****
  
  STARTTEST
  :set cino&
! 2kdd=4][
  ENDTEST
  
  void func(void)
--- 1429,1435 ----
  
  STARTTEST
  :set cino&
! 2kdd=7][
  ENDTEST
  
  void func(void)
***************
*** 1478,1484 ****
  	3, 4,
  	5, 6};
  
! printf("Don't you dare indent this line incorrectly!\n);
  }
  
  STARTTEST
--- 1478,1506 ----
  	3, 4,
  	5, 6};
  
! printf("Don't you dare indent this line incorrectly!\n");
! }
! 
! void
! func4(a, b,
! 		c)
! int a;
! int b;
! int c;
! {
! }
! 
! void
! func5(
! 		int a,
! 		int b)
! {
! }
! 
! void
! func6(
! 		int a)
! {
  }
  
  STARTTEST
*** ../vim-7.3.379/src/testdir/test3.ok	2011-12-14 20:05:17.000000000 +0100
--- src/testdir/test3.ok	2011-12-14 20:11:24.000000000 +0100
***************
*** 1331,1337 ****
  		3, 4,
  		5, 6};
  
! 	printf("Don't you dare indent this line incorrectly!\n);
  }
  
  
--- 1331,1359 ----
  		3, 4,
  		5, 6};
  
! 	printf("Don't you dare indent this line incorrectly!\n");
! }
! 
! 	void
! func4(a, b,
! 		c)
! 	int a;
! 	int b;
! 	int c;
! {
! }
! 
! 	void
! func5(
! 		int a,
! 		int b)
! {
! }
! 
! 	void
! func6(
! 		int a)
! {
  }
  
  
*** ../vim-7.3.379/src/version.c	2011-12-14 20:05:17.000000000 +0100
--- src/version.c	2011-12-14 20:20:50.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     380,
  /**/

-- 
"Intelligence has much less practical application than you'd think."
		  -- Scott Adams, Dilbert.

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