]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.504
- new
[packages/vim.git] / 6.2.504
1 To: vim-dev@vim.org
2 Subject: Patch 6.2.504
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 6.2.504
11 Problem:    Various problems with 'cindent', among which that a
12             list of variable declarations is not indented properly.
13 Solution:   Fix the wrong indenting.  Improve indenting of C++ methods.
14             Add the 'i', 'b' and 'W' options to 'cinoptions'. (mostly by
15             Helmut Stiegler)
16             Improve indenting of preprocessor-continuation lines.
17 Files:      runtime/doc/indent.txt, src/misc1.c, src/testdir/test3.in,
18             src/testdir/test3.ok
19
20
21 *** ../vim-6.2.503/runtime/doc/indent.txt       Sun Jun  1 12:20:33 2003
22 --- runtime/doc/indent.txt      Sun Apr 25 11:57:22 2004
23 ***************
24 *** 1,4 ****
25 ! *indent.txt*    For Vim version 6.2.  Last change: 2003 May 04
26   
27   
28                   VIM REFERENCE MANUAL    by Bram Moolenaar
29 --- 1,4 ----
30 ! *indent.txt*    For Vim version 6.2.  Last change: 2004 Apr 25
31   
32   
33                   VIM REFERENCE MANUAL    by Bram Moolenaar
34 ***************
35 *** 228,234 ****
36                        a = a + 1;                 b = b + 1;
37   <
38         lN    If N != 0 Vim will align with a case label instead of the
39 !             statement after it.
40   
41                 cino=                       cino=l1 >
42                     switch (a) {              switch (a) {
43 --- 228,234 ----
44                        a = a + 1;                 b = b + 1;
45   <
46         lN    If N != 0 Vim will align with a case label instead of the
47 !             statement after it in the same line.
48   
49                 cino=                       cino=l1 >
50                     switch (a) {              switch (a) {
51 ***************
52 *** 236,241 ****
53 --- 236,256 ----
54                                     break;            break;
55                                 }                 }
56   <
57 +       bN    If N != 0 Vim will align a final "break" with the case label,
58 +             so that case..break looks like a sort of block. (default: 0).
59
60 +               cino=               cino=b1 >
61 +                 switch (x)          switch(x)
62 +                 {                   {
63 +                     case 1:             case 1:
64 +                         a = b;              a = b;
65 +                         break;          break;
66
67 +                     default:            default:
68 +                         a = 0;              a = 0;
69 +                         break;          break;
70 +                 }                   }
71 + <
72         gN    Place C++ scope declarations N characters from the indent of the
73               block they are in.  (default 'shiftwidth').  A scope declaration
74               can be "public:", "protected:" or "private:".
75 ***************
76 *** 271,276 ****
77 --- 286,304 ----
78                       int             int                        int
79                   func()              func()              func()
80   <
81 +       iN    Indent C++ base class declarations and contructor
82 +             initializations, if they start in a new line (otherwise they
83 +             are aligned at the right side of the ':').
84 +             (default 'shiftwidth').
85
86 +               cino=                     cino=i0 >
87 +                 class MyClass :           class MyClass :
88 +                     public BaseClass      public BaseClass
89 +                 {}                        {}
90 +                 MyClass::MyClass() :      MyClass::MyClass() :
91 +                     BaseClass(3)          BaseClass(3)
92 +                 {}                        {}
93 + <
94         +N    Indent a continuation line (a line that spills onto the next) N
95               additional characters.  (default 'shiftwidth').
96   
97 ***************
98 *** 347,352 ****
99 --- 375,394 ----
100                          && (   c2              && (   c2
101                                 || c3))             || c3))
102                       foo;                      foo;
103 + <
104 +       WN    When in unclosed parentheses and N is non-zero and either
105 +             using "(0" or "u0", respectively and the unclosed parentheses is
106 +             the last non-white character in its line and it is not the
107 +             closing parentheses, indent the following line N characters
108 +             relative to the outer context (i.e. start of the line or the
109 +             next unclosed parentheses). (default: 0).
110
111 +               cino=(0                    cino=(0,W4 >
112 +                 a_long_line(              a_long_line(
113 +                             argument,         argument,
114 +                             argument);        argument);
115 +                 a_short_line(argument,    a_short_line(argument,
116 +                              argument);                argument);
117   <
118         mN    When N is non-zero, line up a line starting with a closing
119               parentheses with the first character of the line with the
120 *** ../vim-6.2.503/src/misc1.c  Mon Apr 19 20:26:43 2004
121 --- src/misc1.c Mon Apr 26 18:58:23 2004
122 ***************
123 *** 4351,4370 ****
124   static char_u *after_label __ARGS((char_u *l));
125   static int    get_indent_nolabel __ARGS((linenr_T lnum));
126   static int    skip_label __ARGS((linenr_T, char_u **pp, int ind_maxcomment));
127   static int    cin_ispreproc __ARGS((char_u *));
128   static int    cin_iscomment __ARGS((char_u *));
129   static int    cin_islinecomment __ARGS((char_u *));
130 ! static int    cin_isterminated __ARGS((char_u *, int));
131 ! static int    cin_isfuncdecl __ARGS((char_u *));
132   static int    cin_isif __ARGS((char_u *));
133   static int    cin_iselse __ARGS((char_u *));
134   static int    cin_isdo __ARGS((char_u *));
135   static int    cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
136 ! static int    cin_ends_in __ARGS((char_u *, char_u *));
137   static int    cin_skip2pos __ARGS((pos_T *trypos));
138   static pos_T  *find_start_brace __ARGS((int));
139   static pos_T  *find_match_paren __ARGS((int, int));
140 ! static int    find_last_paren __ARGS((char_u *l));
141   static int    find_match __ARGS((int lookfor, linenr_T ourscope, int ind_maxparen, int ind_maxcomment));
142   
143   /*
144 --- 4351,4377 ----
145   static char_u *after_label __ARGS((char_u *l));
146   static int    get_indent_nolabel __ARGS((linenr_T lnum));
147   static int    skip_label __ARGS((linenr_T, char_u **pp, int ind_maxcomment));
148 + static int    cin_first_id_amount __ARGS((void));
149 + static int    cin_get_equal_amount __ARGS((linenr_T lnum));
150   static int    cin_ispreproc __ARGS((char_u *));
151 + static int    cin_ispreproc_cont __ARGS((char_u **pp, linenr_T *lnump));
152   static int    cin_iscomment __ARGS((char_u *));
153   static int    cin_islinecomment __ARGS((char_u *));
154 ! static int    cin_isterminated __ARGS((char_u *, int, int));
155 ! static int    cin_isinit __ARGS((void));
156 ! static int    cin_isfuncdecl __ARGS((char_u **, linenr_T));
157   static int    cin_isif __ARGS((char_u *));
158   static int    cin_iselse __ARGS((char_u *));
159   static int    cin_isdo __ARGS((char_u *));
160   static int    cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
161 ! static int    cin_isbreak __ARGS((char_u *));
162 ! static int    cin_is_cpp_baseclass __ARGS((char_u *line, colnr_T *col));
163 ! static int    cin_ends_in __ARGS((char_u *, char_u *, char_u *));
164   static int    cin_skip2pos __ARGS((pos_T *trypos));
165   static pos_T  *find_start_brace __ARGS((int));
166   static pos_T  *find_match_paren __ARGS((int, int));
167 ! static int    corr_ind_maxparen __ARGS((int ind_maxparen, pos_T *startpos));
168 ! static int    find_last_paren __ARGS((char_u *l, int start, int end));
169   static int    find_match __ARGS((int lookfor, linenr_T ourscope, int ind_maxparen, int ind_maxcomment));
170   
171   /*
172 ***************
173 *** 4503,4509 ****
174                 continue;
175   
176             curwin->w_cursor = cursor_save;
177 !           if (cin_isterminated(line, TRUE)
178                     || cin_isscopedecl(line)
179                     || cin_iscase(line)
180                     || (cin_islabel_skip(&line) && cin_nocode(line)))
181 --- 4510,4516 ----
182                 continue;
183   
184             curwin->w_cursor = cursor_save;
185 !           if (cin_isterminated(line, TRUE, FALSE)
186                     || cin_isscopedecl(line)
187                     || cin_iscase(line)
188                     || (cin_islabel_skip(&line) && cin_nocode(line)))
189 ***************
190 *** 4517,4522 ****
191 --- 4524,4550 ----
192   }
193   
194   /*
195 +  * Recognize structure initialization and enumerations.
196 +  * Q&D-Implementation:
197 +  * check for "=" at end or "enum" at beginning of line.
198 +  */
199 +     int
200 + cin_isinit(void)
201 + {
202 +     char_u    *s;
203
204 +     s = cin_skipcomment(ml_get_curline());
205
206 +     if (STRNCMP(s, "enum", 4) == 0 && !vim_isIDc(s[4]))
207 +       return TRUE;
208
209 +     if (cin_ends_in(s, (char_u *)"=", (char_u *)"{"))
210 +       return TRUE;
211
212 +     return FALSE;
213 + }
214
215 + /*
216    * Recognize a switch label: "case .*:" or "default:".
217    */
218        int
219 ***************
220 *** 4677,4682 ****
221 --- 4705,4808 ----
222   }
223   
224   /*
225 +  * Return the indent of the first variable name after a type in a declaration.
226 +  *  int           a,                  indent of "a"
227 +  *  static struct foo    b,   indent of "b"
228 +  *  enum bla    c,            indent of "c"
229 +  * Returns zero when it doesn't look like a declaration.
230 +  */
231 +     static int
232 + cin_first_id_amount()
233 + {
234 +     char_u    *line, *p, *s;
235 +     int               len;
236 +     pos_T     fp;
237 +     colnr_T   col;
238
239 +     line = ml_get_curline();
240 +     p = skipwhite(line);
241 +     len = skiptowhite(p) - p;
242 +     if (len == 6 && STRNCMP(p, "static", 6) == 0)
243 +     {
244 +       p = skipwhite(p + 6);
245 +       len = skiptowhite(p) - p;
246 +     }
247 +     if (len == 6 && STRNCMP(p, "struct", 6) == 0)
248 +       p = skipwhite(p + 6);
249 +     else if (len == 4 && STRNCMP(p, "enum", 4) == 0)
250 +       p = skipwhite(p + 4);
251 +     else if ((len == 8 && STRNCMP(p, "unsigned", 8) == 0)
252 +           || (len == 6 && STRNCMP(p, "signed", 6) == 0))
253 +     {
254 +       s = skipwhite(p + len);
255 +       if ((STRNCMP(s, "int", 3) == 0 && vim_iswhite(s[3]))
256 +               || (STRNCMP(s, "long", 4) == 0 && vim_iswhite(s[4]))
257 +               || (STRNCMP(s, "short", 5) == 0 && vim_iswhite(s[5]))
258 +               || (STRNCMP(s, "char", 4) == 0 && vim_iswhite(s[4])))
259 +           p = s;
260 +     }
261 +     for (len = 0; vim_isIDc(p[len]); ++len)
262 +       ;
263 +     if (len == 0 || !vim_iswhite(p[len]) || cin_nocode(p))
264 +       return 0;
265
266 +     p = skipwhite(p + len);
267 +     fp.lnum = curwin->w_cursor.lnum;
268 +     fp.col = (colnr_T)(p - line);
269 +     getvcol(curwin, &fp, &col, NULL, NULL);
270 +     return (int)col;
271 + }
272
273 + /*
274 +  * Return the indent of the first non-blank after an equal sign.
275 +  *       char *foo = "here";
276 +  * Return zero if no (useful) equal sign found.
277 +  * Return -1 if the line above "lnum" ends in a backslash.
278 +  *      foo = "asdf\
279 +  *           asdf\
280 +  *           here";
281 +  */
282 +     static int
283 + cin_get_equal_amount(lnum)
284 +     linenr_T  lnum;
285 + {
286 +     char_u    *line;
287 +     char_u    *s;
288 +     colnr_T   col;
289 +     pos_T     fp;
290
291 +     if (lnum > 1)
292 +     {
293 +       line = ml_get(lnum - 1);
294 +       if (*line != NUL && line[STRLEN(line) - 1] == '\\')
295 +           return -1;
296 +     }
297
298 +     line = s = ml_get(lnum);
299 +     while (*s != NUL && vim_strchr((char_u *)"=;{}\"'", *s) == NULL)
300 +     {
301 +       if (cin_iscomment(s))   /* ignore comments */
302 +           s = cin_skipcomment(s);
303 +       else
304 +           ++s;
305 +     }
306 +     if (*s != '=')
307 +       return 0;
308
309 +     s = skipwhite(s + 1);
310 +     if (cin_nocode(s))
311 +       return 0;
312
313 +     if (*s == '"')    /* nice alignment for continued strings */
314 +       ++s;
315
316 +     fp.lnum = lnum;
317 +     fp.col = (colnr_T)(s - line);
318 +     getvcol(curwin, &fp, &col, NULL, NULL);
319 +     return (int)col;
320 + }
321
322 + /*
323    * Recognize a preprocessor statement: Any line that starts with '#'.
324    */
325       static int
326 ***************
327 *** 4690,4695 ****
328 --- 4816,4855 ----
329   }
330   
331   /*
332 +  * Return TRUE if line "*pp" at "*lnump" is a preprocessor statement or a
333 +  * continuation line of a preprocessor statement.  Decrease "*lnump" to the
334 +  * start and return the line in "*pp".
335 +  */
336 +     static int
337 + cin_ispreproc_cont(pp, lnump)
338 +     char_u    **pp;
339 +     linenr_T  *lnump;
340 + {
341 +     char_u    *line = *pp;
342 +     linenr_T  lnum = *lnump;
343 +     int               retval = FALSE;
344
345 +     while (1)
346 +     {
347 +       if (cin_ispreproc(line))
348 +       {
349 +           retval = TRUE;
350 +           *lnump = lnum;
351 +           break;
352 +       }
353 +       if (lnum == 1)
354 +           break;
355 +       line = ml_get(--lnum);
356 +       if (*line == NUL || line[STRLEN(line) - 1] != '\\')
357 +           break;
358 +     }
359
360 +     if (lnum != *lnump)
361 +       *pp = ml_get(*lnump);
362 +     return retval;
363 + }
364
365 + /*
366    * Recognize the start of a C or C++ comment.
367    */
368       static int
369 ***************
370 *** 4712,4752 ****
371   /*
372    * Recognize a line that starts with '{' or '}', or ends with ';', '{' or '}'.
373    * Don't consider "} else" a terminated line.
374 !  * Also consider a line terminated if it ends in ','.  This is not 100%
375 !  * correct, but this mostly means we are in initializations and then it's OK.
376    */
377       static int
378 ! cin_isterminated(s, incl_open)
379       char_u    *s;
380       int               incl_open;      /* include '{' at the end as terminator */
381   {
382       s = cin_skipcomment(s);
383   
384       if (*s == '{' || (*s == '}' && !cin_iselse(s)))
385 !       return TRUE;
386   
387       while (*s)
388       {
389         /* skip over comments, "" strings and 'c'haracters */
390         s = skip_string(cin_skipcomment(s));
391 !       if ((*s == ';' || (incl_open && *s == '{') || *s == '}' || *s == ',')
392 !                                                    && cin_nocode(s + 1))
393 !           return TRUE;
394         if (*s)
395             s++;
396       }
397 !     return FALSE;
398   }
399   
400   /*
401    * Recognize the basic picture of a function declaration -- it needs to
402    * have an open paren somewhere and a close paren at the end of the line and
403    * no semicolons anywhere.
404    */
405       static int
406 ! cin_isfuncdecl(s)
407 !     char_u *s;
408   {
409       while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
410       {
411         if (cin_iscomment(s))   /* ignore comments */
412 --- 4872,4931 ----
413   /*
414    * Recognize a line that starts with '{' or '}', or ends with ';', '{' or '}'.
415    * Don't consider "} else" a terminated line.
416 !  * Return the character terminating the line (ending char's have precedence if
417 !  * both apply in order to determine initializations).
418    */
419       static int
420 ! cin_isterminated(s, incl_open, incl_comma)
421       char_u    *s;
422       int               incl_open;      /* include '{' at the end as terminator */
423 +     int               incl_comma;     /* recognize a trailing comma */
424   {
425 +     char_u found_start = 0;
426
427       s = cin_skipcomment(s);
428   
429       if (*s == '{' || (*s == '}' && !cin_iselse(s)))
430 !       found_start = *s;
431   
432       while (*s)
433       {
434         /* skip over comments, "" strings and 'c'haracters */
435         s = skip_string(cin_skipcomment(s));
436 !       if ((*s == ';' || (incl_open && *s == '{') || *s == '}'
437 !                                                || (incl_comma && *s == ','))
438 !               && cin_nocode(s + 1))
439 !           return *s;
440
441         if (*s)
442             s++;
443       }
444 !     return found_start;
445   }
446   
447   /*
448    * Recognize the basic picture of a function declaration -- it needs to
449    * have an open paren somewhere and a close paren at the end of the line and
450    * no semicolons anywhere.
451 +  * When a line ends in a comma we continue looking in the next line.
452 +  * "sp" points to a string with the line.  When looking at other lines it must
453 +  * be restored to the line.  When it's NULL fetch lines here.
454 +  * "lnum" is where we start looking.
455    */
456       static int
457 ! cin_isfuncdecl(sp, first_lnum)
458 !     char_u    **sp;
459 !     linenr_T  first_lnum;
460   {
461 +     char_u    *s;
462 +     linenr_T  lnum = first_lnum;
463 +     int               retval = FALSE;
464
465 +     if (sp == NULL)
466 +       s = ml_get(lnum);
467 +     else
468 +       s = *sp;
469
470       while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
471       {
472         if (cin_iscomment(s))   /* ignore comments */
473 ***************
474 *** 4760,4772 ****
475       while (*s && *s != ';' && *s != '\'' && *s != '"')
476       {
477         if (*s == ')' && cin_nocode(s + 1))
478 !           return TRUE;
479 !       if (cin_iscomment(s))   /* ignore comments */
480             s = cin_skipcomment(s);
481         else
482             ++s;
483       }
484 !     return FALSE;
485   }
486   
487       static int
488 --- 4939,4975 ----
489       while (*s && *s != ';' && *s != '\'' && *s != '"')
490       {
491         if (*s == ')' && cin_nocode(s + 1))
492 !       {
493 !           /* ')' at the end: may have found a match
494 !            * Check for he previous line not to end in a backslash:
495 !            *       #if defined(x) && \
496 !            *           defined(y)
497 !            */
498 !           lnum = first_lnum - 1;
499 !           s = ml_get(lnum);
500 !           if (*s == NUL || s[STRLEN(s) - 1] != '\\')
501 !               retval = TRUE;
502 !           goto done;
503 !       }
504 !       if (*s == ',' && cin_nocode(s + 1))
505 !       {
506 !           /* ',' at the end: continue looking in the next line */
507 !           if (lnum >= curbuf->b_ml.ml_line_count)
508 !               break;
509
510 !           s = ml_get(++lnum);
511 !       }
512 !       else if (cin_iscomment(s))      /* ignore comments */
513             s = cin_skipcomment(s);
514         else
515             ++s;
516       }
517
518 ! done:
519 !     if (lnum != first_lnum && sp != NULL)
520 !       *sp = ml_get(first_lnum);
521
522 !     return retval;
523   }
524   
525       static int
526 ***************
527 *** 4829,4842 ****
528       return retval;
529   }
530   
531   /*
532    * Return TRUE if string "s" ends with the string "find", possibly followed by
533    * white space and comments.  Skip strings and comments.
534    */
535       static int
536 ! cin_ends_in(s, find)
537       char_u    *s;
538       char_u    *find;
539   {
540       char_u    *p = s;
541       char_u    *r;
542 --- 5032,5150 ----
543       return retval;
544   }
545   
546 +     static int
547 + cin_isbreak(p)
548 +     char_u  *p;
549 + {
550 +     return (STRNCMP(p, "break", 5) == 0 && !vim_isIDc(p[5]));
551 + }
552
553 + /* Find the position of a C++ base-class declaration or
554 +  * constructor-initialization. eg:
555 +  *
556 +  * class MyClass :
557 +  *    baseClass               <-- here
558 +  * class MyClass : public baseClass,
559 +  *    anotherBaseClass        <-- here (should probably lineup ??)
560 +  * MyClass::MyClass(...) :
561 +  *    baseClass(...)          <-- here (constructor-initialization)
562 +  */
563 +     static int
564 + cin_is_cpp_baseclass(line, col)
565 +     char_u    *line;
566 +     colnr_T   *col;
567 + {
568 +     char_u    *s;
569 +     int               class_or_struct, lookfor_ctor_init, cpp_base_class;
570
571 +     *col = 0;
572
573 +     s = cin_skipcomment(line);
574 +     if (*s == NUL)
575 +       return FALSE;
576
577 +     cpp_base_class = lookfor_ctor_init = class_or_struct = FALSE;
578
579 +     while(*s != NUL)
580 +     {
581 +       if (s[0] == ':')
582 +       {
583 +           if (s[1] == ':')
584 +           {
585 +               /* skip double colon. It can't be a constructor
586 +                * initialization any more */
587 +               lookfor_ctor_init = FALSE;
588 +               s = cin_skipcomment(s + 2);
589 +           }
590 +           else if (lookfor_ctor_init || class_or_struct)
591 +           {
592 +               /* we have something found, that looks like the start of
593 +                * cpp-base-class-declaration or contructor-initialization */
594 +               cpp_base_class = TRUE;
595 +               lookfor_ctor_init = class_or_struct = FALSE;
596 +               *col = 0;
597 +               s = cin_skipcomment(s + 1);
598 +           }
599 +           else
600 +               s = cin_skipcomment(s + 1);
601 +       }
602 +       else if ((STRNCMP(s, "class", 5) == 0 && !vim_isIDc(s[5]))
603 +               || (STRNCMP(s, "struct", 6) == 0 && !vim_isIDc(s[6])))
604 +       {
605 +           class_or_struct = TRUE;
606 +           lookfor_ctor_init = FALSE;
607
608 +           if (*s == 'c')
609 +               s = cin_skipcomment(s + 5);
610 +           else
611 +               s = cin_skipcomment(s + 6);
612 +       }
613 +       else
614 +       {
615 +           if (s[0] == '{' || s[0] == '}' || s[0] == ';')
616 +           {
617 +               cpp_base_class = lookfor_ctor_init = class_or_struct = FALSE;
618 +           }
619 +           else if (s[0] == ')')
620 +           {
621 +               /* Constructor-initialization is assumed if we come across
622 +                * something like "):" */
623 +               class_or_struct = FALSE;
624 +               lookfor_ctor_init = TRUE;
625 +           }
626 +           else if (!vim_isIDc(s[0]))
627 +           {
628 +               /* if it is not an identifier, we are wrong */
629 +               class_or_struct = FALSE;
630 +               lookfor_ctor_init = FALSE;
631 +           }
632 +           else if (*col == 0)
633 +           {
634 +               /* it can't be a constructor-initialization any more */
635 +               lookfor_ctor_init = FALSE;
636
637 +               /* the first statement starts here: lineup with this one... */
638 +               if (cpp_base_class && *col == 0)
639 +                   *col = (colnr_T)(s - line);
640 +           }
641
642 +           s = cin_skipcomment(s + 1);
643 +       }
644 +     }
645
646 +     return cpp_base_class;
647 + }
648
649   /*
650    * Return TRUE if string "s" ends with the string "find", possibly followed by
651    * white space and comments.  Skip strings and comments.
652 +  * Ignore "ignore" after "find" if it's not NULL.
653    */
654       static int
655 ! cin_ends_in(s, find, ignore)
656       char_u    *s;
657       char_u    *find;
658 +     char_u    *ignore;
659   {
660       char_u    *p = s;
661       char_u    *r;
662 ***************
663 *** 4848,4854 ****
664         if (STRNCMP(p, find, len) == 0)
665         {
666             r = skipwhite(p + len);
667 !           if (*r == NUL || cin_iscomment(r))
668                 return TRUE;
669         }
670         if (*p != NUL)
671 --- 5156,5164 ----
672         if (STRNCMP(p, find, len) == 0)
673         {
674             r = skipwhite(p + len);
675 !           if (ignore != NULL && STRNCMP(r, ignore, STRLEN(ignore)) == 0)
676 !               r = skipwhite(r + STRLEN(ignore));
677 !           if (cin_nocode(r))
678                 return TRUE;
679         }
680         if (*p != NUL)
681 ***************
682 *** 4951,4974 ****
683   }
684   
685   /*
686 !  * Set w_cursor.col to the column number of the last ')' in line "l".
687    */
688       static int
689 ! find_last_paren(l)
690 !     char_u *l;
691   {
692 !     int           i;
693 !     int           retval = FALSE;
694   
695       curwin->w_cursor.col = 0;             /* default is start of line */
696   
697       for (i = 0; l[i]; i++)
698       {
699         i = (int)(skip_string(l + i) - l);    /* ignore parens in quotes */
700 !       if (l[i] == ')')
701         {
702 !           curwin->w_cursor.col = i;
703 !           retval = TRUE;
704         }
705       }
706       return retval;
707 --- 5261,5313 ----
708   }
709   
710   /*
711 !  * Return ind_maxparen corrected for the difference in line number between the
712 !  * cursor position and "startpos".  This makes sure that searching for a
713 !  * matching paren above the cursor line doesn't find a match because of
714 !  * looking a few lines further.
715    */
716       static int
717 ! corr_ind_maxparen(ind_maxparen, startpos)
718 !     int               ind_maxparen;
719 !     pos_T     *startpos;
720   {
721 !     long      n = (long)startpos->lnum - (long)curwin->w_cursor.lnum;
722
723 !     if (n > 0 && n < ind_maxparen / 2)
724 !       return ind_maxparen - (int)n;
725 !     return ind_maxparen;
726 ! }
727
728 ! /*
729 !  * Set w_cursor.col to the column number of the last unmatched ')' or '{' in
730 !  * line "l".
731 !  */
732 !     static int
733 ! find_last_paren(l, start, end)
734 !     char_u    *l;
735 !     int               start, end;
736 ! {
737 !     int               i;
738 !     int               retval = FALSE;
739 !     int               open_count = 0;
740   
741       curwin->w_cursor.col = 0;             /* default is start of line */
742   
743       for (i = 0; l[i]; i++)
744       {
745 +       i = (int)(cin_skipcomment(l + i) - l); /* ignore parens in comments */
746         i = (int)(skip_string(l + i) - l);    /* ignore parens in quotes */
747 !       if (l[i] == start)
748 !           ++open_count;
749 !       else if (l[i] == end)
750         {
751 !           if (open_count > 0)
752 !               --open_count;
753 !           else
754 !           {
755 !               curwin->w_cursor.col = i;
756 !               retval = TRUE;
757 !           }
758         }
759       }
760       return retval;
761 ***************
762 *** 5030,5035 ****
763 --- 5369,5379 ----
764       int ind_case_code = curbuf->b_p_sw;
765   
766       /*
767 +      * lineup break at end of case in switch() with case label
768 +      */
769 +     int ind_case_break = 0;
770
771 +     /*
772        * spaces from the class declaration indent a scope declaration label
773        * should be located
774        */
775 ***************
776 *** 5051,5056 ****
777 --- 5395,5406 ----
778       int ind_func_type = curbuf->b_p_sw;
779   
780       /*
781 +      * amount a cpp base class declaration or constructor initialization
782 +      * should be indented
783 +      */
784 +     int ind_cpp_baseclass = curbuf->b_p_sw;
785
786 +     /*
787        * additional spaces beyond the prevailing indent a continuation line
788        * should be located
789        */
790 ***************
791 *** 5074,5079 ****
792 --- 5424,5436 ----
793       int ind_unclosed_noignore = 0;
794   
795       /*
796 +      * If the opening paren is the last nonwhite character on the line, and
797 +      * ind_unclosed_wrapped is nonzero, use this indent relative to the outer
798 +      * context (for very long lines).
799 +      */
800 +     int ind_unclosed_wrapped = 0;
801
802 +     /*
803        * suppress ignoring white space when lining up with the character after
804        * an unclosed parentheses.
805        */
806 ***************
807 *** 5139,5145 ****
808 --- 5496,5504 ----
809       linenr_T  ourscope;
810       char_u    *l;
811       char_u    *look;
812 +     char_u    terminated;
813       int               lookfor;
814 + #define LOOKFOR_INITIAL               0
815   #define LOOKFOR_IF            1
816   #define LOOKFOR_DO            2
817   #define LOOKFOR_CASE          3
818 ***************
819 *** 5147,5152 ****
820 --- 5506,5515 ----
821   #define LOOKFOR_TERM          5
822   #define LOOKFOR_UNTERM                6
823   #define LOOKFOR_SCOPEDECL     7
824 + #define LOOKFOR_NOBREAK               8
825 + #define LOOKFOR_CPP_BASECLASS 9
826 + #define LOOKFOR_ENUM_OR_INIT  10
827
828       int               whilelevel;
829       linenr_T  lnum;
830       char_u    *options;
831 ***************
832 *** 5154,5159 ****
833 --- 5517,5524 ----
834       int               divider;
835       int               n;
836       int               iscase;
837 +     int               lookfor_break;
838 +     int               cont_amount = 0;    /* amount for continuation line */
839   
840       for (options = curbuf->b_p_cino; *options; )
841       {
842 ***************
843 *** 5201,5215 ****
844 --- 5566,5583 ----
845             case '^': ind_open_left_imag = n; break;
846             case ':': ind_case = n; break;
847             case '=': ind_case_code = n; break;
848 +           case 'b': ind_case_break = n; break;
849             case 'p': ind_param = n; break;
850             case 't': ind_func_type = n; break;
851             case '/': ind_comment = n; break;
852             case 'c': ind_in_comment = n; break;
853             case 'C': ind_in_comment2 = n; break;
854 +           case 'i': ind_cpp_baseclass = n; break;
855             case '+': ind_continuation = n; break;
856             case '(': ind_unclosed = n; break;
857             case 'u': ind_unclosed2 = n; break;
858             case 'U': ind_unclosed_noignore = n; break;
859 +           case 'W': ind_unclosed_wrapped = n; break;
860             case 'w': ind_unclosed_whiteok = n; break;
861             case 'm': ind_matching_paren = n; break;
862             case ')': ind_maxparen = n; break;
863 ***************
864 *** 5454,5487 ****
865          * a previous non-empty line that matches the same paren.
866          */
867         amount = -1;
868         our_paren_pos = *trypos;
869 !       if (theline[0] != ')')
870         {
871 !           for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum)
872 !           {
873 !               l = skipwhite(ml_get(lnum));
874 !               if (cin_nocode(l))          /* skip comment lines */
875 !                   continue;
876 !               if (cin_ispreproc(l))       /* ignore #defines, #if, etc. */
877 !                   continue;
878 !               curwin->w_cursor.lnum = lnum;
879   
880 !               /* Skip a comment. XXX */
881 !               if ((trypos = find_start_comment(ind_maxcomment)) != NULL)
882 !               {
883 !                   lnum = trypos->lnum + 1;
884 !                   continue;
885 !               }
886   
887 !               /* XXX */
888 !               if ((trypos = find_match_paren(ind_maxparen,
889 !                                                  ind_maxcomment)) != NULL &&
890 !                                        trypos->lnum == our_paren_pos.lnum &&
891 !                                            trypos->col == our_paren_pos.col)
892 !               {
893                     amount = get_indent_lnum(lnum);     /* XXX */
894 !                   break;
895 !               }
896             }
897         }
898   
899 --- 5822,5861 ----
900          * a previous non-empty line that matches the same paren.
901          */
902         amount = -1;
903 +       cur_amount = MAXCOL;
904         our_paren_pos = *trypos;
905 !       for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum)
906         {
907 !           l = skipwhite(ml_get(lnum));
908 !           if (cin_nocode(l))          /* skip comment lines */
909 !               continue;
910 !           if (cin_ispreproc_cont(&l, &lnum))  /* ignore #defines, #if, etc. */
911 !               continue;
912 !           curwin->w_cursor.lnum = lnum;
913   
914 !           /* Skip a comment. XXX */
915 !           if ((trypos = find_start_comment(ind_maxcomment)) != NULL)
916 !           {
917 !               lnum = trypos->lnum + 1;
918 !               continue;
919 !           }
920   
921 !           /* XXX */
922 !           if ((trypos = find_match_paren(
923 !                           corr_ind_maxparen(ind_maxparen, &cur_curpos),
924 !                                                     ind_maxcomment)) != NULL
925 !                   && trypos->lnum == our_paren_pos.lnum
926 !                   && trypos->col == our_paren_pos.col)
927 !           {
928                     amount = get_indent_lnum(lnum);     /* XXX */
929
930 !                   if (theline[0] == ')')
931 !                   {
932 !                       if (our_paren_pos.lnum != lnum && cur_amount > amount)
933 !                           cur_amount = amount;
934 !                       amount = -1;
935 !                   }
936 !               break;
937             }
938         }
939   
940 ***************
941 *** 5493,5514 ****
942         if (amount == -1)
943         {
944             amount = skip_label(our_paren_pos.lnum, &look, ind_maxcomment);
945 -           cur_amount = MAXCOL;
946             if (theline[0] == ')' || ind_unclosed == 0
947                        || (!ind_unclosed_noignore && *skipwhite(look) == '('))
948             {
949                 /*
950                  * If we're looking at a close paren, line up right there;
951                  * otherwise, line up with the next (non-white) character.
952                  */
953                 if (theline[0] != ')')
954                 {
955 !                   if (ind_unclosed_whiteok)
956                         our_paren_pos.col++;
957                     else
958                     {
959                         col = our_paren_pos.col + 1;
960 -                       l = ml_get(our_paren_pos.lnum);
961                         while (vim_iswhite(l[col]))
962                             col++;
963                         if (l[col] != NUL)      /* In case of trailing space */
964 --- 5867,5917 ----
965         if (amount == -1)
966         {
967             amount = skip_label(our_paren_pos.lnum, &look, ind_maxcomment);
968             if (theline[0] == ')' || ind_unclosed == 0
969                        || (!ind_unclosed_noignore && *skipwhite(look) == '('))
970             {
971                 /*
972                  * If we're looking at a close paren, line up right there;
973                  * otherwise, line up with the next (non-white) character.
974 +                * When ind_unclosed_wrapped is set and the matching paren is
975 +                * the last nonwhite character of the line, use either the
976 +                * indent of the current line or the indentation of the next
977 +                * outer paren and add ind_unclosed_wrapped (for very long
978 +                * lines).
979                  */
980                 if (theline[0] != ')')
981                 {
982 !                   cur_amount = MAXCOL;
983 !                   l = ml_get(our_paren_pos.lnum);
984 !                   if (ind_unclosed_wrapped
985 !                                      && cin_ends_in(l, (char_u *)"(", NULL))
986 !                   {
987 !                       /* look for opening unmatched paren, indent one level
988 !                        * for each additional level */
989 !                       n = 1;
990 !                       for (col = 0; col < our_paren_pos.col; ++col)
991 !                       {
992 !                           switch (l[col])
993 !                           {
994 !                               case '(':
995 !                               case '{': ++n;
996 !                                         break;
997
998 !                               case ')':
999 !                               case '}': if (n > 1)
1000 !                                             --n;
1001 !                                         break;
1002 !                           }
1003 !                       }
1004
1005 !                       our_paren_pos.col = 0;
1006 !                       amount += n * ind_unclosed_wrapped;
1007 !                   }
1008 !                   else if (ind_unclosed_whiteok)
1009                         our_paren_pos.col++;
1010                     else
1011                     {
1012                         col = our_paren_pos.col + 1;
1013                         while (vim_iswhite(l[col]))
1014                             col++;
1015                         if (l[col] != NUL)      /* In case of trailing space */
1016 ***************
1017 *** 5522,5529 ****
1018                  * Find how indented the paren is, or the character after it
1019                  * if we did the above "if".
1020                  */
1021 !               getvcol(curwin, &our_paren_pos, &col, NULL, NULL);
1022 !               cur_amount = col;
1023             }
1024   
1025             if (theline[0] == ')' && ind_matching_paren)
1026 --- 5925,5936 ----
1027                  * Find how indented the paren is, or the character after it
1028                  * if we did the above "if".
1029                  */
1030 !               if (our_paren_pos.col > 0)
1031 !               {
1032 !                   getvcol(curwin, &our_paren_pos, &col, NULL, NULL);
1033 !                   if (cur_amount > (int)col)
1034 !                       cur_amount = col;
1035 !               }
1036             }
1037   
1038             if (theline[0] == ')' && ind_matching_paren)
1039 ***************
1040 *** 5532,5538 ****
1041             }
1042             else if (ind_unclosed == 0 || (!ind_unclosed_noignore
1043                                                   && *skipwhite(look) == '('))
1044 !               amount = cur_amount;
1045             else
1046             {
1047                 /* add ind_unclosed2 for each '(' before our matching one */
1048 --- 5939,5948 ----
1049             }
1050             else if (ind_unclosed == 0 || (!ind_unclosed_noignore
1051                                                   && *skipwhite(look) == '('))
1052 !           {
1053 !               if (cur_amount != MAXCOL)
1054 !                   amount = cur_amount;
1055 !           }
1056             else
1057             {
1058                 /* add ind_unclosed2 for each '(' before our matching one */
1059 ***************
1060 *** 5622,5629 ****
1061              * matching it will take us back to the start of the line.
1062              */
1063             lnum = ourscope;
1064 !           if (find_last_paren(start) &&
1065 !                   (trypos = find_match_paren(ind_maxparen,
1066                                                      ind_maxcomment)) != NULL)
1067                 lnum = trypos->lnum;
1068   
1069 --- 6032,6039 ----
1070              * matching it will take us back to the start of the line.
1071              */
1072             lnum = ourscope;
1073 !           if (find_last_paren(start, '(', ')')
1074 !                   && (trypos = find_match_paren(ind_maxparen,
1075                                                      ind_maxcomment)) != NULL)
1076                 lnum = trypos->lnum;
1077   
1078 ***************
1079 *** 5662,5674 ****
1080              * If we're looking at a "while", try to find a "do"
1081              * to match it with.
1082              */
1083 !           lookfor = 0;
1084             if (cin_iselse(theline))
1085                 lookfor = LOOKFOR_IF;
1086             else if (cin_iswhileofdo(theline, cur_curpos.lnum, ind_maxparen))
1087                                                                     /* XXX */
1088                 lookfor = LOOKFOR_DO;
1089 !           if (lookfor)
1090             {
1091                 curwin->w_cursor.lnum = cur_curpos.lnum;
1092                 if (find_match(lookfor, ourscope, ind_maxparen,
1093 --- 6072,6084 ----
1094              * If we're looking at a "while", try to find a "do"
1095              * to match it with.
1096              */
1097 !           lookfor = LOOKFOR_INITIAL;
1098             if (cin_iselse(theline))
1099                 lookfor = LOOKFOR_IF;
1100             else if (cin_iswhileofdo(theline, cur_curpos.lnum, ind_maxparen))
1101                                                                     /* XXX */
1102                 lookfor = LOOKFOR_DO;
1103 !           if (lookfor != LOOKFOR_INITIAL)
1104             {
1105                 curwin->w_cursor.lnum = cur_curpos.lnum;
1106                 if (find_match(lookfor, ourscope, ind_maxparen,
1107 ***************
1108 *** 5709,5714 ****
1109 --- 6119,6126 ----
1110                 }
1111             }
1112   
1113 +           lookfor_break = FALSE;
1114
1115             if (cin_iscase(theline))    /* it's a switch() label */
1116             {
1117                 lookfor = LOOKFOR_CASE; /* find a previous switch() label */
1118 ***************
1119 *** 5721,5727 ****
1120             }
1121             else
1122             {
1123 !               lookfor = LOOKFOR_ANY;
1124                 amount += ind_level;    /* ind_level from start of block */
1125             }
1126             scope_amount = amount;
1127 --- 6133,6142 ----
1128             }
1129             else
1130             {
1131 !               if (ind_case_break && cin_isbreak(theline))     /* break; ... */
1132 !                   lookfor_break = TRUE;
1133
1134 !               lookfor = LOOKFOR_INITIAL;
1135                 amount += ind_level;    /* ind_level from start of block */
1136             }
1137             scope_amount = amount;
1138 ***************
1139 *** 5747,5755 ****
1140                  */
1141                 if (curwin->w_cursor.lnum <= ourscope)
1142                 {
1143 !                   if (lookfor == LOOKFOR_UNTERM)
1144 !                       amount += ind_continuation;
1145 !                   else if (lookfor != LOOKFOR_TERM)
1146                     {
1147                         amount = scope_amount;
1148                         if (theline[0] == '{')
1149 --- 6162,6282 ----
1150                  */
1151                 if (curwin->w_cursor.lnum <= ourscope)
1152                 {
1153 !                   /* we reached end of scope:
1154 !                    * if looking for a enum or structure initialization
1155 !                    * go further back:
1156 !                    * if it is an initializer (enum xxx or xxx =), then
1157 !                    * don't add ind_continuation, otherwise it is a variable
1158 !                    * declaration:
1159 !                    * int x,
1160 !                    *     here; <-- add ind_continuation
1161 !                    */
1162 !                   if (lookfor == LOOKFOR_ENUM_OR_INIT)
1163 !                   {
1164 !                       if (curwin->w_cursor.lnum == 0
1165 !                               || curwin->w_cursor.lnum
1166 !                                                   < ourscope - ind_maxparen)
1167 !                       {
1168 !                           /* nothing found (abuse ind_maxparen as limit)
1169 !                            * assume terminated line (i.e. a variable
1170 !                            * initialization) */
1171 !                           if (cont_amount > 0)
1172 !                               amount = cont_amount;
1173 !                           else
1174 !                               amount += ind_continuation;
1175 !                           break;
1176 !                       }
1177
1178 !                       l = ml_get_curline();
1179
1180 !                       /*
1181 !                        * If we're in a comment now, skip to the start of the
1182 !                        * comment.
1183 !                        */
1184 !                       trypos = find_start_comment(ind_maxcomment);
1185 !                       if (trypos != NULL)
1186 !                       {
1187 !                           curwin->w_cursor.lnum = trypos->lnum + 1;
1188 !                           continue;
1189 !                       }
1190
1191 !                       /*
1192 !                        * Skip preprocessor directives and blank lines.
1193 !                        */
1194 !                       if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
1195 !                           continue;
1196
1197 !                       if (cin_nocode(l))
1198 !                           continue;
1199
1200 !                       /*
1201 !                        * If we are at top level and the line looks like a
1202 !                        * function declaration, we are done
1203 !                        * (it's a variable declaration).
1204 !                        */
1205 !                       if (start_brace != BRACE_IN_COL0
1206 !                               || !cin_isfuncdecl(&l, curwin->w_cursor.lnum))
1207 !                       {
1208 !                           terminated = cin_isterminated(l, FALSE, TRUE);
1209
1210 !                           /* if the line is terminated with another ','
1211 !                            * it is a continued variable initialization.
1212 !                            * don't add extra indent.
1213 !                            * TODO: does not work, if  a function
1214 !                            * declaration is split over multiple lines:
1215 !                            * cin_isfuncdecl returns FALSE then.
1216 !                            */
1217 !                           if (terminated == ',')
1218 !                               break;
1219
1220 !                           /* if it es a enum declaration or an assignment,
1221 !                            * we are done.
1222 !                            */
1223 !                           if (terminated != ';' && cin_isinit())
1224 !                               break;
1225
1226 !                           /* nothing useful found */
1227 !                           if (terminated == 0 || terminated == '{')
1228 !                               continue;
1229 !                       }
1230
1231 !                       /* Skip parens and braces. Position the cursor over
1232 !                        * the rightmost paren, so that matching it will take
1233 !                        * us back to the start of the line.
1234 !                        */                                     /* XXX */
1235 !                       trypos = NULL;
1236 !                       if (find_last_paren(l, '(', ')'))
1237 !                           trypos = find_match_paren(ind_maxparen,
1238 !                                                             ind_maxcomment);
1239
1240 !                       if (trypos == NULL && find_last_paren(l, '{', '}'))
1241 !                           trypos = find_start_brace(ind_maxcomment);
1242
1243 !                       if (trypos != NULL)
1244 !                       {
1245 !                           curwin->w_cursor.lnum = trypos->lnum + 1;
1246 !                           continue;
1247 !                       }
1248
1249 !                       /* it's a variable declaration, add indentation
1250 !                        * like in
1251 !                        * int a,
1252 !                        *    b;
1253 !                        */
1254 !                       if (cont_amount > 0)
1255 !                           amount = cont_amount;
1256 !                       else
1257 !                           amount += ind_continuation;
1258 !                   }
1259 !                   else if (lookfor == LOOKFOR_UNTERM)
1260 !                   {
1261 !                       if (cont_amount > 0)
1262 !                           amount = cont_amount;
1263 !                       else
1264 !                           amount += ind_continuation;
1265 !                   }
1266 !                   else if (lookfor != LOOKFOR_TERM
1267 !                                         && lookfor != LOOKFOR_CPP_BASECLASS)
1268                     {
1269                         amount = scope_amount;
1270                         if (theline[0] == '{')
1271 ***************
1272 *** 5776,5781 ****
1273 --- 6303,6313 ----
1274                 iscase = cin_iscase(l);
1275                 if (iscase || cin_isscopedecl(l))
1276                 {
1277 +                   /* we are only looking for cpp base class
1278 +                    * declaration/initialization any longer */
1279 +                   if (lookfor == LOOKFOR_CPP_BASECLASS)
1280 +                       break;
1281
1282                     /* When looking for a "do" we are not interested in
1283                      * labels. */
1284                     if (whilelevel > 0)
1285 ***************
1286 *** 5786,5794 ****
1287                      *      c = 99 +        <- this indent plus continuation
1288                      *->           here;
1289                      */
1290 !                   if (lookfor == LOOKFOR_UNTERM)
1291                     {
1292 !                       amount += ind_continuation;
1293                         break;
1294                     }
1295   
1296 --- 6318,6330 ----
1297                      *      c = 99 +        <- this indent plus continuation
1298                      *->           here;
1299                      */
1300 !                   if (lookfor == LOOKFOR_UNTERM
1301 !                                          || lookfor == LOOKFOR_ENUM_OR_INIT)
1302                     {
1303 !                       if (cont_amount > 0)
1304 !                           amount = cont_amount;
1305 !                       else
1306 !                           amount += ind_continuation;
1307                         break;
1308                     }
1309   
1310 ***************
1311 *** 5798,5803 ****
1312 --- 6334,6340 ----
1313                      *  case yy:
1314                      */
1315                     if (       (iscase && lookfor == LOOKFOR_CASE)
1316 +                           || (iscase && lookfor_break)
1317                             || (!iscase && lookfor == LOOKFOR_SCOPEDECL))
1318                     {
1319                         /*
1320 ***************
1321 *** 5829,5835 ****
1322                     {
1323                         if (n)
1324                             amount = n;
1325 !                       break;
1326                     }
1327   
1328                     /*
1329 --- 6366,6374 ----
1330                     {
1331                         if (n)
1332                             amount = n;
1333
1334 !                       if (!lookfor_break)
1335 !                           break;
1336                     }
1337   
1338                     /*
1339 ***************
1340 *** 5858,5873 ****
1341                      */
1342                     scope_amount = get_indent() + (iscase    /* XXX */
1343                                         ? ind_case_code : ind_scopedecl_code);
1344 !                   lookfor = LOOKFOR_ANY;
1345                     continue;
1346                 }
1347   
1348                 /*
1349                  * Looking for a switch() label or C++ scope declaration,
1350 !                * ignore other lines.
1351                  */
1352                 if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL)
1353                     continue;
1354   
1355                 /*
1356                  * Ignore jump labels with nothing after them.
1357 --- 6397,6417 ----
1358                      */
1359                     scope_amount = get_indent() + (iscase    /* XXX */
1360                                         ? ind_case_code : ind_scopedecl_code);
1361 !                   lookfor = ind_case_break ? LOOKFOR_NOBREAK : LOOKFOR_ANY;
1362                     continue;
1363                 }
1364   
1365                 /*
1366                  * Looking for a switch() label or C++ scope declaration,
1367 !                * ignore other lines, skip {}-blocks.
1368                  */
1369                 if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL)
1370 +               {
1371 +                   if (find_last_paren(l, '{', '}') && (trypos =
1372 +                                   find_start_brace(ind_maxcomment)) != NULL)
1373 +                       curwin->w_cursor.lnum = trypos->lnum + 1;
1374                     continue;
1375 +               }
1376   
1377                 /*
1378                  * Ignore jump labels with nothing after them.
1379 ***************
1380 *** 5886,5898 ****
1381                  * unlocked it)
1382                  */
1383                 l = ml_get_curline();
1384 !               if (cin_ispreproc(l) || cin_nocode(l))
1385                     continue;
1386   
1387                 /*
1388                  * What happens next depends on the line being terminated.
1389                  */
1390 !               if (!cin_isterminated(l, FALSE))
1391                 {
1392                     /*
1393                      * if we're in the middle of a paren thing,
1394 --- 6430,6496 ----
1395                  * unlocked it)
1396                  */
1397                 l = ml_get_curline();
1398 !               if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)
1399 !                                                            || cin_nocode(l))
1400                     continue;
1401   
1402                 /*
1403 +                * Are we at the start of a cpp base class declaration or
1404 +                * constructor initialization?
1405 +                */                                                 /* XXX */
1406 +               if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass
1407 +                                            && cin_is_cpp_baseclass(l, &col))
1408 +               {
1409 +                   if (lookfor == LOOKFOR_UNTERM)
1410 +                   {
1411 +                       if (cont_amount > 0)
1412 +                           amount = cont_amount;
1413 +                       else
1414 +                           amount += ind_continuation;
1415 +                   }
1416 +                   else if (col == 0 || theline[0] == '{')
1417 +                   {
1418 +                       amount = get_indent();
1419 +                       if (find_last_paren(l, '(', ')')
1420 +                               && (trypos = find_match_paren(ind_maxparen,
1421 +                                       ind_maxcomment)) != NULL)
1422 +                           amount = get_indent_lnum(trypos->lnum); /* XXX */
1423 +                       if (theline[0] != '{')
1424 +                           amount += ind_cpp_baseclass;
1425 +                   }
1426 +                   else
1427 +                   {
1428 +                       curwin->w_cursor.col = col;
1429 +                       getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL);
1430 +                       amount = (int)col;
1431 +                   }
1432 +                   break;
1433 +               }
1434 +               else if (lookfor == LOOKFOR_CPP_BASECLASS)
1435 +               {
1436 +                   /* only look, whether there is a cpp base class
1437 +                    * declaration or initialization before the opening brace. */
1438 +                   if (cin_isterminated(l, TRUE, FALSE))
1439 +                       break;
1440 +                   else
1441 +                       continue;
1442 +               }
1443
1444 +               /*
1445                  * What happens next depends on the line being terminated.
1446 +                * If terminated with a ',' only consider it terminating if
1447 +                * there is anoter unterminated statement behind, eg:
1448 +                *   123,
1449 +                *   sizeof
1450 +                *        here
1451 +                * Otherwise check whether it is a enumeration or structure
1452 +                * initialisation (not indented) or a variable declaration
1453 +                * (indented).
1454                  */
1455 !               terminated = cin_isterminated(l, FALSE, TRUE);
1456
1457 !               if (terminated == 0 || (lookfor != LOOKFOR_UNTERM
1458 !                                                       && terminated == ','))
1459                 {
1460                     /*
1461                      * if we're in the middle of a paren thing,
1462 ***************
1463 *** 5905,5913 ****
1464                      * position the cursor over the rightmost paren, so that
1465                      * matching it will take us back to the start of the line.
1466                      */
1467 !                   (void)find_last_paren(l);
1468 !                   if ((trypos = find_match_paren(ind_maxparen,
1469 !                                                    ind_maxcomment)) != NULL)
1470                     {
1471                         /*
1472                          * Check if we are on a case label now.  This is
1473 --- 6503,6521 ----
1474                      * position the cursor over the rightmost paren, so that
1475                      * matching it will take us back to the start of the line.
1476                      */
1477 !                   (void)find_last_paren(l, '(', ')');
1478 !                   trypos = find_match_paren(
1479 !                                corr_ind_maxparen(ind_maxparen, &cur_curpos),
1480 !                                                             ind_maxcomment);
1481
1482 !                   /*
1483 !                    * If we are looking for ',', we also look for matching
1484 !                    * braces.
1485 !                    */
1486 !                   if (trypos == NULL && find_last_paren(l, '{', '}'))
1487 !                       trypos = find_start_brace(ind_maxcomment);
1488
1489 !                   if (trypos != NULL)
1490                     {
1491                         /*
1492                          * Check if we are on a case label now.  This is
1493 ***************
1494 *** 5925,5930 ****
1495 --- 6533,6556 ----
1496                     }
1497   
1498                     /*
1499 +                    * Skip over continuation lines to find the one to get the
1500 +                    * indent from
1501 +                    * char *usethis = "bla\
1502 +                    *           bla",
1503 +                    *      here;
1504 +                    */
1505 +                   if (terminated == ',')
1506 +                   {
1507 +                       while (curwin->w_cursor.lnum > 1)
1508 +                       {
1509 +                           l = ml_get(curwin->w_cursor.lnum - 1);
1510 +                           if (*l == NUL || l[STRLEN(l) - 1] != '\\')
1511 +                               break;
1512 +                           --curwin->w_cursor.lnum;
1513 +                       }
1514 +                   }
1515
1516 +                   /*
1517                      * Get indent and pointer to text for current line,
1518                      * ignoring any jump label.     XXX
1519                      */
1520 ***************
1521 *** 5938,5944 ****
1522                      * ->       {
1523                      *          }
1524                      */
1525 !                   if (lookfor != LOOKFOR_TERM && theline[0] == '{')
1526                     {
1527                         amount = cur_amount;
1528                         /*
1529 --- 6564,6571 ----
1530                      * ->       {
1531                      *          }
1532                      */
1533 !                   if (terminated != ',' && lookfor != LOOKFOR_TERM
1534 !                                                        && theline[0] == '{')
1535                     {
1536                         amount = cur_amount;
1537                         /*
1538 ***************
1539 *** 5950,5955 ****
1540 --- 6577,6590 ----
1541                          */
1542                         if (*skipwhite(l) != '{')
1543                             amount += ind_open_extra;
1544
1545 +                       if (ind_cpp_baseclass)
1546 +                       {
1547 +                           /* have to look back, whether it is a cpp base
1548 +                            * class declaration or initialization */
1549 +                           lookfor = LOOKFOR_CPP_BASECLASS;
1550 +                           continue;
1551 +                       }
1552                         break;
1553                     }
1554   
1555 ***************
1556 *** 5966,5974 ****
1557                          *          100 +
1558                          * ->           here;
1559                          */
1560 !                       if (lookfor == LOOKFOR_UNTERM)
1561                         {
1562 !                           amount += ind_continuation;
1563                             break;
1564                         }
1565   
1566 --- 6601,6613 ----
1567                          *          100 +
1568                          * ->           here;
1569                          */
1570 !                       if (lookfor == LOOKFOR_UNTERM
1571 !                                          || lookfor == LOOKFOR_ENUM_OR_INIT)
1572                         {
1573 !                           if (cont_amount > 0)
1574 !                               amount = cont_amount;
1575 !                           else
1576 !                               amount += ind_continuation;
1577                             break;
1578                         }
1579   
1580 ***************
1581 *** 6040,6056 ****
1582                          * ->       here;
1583                          */
1584                         if (lookfor == LOOKFOR_UNTERM)
1585                             break;
1586   
1587 !                       /*
1588 !                        * Found first unterminated line on a row, may line up
1589 !                        * with this line, remember its indent
1590 !                        *          100 +
1591 !                        * ->       here;
1592 !                        */
1593 !                       amount = cur_amount;
1594 !                       if (lookfor != LOOKFOR_TERM)
1595 !                           lookfor = LOOKFOR_UNTERM;
1596                     }
1597                 }
1598   
1599 --- 6679,6750 ----
1600                          * ->       here;
1601                          */
1602                         if (lookfor == LOOKFOR_UNTERM)
1603 +                       {
1604 +                           /* When line ends in a comma add extra indent */
1605 +                           if (terminated == ',')
1606 +                               amount += ind_continuation;
1607                             break;
1608 +                       }
1609   
1610 !                       if (lookfor == LOOKFOR_ENUM_OR_INIT)
1611 !                       {
1612 !                           /* Found two lines ending in ',', lineup with the
1613 !                            * lowest one, but check for cpp base class
1614 !                            * declaration/initialization, if it is an
1615 !                            * opening brace or we are looking just for
1616 !                            * enumerations/initializations. */
1617 !                           if (terminated == ',')
1618 !                           {
1619 !                               if (ind_cpp_baseclass == 0)
1620 !                                   break;
1621
1622 !                               lookfor = LOOKFOR_CPP_BASECLASS;
1623 !                               continue;
1624 !                           }
1625
1626 !                           /* Ignore unterminated lines in between, but
1627 !                            * reduce indent. */
1628 !                           if (amount > cur_amount)
1629 !                               amount = cur_amount;
1630 !                       }
1631 !                       else
1632 !                       {
1633 !                           /*
1634 !                            * Found first unterminated line on a row, may
1635 !                            * line up with this line, remember its indent
1636 !                            *      100 +
1637 !                            * ->           here;
1638 !                            */
1639 !                           amount = cur_amount;
1640
1641 !                           /*
1642 !                            * If previous line ends in ',', check whether we
1643 !                            * are in an initialization or enum
1644 !                            * struct xxx =
1645 !                            * {
1646 !                            *      sizeof a,
1647 !                            *      124 };
1648 !                            * or a normal possible continuation line.
1649 !                            * but only, of no other statement has been found
1650 !                            * yet.
1651 !                            */
1652 !                           if (lookfor == LOOKFOR_INITIAL && terminated == ',')
1653 !                           {
1654 !                               lookfor = LOOKFOR_ENUM_OR_INIT;
1655 !                               cont_amount = cin_first_id_amount();
1656 !                           }
1657 !                           else
1658 !                           {
1659 !                               if (lookfor == LOOKFOR_INITIAL
1660 !                                       && *l != NUL
1661 !                                       && l[STRLEN(l) - 1] == '\\')
1662 !                                                               /* XXX */
1663 !                                   cont_amount = cin_get_equal_amount(
1664 !                                                      curwin->w_cursor.lnum);
1665 !                               if (lookfor != LOOKFOR_TERM)
1666 !                                   lookfor = LOOKFOR_UNTERM;
1667 !                           }
1668 !                       }
1669                     }
1670                 }
1671   
1672 ***************
1673 *** 6069,6077 ****
1674                      *      100 +               <- line up with this one
1675                      * ->           here;
1676                      */
1677 !                   if (lookfor == LOOKFOR_UNTERM)
1678                     {
1679 !                       amount += ind_continuation;
1680                         break;
1681                     }
1682   
1683 --- 6763,6775 ----
1684                      *      100 +               <- line up with this one
1685                      * ->           here;
1686                      */
1687 !                   if (lookfor == LOOKFOR_UNTERM
1688 !                                          || lookfor == LOOKFOR_ENUM_OR_INIT)
1689                     {
1690 !                       if (cont_amount > 0)
1691 !                           amount = cont_amount;
1692 !                       else
1693 !                           amount += ind_continuation;
1694                         break;
1695                     }
1696   
1697 ***************
1698 *** 6095,6100 ****
1699 --- 6793,6809 ----
1700                 else
1701                 {
1702                     /*
1703 +                    * Skip single break line, if before a switch label. It
1704 +                    * may be lined up with the case label.
1705 +                    */
1706 +                   if (lookfor == LOOKFOR_NOBREAK
1707 +                                 && cin_isbreak(skipwhite(ml_get_curline())))
1708 +                   {
1709 +                       lookfor = LOOKFOR_ANY;
1710 +                       continue;
1711 +                   }
1712
1713 +                   /*
1714                      * Handle "do {" line.
1715                      */
1716                     if (whilelevel > 0)
1717 ***************
1718 *** 6114,6123 ****
1719                      *   x = 1;
1720                      *   y = foo +
1721                      * ->       here;
1722                      */
1723 !                   if (lookfor == LOOKFOR_UNTERM)
1724                     {
1725 !                       amount += ind_continuation;
1726                         break;
1727                     }
1728   
1729 --- 6823,6840 ----
1730                      *   x = 1;
1731                      *   y = foo +
1732                      * ->       here;
1733 +                    * or
1734 +                    *   int x = 1;
1735 +                    *   int foo,
1736 +                    * ->       here;
1737                      */
1738 !                   if (lookfor == LOOKFOR_UNTERM
1739 !                                          || lookfor == LOOKFOR_ENUM_OR_INIT)
1740                     {
1741 !                       if (cont_amount > 0)
1742 !                           amount = cont_amount;
1743 !                       else
1744 !                           amount += ind_continuation;
1745                         break;
1746                     }
1747   
1748 ***************
1749 *** 6132,6138 ****
1750                      */
1751                     if (lookfor == LOOKFOR_TERM)
1752                     {
1753 !                       if (whilelevel == 0)
1754                             break;
1755                     }
1756   
1757 --- 6849,6855 ----
1758                      */
1759                     if (lookfor == LOOKFOR_TERM)
1760                     {
1761 !                       if (!lookfor_break && whilelevel == 0)
1762                             break;
1763                     }
1764   
1765 ***************
1766 *** 6153,6160 ****
1767                          */
1768   term_again:
1769                         l = ml_get_curline();
1770 !                       if (find_last_paren(l) &&
1771 !                               (trypos = find_match_paren(ind_maxparen,
1772                                                      ind_maxcomment)) != NULL)
1773                         {
1774                             /*
1775 --- 6870,6877 ----
1776                          */
1777   term_again:
1778                         l = ml_get_curline();
1779 !                       if (find_last_paren(l, '(', ')')
1780 !                               && (trypos = find_match_paren(ind_maxparen,
1781                                                      ind_maxcomment)) != NULL)
1782                         {
1783                             /*
1784 ***************
1785 *** 6254,6261 ****
1786          */
1787         else if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
1788                 && !cin_nocode(theline)
1789 !               && cin_isfuncdecl(ml_get(cur_curpos.lnum + 1))
1790 !               && !cin_isterminated(theline, FALSE))
1791         {
1792             amount = ind_func_type;
1793         }
1794 --- 6971,6980 ----
1795          */
1796         else if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
1797                 && !cin_nocode(theline)
1798 !               && !cin_ends_in(theline, (char_u *)":", NULL)
1799 !               && !cin_ends_in(theline, (char_u *)",", NULL)
1800 !               && cin_isfuncdecl(NULL, cur_curpos.lnum + 1)
1801 !               && !cin_isterminated(theline, FALSE, TRUE))
1802         {
1803             amount = ind_func_type;
1804         }
1805 ***************
1806 *** 6283,6293 ****
1807                 }
1808   
1809                 /*
1810                  * If the line looks like a function declaration, and we're
1811                  * not in a comment, put it the left margin.
1812                  */
1813 !               if (cin_isfuncdecl(theline))
1814                     break;
1815   
1816                 /*
1817                  * Finding the closing '}' of a previous function.  Put
1818 --- 7002,7092 ----
1819                 }
1820   
1821                 /*
1822 +                * Are we at the start of a cpp base class declaration or constructor
1823 +                * initialization?
1824 +                */                                                 /* XXX */
1825 +               if (ind_cpp_baseclass != 0 && theline[0] != '{'
1826 +                                            && cin_is_cpp_baseclass(l, &col))
1827 +               {
1828 +                   if (col == 0)
1829 +                   {
1830 +                       amount = get_indent() + ind_cpp_baseclass;  /* XXX */
1831 +                       if (find_last_paren(l, '(', ')')
1832 +                               && (trypos = find_match_paren(ind_maxparen,
1833 +                                       ind_maxcomment)) != NULL)
1834 +                           amount = get_indent_lnum(trypos->lnum)
1835 +                                          + ind_cpp_baseclass;     /* XXX */
1836 +                   }
1837 +                   else
1838 +                   {
1839 +                       curwin->w_cursor.col = col;
1840 +                       getvcol(curwin, &curwin->w_cursor, &col, NULL, NULL);
1841 +                       amount = (int)col;
1842 +                   }
1843 +                   break;
1844 +               }
1845
1846 +               /*
1847 +                * Skip preprocessor directives and blank lines.
1848 +                */
1849 +               if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum))
1850 +                   continue;
1851
1852 +               if (cin_nocode(l))
1853 +                   continue;
1854
1855 +               /*
1856 +                * If the previous line ends in ',', use one level of
1857 +                * indentation:
1858 +                * int foo,
1859 +                *     bar;
1860 +                * do this before checking for '}' in case of eg.
1861 +                * enum foobar
1862 +                * {
1863 +                *   ...
1864 +                * } foo,
1865 +                *   bar;
1866 +                */
1867 +               n = 0;
1868 +               if (cin_ends_in(l, (char_u *)",", NULL)
1869 +                            || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\'))
1870 +               {
1871 +                   /* take us back to opening paren */
1872 +                   if (find_last_paren(l, '(', ')')
1873 +                           && (trypos = find_match_paren(ind_maxparen,
1874 +                                                    ind_maxcomment)) != NULL)
1875 +                       curwin->w_cursor.lnum = trypos->lnum;
1876
1877 +                   /* For a line ending in ',' that is a continuation line go
1878 +                    * back to the first line with a backslash:
1879 +                    * char *foo = "bla\
1880 +                    *           bla",
1881 +                    *      here;
1882 +                    */
1883 +                   while (n == 0 && curwin->w_cursor.lnum > 1)
1884 +                   {
1885 +                       l = ml_get(curwin->w_cursor.lnum - 1);
1886 +                       if (*l == NUL || l[STRLEN(l) - 1] != '\\')
1887 +                           break;
1888 +                       --curwin->w_cursor.lnum;
1889 +                   }
1890
1891 +                   amount = get_indent();          /* XXX */
1892
1893 +                   if (amount == 0)
1894 +                       amount = cin_first_id_amount();
1895 +                   if (amount == 0)
1896 +                       amount = ind_continuation;
1897 +                   break;
1898 +               }
1899
1900 +               /*
1901                  * If the line looks like a function declaration, and we're
1902                  * not in a comment, put it the left margin.
1903                  */
1904 !               if (cin_isfuncdecl(NULL, cur_curpos.lnum))  /* XXX */
1905                     break;
1906 +               l = ml_get_curline();
1907   
1908                 /*
1909                  * Finding the closing '}' of a previous function.  Put
1910 ***************
1911 *** 6302,6325 ****
1912                  * char *string_array[] = { "foo",
1913                  *     / * x * / "b};ar" }; / * foobar * /
1914                  */
1915 !               if (cin_ends_in(l, (char_u *)"};"))
1916                     break;
1917   
1918                 /*
1919 -                * Skip preprocessor directives and blank lines.
1920 -                */
1921 -               if (cin_ispreproc(l))
1922 -                   continue;
1923
1924 -               if (cin_nocode(l))
1925 -                   continue;
1926
1927 -               /*
1928                  * If the PREVIOUS line is a function declaration, the current
1929                  * line (and the ones that follow) needs to be indented as
1930                  * parameters.
1931                  */
1932 !               if (cin_isfuncdecl(l))
1933                 {
1934                     amount = ind_param;
1935                     break;
1936 --- 7101,7115 ----
1937                  * char *string_array[] = { "foo",
1938                  *     / * x * / "b};ar" }; / * foobar * /
1939                  */
1940 !               if (cin_ends_in(l, (char_u *)"};", NULL))
1941                     break;
1942   
1943                 /*
1944                  * If the PREVIOUS line is a function declaration, the current
1945                  * line (and the ones that follow) needs to be indented as
1946                  * parameters.
1947                  */
1948 !               if (cin_isfuncdecl(&l, curwin->w_cursor.lnum))
1949                 {
1950                     amount = ind_param;
1951                     break;
1952 ***************
1953 *** 6332,6369 ****
1954                  *     bar;
1955                  * indent_to_0 here;
1956                  */
1957 !               if (cin_ends_in(l, (char_u*)";"))
1958                 {
1959                     l = ml_get(curwin->w_cursor.lnum - 1);
1960 !                   if (cin_ends_in(l, (char_u *)",")
1961                             || (*l != NUL && l[STRLEN(l) - 1] == '\\'))
1962                         break;
1963                     l = ml_get_curline();
1964                 }
1965   
1966                 /*
1967 -                * If the previous line ends in ',', use one level of
1968 -                * indentation:
1969 -                * int foo,
1970 -                *     bar;
1971 -                */
1972 -               if (cin_ends_in(l, (char_u *)",")
1973 -                       || (*l != NUL && l[STRLEN(l) - 1] == '\\'))
1974 -               {
1975 -                   amount = get_indent();
1976 -                   if (amount == 0)
1977 -                       amount = ind_param;
1978 -                   break;
1979 -               }
1980
1981 -               /*
1982                  * Doesn't look like anything interesting -- so just
1983                  * use the indent of this line.
1984                  *
1985                  * Position the cursor over the rightmost paren, so that
1986                  * matching it will take us back to the start of the line.
1987                  */
1988 !               find_last_paren(l);
1989   
1990                 if ((trypos = find_match_paren(ind_maxparen,
1991                                                      ind_maxcomment)) != NULL)
1992 --- 7122,7144 ----
1993                  *     bar;
1994                  * indent_to_0 here;
1995                  */
1996 !               if (cin_ends_in(l, (char_u*)";", NULL))
1997                 {
1998                     l = ml_get(curwin->w_cursor.lnum - 1);
1999 !                   if (cin_ends_in(l, (char_u *)",", NULL)
2000                             || (*l != NUL && l[STRLEN(l) - 1] == '\\'))
2001                         break;
2002                     l = ml_get_curline();
2003                 }
2004   
2005                 /*
2006                  * Doesn't look like anything interesting -- so just
2007                  * use the indent of this line.
2008                  *
2009                  * Position the cursor over the rightmost paren, so that
2010                  * matching it will take us back to the start of the line.
2011                  */
2012 !               find_last_paren(l, '(', ')');
2013   
2014                 if ((trypos = find_match_paren(ind_maxparen,
2015                                                      ind_maxcomment)) != NULL)
2016 ***************
2017 *** 6375,6380 ****
2018 --- 7150,7174 ----
2019             /* add extra indent for a comment */
2020             if (cin_iscomment(theline))
2021                 amount += ind_comment;
2022
2023 +           /* add extra indent if the previous line ended in a backslash:
2024 +            *        "asdfasdf\
2025 +            *            here";
2026 +            *      char *foo = "asdf\
2027 +            *                   here";
2028 +            */
2029 +           if (cur_curpos.lnum > 1)
2030 +           {
2031 +               l = ml_get(cur_curpos.lnum - 1);
2032 +               if (*l != NUL && l[STRLEN(l) - 1] == '\\')
2033 +               {
2034 +                   cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1);
2035 +                   if (cur_amount > 0)
2036 +                       amount = cur_amount;
2037 +                   else if (cur_amount == 0)
2038 +                       amount += ind_continuation;
2039 +               }
2040 +           }
2041         }
2042       }
2043   
2044 *** ../vim-6.2.503/src/testdir/test3.in Sun May  4 13:29:30 2003
2045 --- src/testdir/test3.in        Mon Apr 26 16:56:42 2004
2046 ***************
2047 *** 504,509 ****
2048 --- 504,513 ----
2049         int indented;
2050   {}
2051   
2052 + char *a[] = {"aaa", "bbb",
2053 +       "ccc", NULL};
2054 + // here
2055
2056   char *tab[] = {"aaa",
2057         "xx", /* xx */};    /* asdf */
2058   int not_indented;
2059 ***************
2060 *** 523,538 ****
2061 --- 527,709 ----
2062         bar;
2063   int foo;
2064   
2065 + #if defined(foo) \
2066 +       && defined(bar)
2067   char * xx = "asdf\
2068         foo\
2069         bor";
2070   int x;
2071   
2072 + char    *foo = "asdf\
2073 +       asdf\
2074 +       asdf",
2075 +       *bar;
2076
2077 + void f()
2078 + {
2079 + #if defined(foo) \
2080 +       && defined(bar)
2081 + char    *foo = "asdf\
2082 +       asdf\
2083 +       asdf",
2084 +       *bar;
2085 +       {
2086 +       int i;
2087 + char    *foo = "asdf\
2088 +       asdf\
2089 +       asdf",
2090 +       *bar;
2091 +       }
2092 + #endif
2093 + }
2094 + #endif
2095
2096   int y;                // comment
2097                 // comment
2098   
2099         // comment
2100   
2101 + {
2102 +       Constructor(int a,
2103 +                       int b )  : BaseClass(a)
2104 +       {
2105 +       }
2106 + }
2107
2108 + void foo()
2109 + {
2110 +       char one,
2111 +       two;
2112 +       struct bla piet,
2113 +       jan;
2114 +       enum foo kees,
2115 +       jannie;
2116 +       static unsigned sdf,
2117 +       krap;
2118 +       unsigned int piet,
2119 +       jan;
2120 +       int
2121 +       kees,
2122 +       jan;
2123 + }
2124
2125 + {
2126 +       t(int f,
2127 +                       int d);         // )
2128 +       d();
2129 + }
2130
2131 + Constructor::Constructor(int a,
2132 +                          int b 
2133 +                         )  : 
2134 +    BaseClass(a,
2135 +              b,
2136 +              c),
2137 +    mMember(b),
2138 + {
2139 + }
2140
2141 + Constructor::Constructor(int a,
2142 +                          int b )  : 
2143 +    BaseClass(a)
2144 + {
2145 + }
2146
2147 + Constructor::Constructor(int a,
2148 +                          int b ) /*x*/ : /*x*/ BaseClass(a),
2149 +                                                member(b)
2150 + {
2151 + }
2152
2153 + class CAbc :
2154 +    public BaseClass1,
2155 +    protected BaseClass2
2156 + {
2157 +    int Test() { return FALSE; }
2158 +    int Test1() { return TRUE; }
2159
2160 +    CAbc(int a, int b )  : 
2161 +       BaseClass(a)
2162 +    { 
2163 +       switch(xxx)
2164 +       {
2165 +          case abc:
2166 +             asdf();
2167 +             break;
2168
2169 +          case 999:
2170 +             baer();
2171 +             break;
2172 +       }
2173 +    }
2174
2175 + public: // <-- this was incoreectly indented before!!
2176 +    void testfall();
2177 + protected:
2178 +    void testfall();
2179 + };
2180
2181 + class CAbc : public BaseClass1,
2182 +              protected BaseClass2
2183 + {
2184 + };
2185
2186 + static struct
2187 + {
2188 +     int a;
2189 +     int b;
2190 + } variable[COUNT] =
2191 + {
2192 +     {
2193 +         123,
2194 +         456
2195 +     },
2196 +       {
2197 +         123,
2198 +         456
2199 +     }
2200 + };
2201
2202 + static struct
2203 + {
2204 +     int a;
2205 +     int b;
2206 + } variable[COUNT] =
2207 + {
2208 +     { 123, 456 },
2209 +       { 123, 456 }
2210 + };
2211
2212 + void asdf()           /* ind_maxparen may cause trouble here */
2213 + {
2214 +       if ((0
2215 +                               && 1
2216 +                               && 1
2217 +                               && 1
2218 +                               && 1
2219 +                               && 1
2220 +                               && 1
2221 +                               && 1
2222 +                               && 1
2223 +                               && 1
2224 +                               && 1
2225 +                               && 1
2226 +                               && 1
2227 +                               && 1
2228 +                               && 1
2229 +                               && 1
2230 +                               && 1
2231 +                               && 1
2232 +                               && 1
2233 +                               && 1
2234 +                               && 1
2235 +                               && 1
2236 +                               && 1
2237 +                               && 1
2238 +                               && 1
2239 +                               && 1)) break;
2240 + }
2241
2242   /* end of AUTO */
2243   
2244   STARTTEST
2245 ***************
2246 *** 900,905 ****
2247 --- 1071,1195 ----
2248         c1 && c2
2249         )
2250         foo;
2251 + }
2252
2253 + STARTTEST
2254 + :set cino=b1
2255 + 2kdd]]=][
2256 + ENDTEST
2257
2258 + void f()
2259 + {
2260 +       switch (x)
2261 +       {
2262 +               case 1:
2263 +                       a = b;
2264 +                       break;
2265 +               default:
2266 +                       a = 0;
2267 +                       break;
2268 +       }
2269 + }
2270
2271 + STARTTEST
2272 + :set cino=(0,W5
2273 + 2kdd]]=][
2274 + ENDTEST
2275
2276 + void f()
2277 + {
2278 +       invokeme(
2279 +       argu,
2280 +       ment);
2281 +       invokeme(
2282 +       argu,
2283 +       ment
2284 +       );
2285 +       invokeme(argu,
2286 +       ment
2287 +       );
2288 + }
2289
2290 + STARTTEST
2291 + :set cino=/6
2292 + 2kdd]]=][
2293 + ENDTEST
2294
2295 + void f()
2296 + {
2297 +       statement;
2298 +               // comment 1
2299 +       // comment 2
2300 + }
2301
2302 + STARTTEST
2303 + :set cino=
2304 + 2kdd]]/comment 1/+1
2305 + ==
2306 + ENDTEST
2307
2308 + void f()
2309 + {
2310 +       statement;
2311 +          // comment 1
2312 +       // comment 2
2313 + }
2314
2315 + STARTTEST
2316 + :set cino=g0
2317 + 2kdd]]=][
2318 + ENDTEST
2319
2320 + class CAbc
2321 + {
2322 +    int Test() { return FALSE; }
2323
2324 + public: // comment
2325 +    void testfall();
2326 + protected:
2327 +    void testfall();
2328 + };
2329
2330 + STARTTEST
2331 + :set cino=(0,W2s
2332 + 2kdd]]=][
2333 + ENDTEST
2334
2335 + {
2336 +    averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
2337 +          asdasdf,
2338 +          func(asdf,
2339 +               asdfadsf),
2340 +          asdfasdf
2341 +          );
2342
2343 +    /* those are ugly, but consequent */
2344
2345 +    func()->asd(asdasdf,
2346 +                averylongfunctionname(
2347 +                      abc,
2348 +                      dec)->averylongfunctionname(
2349 +                            asdfadsf,
2350 +                            asdfasdf,
2351 +                            asdfasdf,
2352 +                            ),
2353 +                func(asdfadf,
2354 +                     asdfasdf
2355 +                    ),
2356 +                asdasdf
2357 +               );
2358
2359 +    averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
2360 +                abc,
2361 +                dec)->asdfasdfasdf(
2362 +                      asdfadsf,
2363 +                      asdfasdf,
2364 +                      asdfasdf,
2365 +                      ),
2366 +          func(asdfadf,
2367 +               asdfasdf),
2368 +          asdasdf
2369 +          );
2370   }
2371   
2372   STARTTEST
2373 *** ../vim-6.2.503/src/testdir/test3.ok Sun May  4 13:29:34 2003
2374 --- src/testdir/test3.ok        Mon Apr 26 16:57:16 2004
2375 ***************
2376 *** 492,497 ****
2377 --- 492,501 ----
2378         int indented;
2379   {}
2380   
2381 + char *a[] = {"aaa", "bbb",
2382 +       "ccc", NULL};
2383 + // here
2384
2385   char *tab[] = {"aaa",
2386         "xx", /* xx */};    /* asdf */
2387   int not_indented;
2388 ***************
2389 *** 511,526 ****
2390         bar;
2391   int foo;
2392   
2393   char * xx = "asdf\
2394 !       foo\
2395 !       bor";
2396   int x;
2397   
2398   int y;                // comment
2399   // comment
2400   
2401   // comment
2402   
2403   /* end of AUTO */
2404   
2405   
2406 --- 515,697 ----
2407         bar;
2408   int foo;
2409   
2410 + #if defined(foo) \
2411 +       && defined(bar)
2412   char * xx = "asdf\
2413 !                        foo\
2414 !                        bor";
2415   int x;
2416   
2417 + char    *foo = "asdf\
2418 +                               asdf\
2419 +                               asdf",
2420 +               *bar;
2421
2422 + void f()
2423 + {
2424 + #if defined(foo) \
2425 +       && defined(bar)
2426 +       char    *foo = "asdf\
2427 +                                       asdf\
2428 +                                       asdf",
2429 +                       *bar;
2430 +       {
2431 +               int i;
2432 +               char    *foo = "asdf\
2433 +                                               asdf\
2434 +                                               asdf",
2435 +                               *bar;
2436 +       }
2437 + #endif
2438 + }
2439 + #endif
2440
2441   int y;                // comment
2442   // comment
2443   
2444   // comment
2445   
2446 + {
2447 +       Constructor(int a,
2448 +                       int b )  : BaseClass(a)
2449 +       {
2450 +       }
2451 + }
2452
2453 + void foo()
2454 + {
2455 +       char one,
2456 +                two;
2457 +       struct bla piet,
2458 +                          jan;
2459 +       enum foo kees,
2460 +                        jannie;
2461 +       static unsigned sdf,
2462 +                                       krap;
2463 +       unsigned int piet,
2464 +                                jan;
2465 +       int
2466 +               kees,
2467 +               jan;
2468 + }
2469
2470 + {
2471 +       t(int f,
2472 +                       int d);         // )
2473 +       d();
2474 + }
2475
2476 + Constructor::Constructor(int a,
2477 +               int b 
2478 +               )  : 
2479 +       BaseClass(a,
2480 +                       b,
2481 +                       c),
2482 +       mMember(b),
2483 + {
2484 + }
2485
2486 + Constructor::Constructor(int a,
2487 +               int b )  : 
2488 +       BaseClass(a)
2489 + {
2490 + }
2491
2492 + Constructor::Constructor(int a,
2493 +               int b ) /*x*/ : /*x*/ BaseClass(a),
2494 +                                                         member(b)
2495 + {
2496 + }
2497
2498 + class CAbc :
2499 +       public BaseClass1,
2500 +       protected BaseClass2
2501 + {
2502 +       int Test() { return FALSE; }
2503 +       int Test1() { return TRUE; }
2504
2505 +       CAbc(int a, int b )  : 
2506 +               BaseClass(a)
2507 +       { 
2508 +               switch(xxx)
2509 +               {
2510 +                       case abc:
2511 +                               asdf();
2512 +                               break;
2513
2514 +                       case 999:
2515 +                               baer();
2516 +                               break;
2517 +               }
2518 +       }
2519
2520 +       public: // <-- this was incoreectly indented before!!
2521 +       void testfall();
2522 +       protected:
2523 +       void testfall();
2524 + };
2525
2526 + class CAbc : public BaseClass1,
2527 +                        protected BaseClass2
2528 + {
2529 + };
2530
2531 + static struct
2532 + {
2533 +       int a;
2534 +       int b;
2535 + } variable[COUNT] =
2536 + {
2537 +       {
2538 +               123,
2539 +               456
2540 +       },
2541 +       {
2542 +               123,
2543 +               456
2544 +       }
2545 + };
2546
2547 + static struct
2548 + {
2549 +       int a;
2550 +       int b;
2551 + } variable[COUNT] =
2552 + {
2553 +       { 123, 456 },
2554 +       { 123, 456 }
2555 + };
2556
2557 + void asdf()           /* ind_maxparen may cause trouble here */
2558 + {
2559 +       if ((0
2560 +                               && 1
2561 +                               && 1
2562 +                               && 1
2563 +                               && 1
2564 +                               && 1
2565 +                               && 1
2566 +                               && 1
2567 +                               && 1
2568 +                               && 1
2569 +                               && 1
2570 +                               && 1
2571 +                               && 1
2572 +                               && 1
2573 +                               && 1
2574 +                               && 1
2575 +                               && 1
2576 +                               && 1
2577 +                               && 1
2578 +                               && 1
2579 +                               && 1
2580 +                               && 1
2581 +                               && 1
2582 +                               && 1
2583 +                               && 1
2584 +                               && 1)) break;
2585 + }
2586
2587   /* end of AUTO */
2588   
2589   
2590 ***************
2591 *** 802,806 ****
2592 --- 973,1071 ----
2593                 c1 && c2
2594         )
2595                 foo;
2596 + }
2597
2598
2599 + void f()
2600 + {
2601 +       switch (x)
2602 +       {
2603 +               case 1:
2604 +                       a = b;
2605 +               break;
2606 +               default:
2607 +                       a = 0;
2608 +               break;
2609 +       }
2610 + }
2611
2612
2613 + void f()
2614 + {
2615 +       invokeme(
2616 +                argu,
2617 +                ment);
2618 +       invokeme(
2619 +                argu,
2620 +                ment
2621 +                );
2622 +       invokeme(argu,
2623 +                        ment
2624 +                       );
2625 + }
2626
2627
2628 + void f()
2629 + {
2630 +       statement;
2631 +                 // comment 1
2632 +                 // comment 2
2633 + }
2634
2635
2636 + void f()
2637 + {
2638 +       statement;
2639 +          // comment 1
2640 +          // comment 2
2641 + }
2642
2643
2644 + class CAbc
2645 + {
2646 +       int Test() { return FALSE; }
2647
2648 + public: // comment
2649 +       void testfall();
2650 + protected:
2651 +       void testfall();
2652 + };
2653
2654
2655 + {
2656 +       averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
2657 +                       asdasdf,
2658 +                       func(asdf,
2659 +                                asdfadsf),
2660 +                       asdfasdf
2661 +                       );
2662
2663 +       /* those are ugly, but consequent */
2664
2665 +       func()->asd(asdasdf,
2666 +                               averylongfunctionname(
2667 +                                               abc,
2668 +                                               dec)->averylongfunctionname(
2669 +                                                               asdfadsf,
2670 +                                                               asdfasdf,
2671 +                                                               asdfasdf,
2672 +                                                               ),
2673 +                               func(asdfadf,
2674 +                                        asdfasdf
2675 +                                       ),
2676 +                               asdasdf
2677 +                          );
2678
2679 +       averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
2680 +                                       abc,
2681 +                                       dec)->asdfasdfasdf(
2682 +                                                       asdfadsf,
2683 +                                                       asdfasdf,
2684 +                                                       asdfasdf,
2685 +                                                       ),
2686 +                       func(asdfadf,
2687 +                                asdfasdf),
2688 +                       asdasdf
2689 +                       );
2690   }
2691   
2692 *** ../vim-6.2.503/src/version.c        Mon Apr 26 12:37:27 2004
2693 --- src/version.c       Mon Apr 26 18:54:36 2004
2694 ***************
2695 *** 639,640 ****
2696 --- 639,642 ----
2697   {   /* Add new patch number below this line */
2698 + /**/
2699 +     504,
2700   /**/
2701
2702 -- 
2703 `The Guide says there is an art to flying,' said Ford, `or at least a
2704 knack. The knack lies in learning how to throw yourself at the ground
2705 and miss.' He smiled weakly.
2706                 -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
2707
2708  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
2709 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
2710 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
2711  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
This page took 0.223886 seconds and 3 git commands to generate.