829
|
1 /* start of AUTO matically checked vim: set ts=4 : */
|
7
|
2 {
|
|
3 if (test)
|
|
4 cmd1;
|
|
5 cmd2;
|
|
6 }
|
|
7
|
|
8 {
|
|
9 if (test)
|
|
10 cmd1;
|
|
11 else
|
|
12 cmd2;
|
|
13 }
|
|
14
|
|
15 {
|
|
16 if (test)
|
|
17 {
|
|
18 cmd1;
|
|
19 cmd2;
|
|
20 }
|
|
21 }
|
|
22
|
|
23 {
|
|
24 if (test)
|
|
25 {
|
|
26 cmd1;
|
|
27 else
|
|
28 }
|
|
29 }
|
|
30
|
|
31 {
|
|
32 while (this)
|
|
33 if (test)
|
|
34 cmd1;
|
|
35 cmd2;
|
|
36 }
|
|
37
|
|
38 {
|
|
39 while (this)
|
|
40 if (test)
|
|
41 cmd1;
|
|
42 else
|
|
43 cmd2;
|
|
44 }
|
|
45
|
|
46 {
|
|
47 if (test)
|
|
48 {
|
|
49 cmd;
|
|
50 }
|
|
51
|
|
52 if (test)
|
|
53 cmd;
|
|
54 }
|
|
55
|
|
56 {
|
|
57 if (test) {
|
|
58 cmd;
|
|
59 }
|
|
60
|
|
61 if (test) cmd;
|
|
62 }
|
|
63
|
|
64 {
|
|
65 cmd1;
|
|
66 for (blah)
|
|
67 while (this)
|
|
68 if (test)
|
|
69 cmd2;
|
|
70 cmd3;
|
|
71 }
|
|
72
|
|
73 {
|
|
74 cmd1;
|
|
75 for (blah)
|
|
76 while (this)
|
|
77 if (test)
|
|
78 cmd2;
|
|
79 cmd3;
|
|
80
|
|
81 if (test)
|
|
82 {
|
|
83 cmd1;
|
|
84 cmd2;
|
|
85 cmd3;
|
|
86 }
|
|
87 }
|
|
88
|
|
89
|
|
90 /* Test for 'cindent' do/while mixed with if/else: */
|
|
91
|
|
92 {
|
|
93 do
|
|
94 if (asdf)
|
|
95 asdfasd;
|
|
96 while (cond);
|
|
97
|
|
98 do
|
|
99 if (asdf)
|
|
100 while (asdf)
|
|
101 asdf;
|
|
102 while (asdf);
|
|
103 }
|
|
104
|
|
105 /* Test for 'cindent' with two ) on a continuation line */
|
|
106 {
|
|
107 if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
|
|
108 aal;sdkjf ( ;asldfkja;sldfk
|
|
109 al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
|
|
110 line up here;
|
|
111 }
|
|
112
|
|
113
|
|
114 /* C++ tests: */
|
|
115
|
|
116 // foo() these three lines should remain in column 0
|
|
117 // {
|
|
118 // }
|
|
119
|
|
120 /* Test for continuation and unterminated lines: */
|
|
121 {
|
|
122 i = 99 + 14325 +
|
|
123 21345 +
|
|
124 21345 +
|
|
125 21345 + ( 21345 +
|
|
126 21345) +
|
|
127 2345 +
|
|
128 1234;
|
|
129 c = 1;
|
|
130 }
|
|
131
|
|
132 /*
|
|
133 testje for indent with empty line
|
|
134
|
|
135 here */
|
|
136
|
|
137 {
|
|
138 if (testing &&
|
|
139 not a joke ||
|
|
140 line up here)
|
|
141 hay;
|
|
142 if (testing &&
|
|
143 (not a joke || testing
|
|
144 )line up here)
|
|
145 hay;
|
|
146 if (testing &&
|
|
147 (not a joke || testing
|
|
148 line up here))
|
|
149 hay;
|
|
150 }
|
|
151
|
|
152
|
|
153 {
|
|
154 switch (c)
|
|
155 {
|
|
156 case xx:
|
|
157 do
|
|
158 if (asdf)
|
|
159 do
|
|
160 asdfasdf;
|
|
161 while (asdf);
|
|
162 else
|
|
163 asdfasdf;
|
|
164 while (cond);
|
|
165 case yy:
|
|
166 case xx:
|
|
167 case zz:
|
|
168 testing;
|
|
169 }
|
|
170 }
|
|
171
|
|
172 {
|
|
173 if (cond) {
|
|
174 foo;
|
|
175 }
|
|
176 else
|
|
177 {
|
|
178 bar;
|
|
179 }
|
|
180 }
|
|
181
|
|
182 {
|
|
183 if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
|
|
184 alsdkfj (asldk;fj
|
|
185 awith cino=(0 ;lf this one goes to below the paren with ==
|
|
186 ;laksjfd ;lsakdjf ;alskdf asd)
|
|
187 asdfasdf;)))
|
|
188 asdfasdf;
|
|
189 }
|
|
190
|
|
191 int
|
|
192 func(a, b)
|
|
193 int a;
|
|
194 int c;
|
|
195 {
|
|
196 if (c1 && (c2 ||
|
|
197 c3))
|
|
198 foo;
|
|
199 if (c1 &&
|
|
200 (c2 || c3)
|
|
201 )
|
|
202 }
|
|
203
|
|
204 {
|
|
205 while (asd)
|
|
206 {
|
|
207 if (asdf)
|
|
208 if (test)
|
|
209 if (that)
|
|
210 {
|
|
211 if (asdf)
|
|
212 do
|
|
213 cdasd;
|
|
214 while (as
|
|
215 df);
|
|
216 }
|
|
217 else
|
|
218 if (asdf)
|
|
219 asdf;
|
|
220 else
|
|
221 asdf;
|
|
222 asdf;
|
|
223 }
|
|
224 }
|
|
225
|
|
226 {
|
|
227 s = "/*"; b = ';'
|
|
228 s = "/*"; b = ';';
|
|
229 a = b;
|
|
230 }
|
|
231
|
|
232 {
|
|
233 switch (a)
|
|
234 {
|
|
235 case a:
|
|
236 switch (t)
|
|
237 {
|
|
238 case 1:
|
|
239 cmd;
|
|
240 break;
|
|
241 case 2:
|
|
242 cmd;
|
|
243 break;
|
|
244 }
|
|
245 cmd;
|
|
246 break;
|
|
247 case b:
|
|
248 {
|
|
249 int i;
|
|
250 cmd;
|
|
251 }
|
|
252 break;
|
|
253 case c: {
|
|
254 int i;
|
|
255 cmd;
|
|
256 }
|
|
257 case d: if (cond &&
|
|
258 test) { /* this line doesn't work right */
|
|
259 int i;
|
|
260 cmd;
|
|
261 }
|
|
262 break;
|
|
263 }
|
|
264 }
|
|
265
|
|
266 {
|
|
267 if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
|
|
268 (bp_to->b_p_initialized ||
|
|
269 (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
|
|
270 return;
|
|
271 label :
|
|
272 asdf = asdf ?
|
|
273 asdf : asdf;
|
|
274 asdf = asdf ?
|
|
275 asdf: asdf;
|
|
276 }
|
|
277
|
|
278 /* Special Comments : This function has the added complexity (compared */
|
|
279 /* : to addtolist) of having to check for a detail */
|
|
280 /* : texture and add that to the list first. */
|
|
281
|
|
282 char *(array[100]) = {
|
|
283 "testje",
|
|
284 "foo",
|
|
285 "bar",
|
|
286 }
|
|
287
|
|
288 enum soppie
|
|
289 {
|
|
290 yes = 0,
|
|
291 no,
|
|
292 maybe
|
|
293 };
|
|
294
|
|
295 typedef enum soppie
|
|
296 {
|
|
297 yes = 0,
|
|
298 no,
|
|
299 maybe
|
|
300 };
|
|
301
|
3218
|
302 static enum
|
|
303 {
|
|
304 yes = 0,
|
|
305 no,
|
|
306 maybe
|
|
307 } soppie;
|
|
308
|
7
|
309 {
|
|
310 int a,
|
|
311 b;
|
|
312 }
|
|
313
|
|
314 {
|
|
315 struct Type
|
|
316 {
|
|
317 int i;
|
|
318 char *str;
|
|
319 } var[] =
|
|
320 {
|
|
321 0, "zero",
|
|
322 1, "one",
|
|
323 2, "two",
|
|
324 3, "three"
|
|
325 };
|
|
326
|
|
327 float matrix[3][3] =
|
|
328 {
|
|
329 {
|
|
330 0,
|
|
331 1,
|
|
332 2
|
|
333 },
|
|
334 {
|
|
335 3,
|
|
336 4,
|
|
337 5
|
|
338 },
|
|
339 {
|
|
340 6,
|
|
341 7,
|
|
342 8
|
|
343 }
|
|
344 };
|
|
345 }
|
|
346
|
|
347 {
|
|
348 /* blah ( blah */
|
|
349 /* where does this go? */
|
|
350
|
|
351 /* blah ( blah */
|
|
352 cmd;
|
|
353
|
|
354 func(arg1,
|
|
355 /* comment */
|
|
356 arg2);
|
|
357 a;
|
|
358 {
|
|
359 b;
|
|
360 {
|
|
361 c; /* Hey, NOW it indents?! */
|
|
362 }
|
|
363 }
|
|
364
|
|
365 {
|
|
366 func(arg1,
|
|
367 arg2,
|
|
368 arg3);
|
|
369 /* Hey, what am I doing here? Is this coz of the ","? */
|
|
370 }
|
|
371 }
|
|
372
|
|
373 main ()
|
|
374 {
|
|
375 if (cond)
|
|
376 {
|
|
377 a = b;
|
|
378 }
|
|
379 if (cond) {
|
|
380 a = c;
|
|
381 }
|
|
382 if (cond)
|
|
383 a = d;
|
|
384 return;
|
|
385 }
|
|
386
|
|
387 {
|
|
388 case 2: if (asdf &&
|
|
389 asdfasdf)
|
|
390 aasdf;
|
|
391 a = 9;
|
|
392 case 3: if (asdf)
|
|
393 aasdf;
|
|
394 a = 9;
|
|
395 case 4: x = 1;
|
|
396 y = 2;
|
|
397
|
|
398 label: if (asdf)
|
|
399 here;
|
|
400
|
|
401 label: if (asdf &&
|
|
402 asdfasdf)
|
|
403 {
|
|
404 }
|
|
405
|
|
406 label: if (asdf &&
|
|
407 asdfasdf) {
|
|
408 there;
|
|
409 }
|
|
410
|
|
411 label: if (asdf &&
|
|
412 asdfasdf)
|
|
413 there;
|
|
414 }
|
|
415
|
|
416 {
|
|
417 /*
|
|
418 hello with ":set comments= cino=c5"
|
|
419 */
|
|
420
|
|
421 /*
|
|
422 hello with ":set comments= cino="
|
|
423 */
|
|
424 }
|
|
425
|
|
426
|
|
427 {
|
|
428 if (a < b) {
|
|
429 a = a + 1;
|
|
430 } else
|
|
431 a = a + 2;
|
|
432
|
|
433 if (a)
|
|
434 do {
|
|
435 testing;
|
|
436 } while (asdfasdf);
|
|
437 a = b + 1;
|
|
438 asdfasdf
|
|
439 }
|
|
440
|
|
441 class bob
|
|
442 {
|
|
443 int foo() {return 1;}
|
|
444 int bar;
|
|
445 }
|
|
446
|
|
447 main()
|
|
448 {
|
|
449 while(1)
|
|
450 if (foo)
|
|
451 {
|
|
452 bar;
|
|
453 }
|
|
454 else {
|
|
455 asdf;
|
|
456 }
|
|
457 misplacedline;
|
|
458 }
|
|
459
|
|
460 {
|
|
461 if (clipboard.state == SELECT_DONE
|
|
462 && ((row == clipboard.start.lnum
|
|
463 && col >= clipboard.start.col)
|
|
464 || row > clipboard.start.lnum))
|
|
465 }
|
|
466
|
|
467 {
|
|
468 if (1) {i += 4;}
|
|
469 where_am_i;
|
|
470 return 0;
|
|
471 }
|
|
472
|
|
473 {
|
|
474 {
|
|
475 } // sdf(asdf
|
|
476 if (asdf)
|
|
477 asd;
|
|
478 }
|
|
479
|
|
480 {
|
|
481 label1:
|
|
482 label2:
|
|
483 }
|
|
484
|
|
485 {
|
|
486 int fooRet = foo(pBar1, false /*fKB*/,
|
|
487 true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
|
|
488 f() {
|
|
489 for ( i = 0;
|
|
490 i < m;
|
|
491 /* c */ i++ ) {
|
|
492 a = b;
|
|
493 }
|
|
494 }
|
|
495 }
|
|
496
|
|
497 {
|
|
498 f1(/*comment*/);
|
|
499 f2();
|
|
500 }
|
|
501
|
|
502 {
|
|
503 do {
|
|
504 if (foo) {
|
|
505 } else
|
|
506 ;
|
|
507 } while (foo);
|
|
508 foo(); // was wrong
|
|
509 }
|
|
510
|
|
511 int x; // no extra indent because of the ;
|
|
512 void func()
|
|
513 {
|
|
514 }
|
|
515
|
|
516 char *tab[] = {"aaa",
|
|
517 "};", /* }; */ NULL}
|
|
518 int indented;
|
|
519 {}
|
|
520
|
|
521 char *a[] = {"aaa", "bbb",
|
|
522 "ccc", NULL};
|
|
523 // here
|
|
524
|
|
525 char *tab[] = {"aaa",
|
|
526 "xx", /* xx */}; /* asdf */
|
|
527 int not_indented;
|
|
528
|
|
529 {
|
|
530 do {
|
|
531 switch (bla)
|
|
532 {
|
|
533 case 1: if (foo)
|
|
534 bar;
|
|
535 }
|
|
536 } while (boo);
|
|
537 wrong;
|
|
538 }
|
|
539
|
|
540 int foo,
|
|
541 bar;
|
|
542 int foo;
|
|
543
|
|
544 #if defined(foo) \
|
|
545 && defined(bar)
|
|
546 char * xx = "asdf\
|
|
547 foo\
|
|
548 bor";
|
|
549 int x;
|
|
550
|
|
551 char *foo = "asdf\
|
|
552 asdf\
|
|
553 asdf",
|
|
554 *bar;
|
|
555
|
|
556 void f()
|
|
557 {
|
|
558 #if defined(foo) \
|
|
559 && defined(bar)
|
|
560 char *foo = "asdf\
|
|
561 asdf\
|
|
562 asdf",
|
|
563 *bar;
|
|
564 {
|
|
565 int i;
|
|
566 char *foo = "asdf\
|
|
567 asdf\
|
|
568 asdf",
|
|
569 *bar;
|
|
570 }
|
|
571 #endif
|
|
572 }
|
|
573 #endif
|
|
574
|
|
575 int y; // comment
|
|
576 // comment
|
|
577
|
|
578 // comment
|
|
579
|
|
580 {
|
|
581 Constructor(int a,
|
|
582 int b ) : BaseClass(a)
|
|
583 {
|
|
584 }
|
|
585 }
|
|
586
|
|
587 void foo()
|
|
588 {
|
|
589 char one,
|
|
590 two;
|
|
591 struct bla piet,
|
|
592 jan;
|
|
593 enum foo kees,
|
|
594 jannie;
|
|
595 static unsigned sdf,
|
|
596 krap;
|
|
597 unsigned int piet,
|
|
598 jan;
|
|
599 int
|
|
600 kees,
|
|
601 jan;
|
|
602 }
|
|
603
|
|
604 {
|
|
605 t(int f,
|
|
606 int d); // )
|
|
607 d();
|
|
608 }
|
|
609
|
|
610 Constructor::Constructor(int a,
|
|
611 int b
|
|
612 ) :
|
|
613 BaseClass(a,
|
|
614 b,
|
|
615 c),
|
|
616 mMember(b),
|
|
617 {
|
|
618 }
|
|
619
|
|
620 Constructor::Constructor(int a,
|
|
621 int b ) :
|
|
622 BaseClass(a)
|
|
623 {
|
|
624 }
|
|
625
|
|
626 Constructor::Constructor(int a,
|
|
627 int b ) /*x*/ : /*x*/ BaseClass(a),
|
828
|
628 member(b)
|
7
|
629 {
|
|
630 }
|
|
631
|
|
632 class CAbc :
|
|
633 public BaseClass1,
|
|
634 protected BaseClass2
|
|
635 {
|
|
636 int Test() { return FALSE; }
|
|
637 int Test1() { return TRUE; }
|
|
638
|
|
639 CAbc(int a, int b ) :
|
|
640 BaseClass(a)
|
|
641 {
|
|
642 switch(xxx)
|
|
643 {
|
|
644 case abc:
|
|
645 asdf();
|
|
646 break;
|
|
647
|
|
648 case 999:
|
|
649 baer();
|
|
650 break;
|
|
651 }
|
|
652 }
|
|
653
|
|
654 public: // <-- this was incoreectly indented before!!
|
|
655 void testfall();
|
|
656 protected:
|
|
657 void testfall();
|
|
658 };
|
|
659
|
|
660 class CAbc : public BaseClass1,
|
828
|
661 protected BaseClass2
|
7
|
662 {
|
|
663 };
|
|
664
|
|
665 static struct
|
|
666 {
|
|
667 int a;
|
|
668 int b;
|
|
669 } variable[COUNT] =
|
|
670 {
|
|
671 {
|
|
672 123,
|
|
673 456
|
|
674 },
|
|
675 {
|
|
676 123,
|
|
677 456
|
|
678 }
|
|
679 };
|
|
680
|
|
681 static struct
|
|
682 {
|
|
683 int a;
|
|
684 int b;
|
|
685 } variable[COUNT] =
|
|
686 {
|
|
687 { 123, 456 },
|
|
688 { 123, 456 }
|
|
689 };
|
|
690
|
|
691 void asdf() /* ind_maxparen may cause trouble here */
|
|
692 {
|
|
693 if ((0
|
|
694 && 1
|
|
695 && 1
|
|
696 && 1
|
|
697 && 1
|
|
698 && 1
|
|
699 && 1
|
|
700 && 1
|
|
701 && 1
|
|
702 && 1
|
|
703 && 1
|
|
704 && 1
|
|
705 && 1
|
|
706 && 1
|
|
707 && 1
|
|
708 && 1
|
|
709 && 1
|
|
710 && 1
|
|
711 && 1
|
|
712 && 1
|
|
713 && 1
|
|
714 && 1
|
|
715 && 1
|
|
716 && 1
|
|
717 && 1
|
|
718 && 1)) break;
|
|
719 }
|
|
720
|
827
|
721 foo()
|
|
722 {
|
|
723 a = cond ? foo() : asdf
|
|
724 + asdf;
|
|
725
|
|
726 a = cond ?
|
|
727 foo() : asdf
|
|
728 + asdf;
|
|
729 }
|
|
730
|
|
731 int main(void)
|
|
732 {
|
|
733 if (a)
|
|
734 if (b)
|
|
735 2;
|
|
736 else 3;
|
|
737 next_line_of_code();
|
|
738 }
|
|
739
|
828
|
740 barry()
|
|
741 {
|
|
742 Foo::Foo (int one,
|
|
743 int two)
|
|
744 : something(4)
|
|
745 {}
|
|
746 }
|
|
747
|
|
748 barry()
|
|
749 {
|
|
750 Foo::Foo (int one, int two)
|
|
751 : something(4)
|
|
752 {}
|
|
753 }
|
|
754
|
|
755 Constructor::Constructor(int a,
|
|
756 int b
|
|
757 ) :
|
|
758 BaseClass(a,
|
|
759 b,
|
|
760 c),
|
|
761 mMember(b)
|
|
762 {
|
|
763 }
|
829
|
764 int main ()
|
|
765 {
|
|
766 if (lala)
|
|
767 do
|
|
768 ++(*lolo);
|
|
769 while (lili
|
|
770 && lele);
|
|
771 lulu;
|
|
772 }
|
828
|
773
|
829
|
774 int main ()
|
|
775 {
|
|
776 switch (c)
|
|
777 {
|
|
778 case 'c': if (cond)
|
|
779 {
|
|
780 }
|
|
781 }
|
|
782 }
|
|
783
|
|
784 main()
|
|
785 {
|
|
786 (void) MyFancyFuasdfadsfnction(
|
|
787 argument);
|
|
788 }
|
|
789
|
|
790 main()
|
|
791 {
|
|
792 char foo[] = "/*";
|
|
793 /* as
|
|
794 df */
|
|
795 hello
|
|
796 }
|
2857
|
797
|
|
798 /* valid namespaces with normal indent */
|
|
799 namespace
|
|
800 {
|
|
801 {
|
|
802 111111111111;
|
|
803 }
|
|
804 }
|
|
805 namespace /* test */
|
|
806 {
|
|
807 11111111111111111;
|
|
808 }
|
|
809 namespace // test
|
|
810 {
|
|
811 111111111111111111;
|
|
812 }
|
|
813 namespace
|
|
814 {
|
|
815 111111111111111111;
|
|
816 }
|
|
817 namespace test
|
|
818 {
|
|
819 111111111111111111;
|
|
820 }
|
|
821 namespace{
|
|
822 111111111111111111;
|
|
823 }
|
|
824 namespace test{
|
|
825 111111111111111111;
|
|
826 }
|
|
827 namespace {
|
|
828 111111111111111111;
|
|
829 }
|
|
830 namespace test {
|
|
831 111111111111111111;
|
|
832 namespace test2 {
|
|
833 22222222222222222;
|
|
834 }
|
|
835 }
|
|
836
|
|
837 /* invalid namespaces use block indent */
|
|
838 namespace test test2 {
|
|
839 111111111111111111111;
|
|
840 }
|
|
841 namespace11111111111 {
|
|
842 111111111111;
|
|
843 }
|
|
844 namespace() {
|
|
845 1111111111111;
|
|
846 }
|
|
847 namespace()
|
|
848 {
|
|
849 111111111111111111;
|
|
850 }
|
|
851 namespace test test2
|
|
852 {
|
|
853 1111111111111111111;
|
|
854 }
|
|
855 namespace111111111
|
|
856 {
|
|
857 111111111111111111;
|
|
858 }
|
|
859
|
7
|
860 /* end of AUTO */
|
|
861
|
|
862
|
|
863 {
|
|
864
|
|
865 /* this is
|
|
866 * a real serious
|
|
867 * about life, the
|
|
868 * universe, and the
|
|
869 * rest important big
|
|
870 * comment
|
|
871 */
|
|
872 /* insert " about life, the universe, and the rest" after "serious" */
|
|
873 }
|
|
874
|
|
875
|
|
876 {
|
|
877 /*
|
|
878 * Testing for comments, without 'cin' set
|
|
879 */
|
|
880 about life
|
|
881
|
|
882 /*
|
|
883 * what happens here?
|
|
884 */
|
|
885 there
|
|
886
|
|
887 /*
|
|
888 the end of the comment, try inserting a line below */
|
|
889 line
|
|
890
|
|
891 /* how about
|
|
892 hello
|
|
893 this one */
|
|
894 }
|
|
895
|
|
896
|
|
897 {
|
|
898 var = this + that + vec[0] * vec[0]
|
|
899 + vec[1] * vec[1]
|
|
900 + vec2[2] * vec[2];
|
|
901 }
|
|
902
|
|
903
|
|
904 {
|
|
905 asdf asdflkajds f;
|
|
906 if (tes & ting) {
|
|
907 asdf asdf asdf ;
|
|
908 asdfa sdf asdf;
|
|
909 }
|
|
910 testing1;
|
|
911 if (tes & ting)
|
|
912 {
|
|
913 asdf asdf asdf ;
|
|
914 asdfa sdf asdf;
|
|
915 }
|
|
916 testing2;
|
|
917 }
|
|
918
|
|
919
|
|
920 main ( int first_par, /*
|
|
921 * Comment for
|
|
922 * first par
|
|
923 */
|
|
924 int second_par /*
|
|
925 * Comment for
|
|
926 * second par
|
|
927 */
|
|
928 )
|
|
929 {
|
|
930 func( first_par, /*
|
|
931 * Comment for
|
|
932 * first par
|
|
933 */
|
|
934 second_par /*
|
|
935 * Comment for
|
|
936 * second par
|
|
937 */
|
|
938 );
|
|
939
|
|
940 }
|
|
941
|
|
942
|
|
943 {
|
|
944 do
|
|
945 {
|
|
946 if ()
|
|
947 {
|
|
948 if ()
|
|
949 asdf;
|
|
950 else
|
|
951 asdf;
|
|
952 }
|
|
953 } while ();
|
|
954 cmd; /* this should go under the } */
|
|
955 }
|
|
956
|
|
957
|
|
958 void f()
|
|
959 {
|
|
960 if ( k() ) {
|
|
961 l();
|
|
962
|
|
963 } else { /* Start (two words) end */
|
|
964 m();
|
|
965 }
|
|
966
|
|
967 n();
|
|
968 }
|
|
969
|
|
970
|
|
971 void f()
|
|
972 {
|
|
973 if ( k() )
|
|
974 {
|
|
975 l();
|
|
976 } else { /* Start (two words) end */
|
|
977 m();
|
|
978 }
|
|
979 n(); /* should be under the if () */
|
|
980 }
|
|
981
|
|
982
|
|
983 void bar(void)
|
|
984 {
|
|
985 static array[2][2] =
|
|
986 {
|
|
987 { 1, 2 },
|
|
988 { 3, 4 },
|
|
989 }
|
|
990
|
|
991 while (a)
|
|
992 {
|
|
993 foo(&a);
|
|
994 }
|
|
995
|
|
996 {
|
|
997 int a;
|
|
998 {
|
|
999 a = a + 1;
|
|
1000 }
|
|
1001 }
|
|
1002 b = a;
|
|
1003 }
|
|
1004
|
|
1005 void func(void)
|
|
1006 {
|
|
1007 a = 1;
|
|
1008 {
|
|
1009 b = 2;
|
|
1010 }
|
|
1011 c = 3;
|
|
1012 d = 4;
|
|
1013 }
|
|
1014 /* foo */
|
|
1015
|
|
1016
|
|
1017 a()
|
|
1018 {
|
|
1019 do {
|
|
1020 a = a +
|
|
1021 a;
|
|
1022 } while ( a ); /* add text under this line */
|
|
1023 here
|
|
1024 if ( a )
|
|
1025 a;
|
|
1026 }
|
|
1027
|
|
1028
|
|
1029 a()
|
|
1030 {
|
|
1031 label1:
|
|
1032 /* hmm */
|
|
1033 // comment
|
|
1034 label2: b();
|
|
1035 label3 /* post */:
|
|
1036 /* pre */ label4:
|
|
1037 f(/*com*/);
|
|
1038 if (/*com*/)
|
|
1039 cmd();
|
|
1040 }
|
|
1041
|
|
1042
|
|
1043 /*
|
|
1044 * A simple comment
|
|
1045 */
|
|
1046
|
|
1047 /*
|
|
1048 ** A different comment
|
|
1049 */
|
|
1050
|
|
1051
|
|
1052 void f()
|
|
1053 {
|
|
1054
|
|
1055 /*********
|
|
1056 A comment.
|
|
1057 *********/
|
|
1058 }
|
|
1059
|
|
1060
|
|
1061 void f()
|
|
1062 {
|
|
1063
|
|
1064 /*********
|
|
1065 A comment.
|
|
1066 *********/
|
|
1067 }
|
|
1068
|
|
1069
|
|
1070 void f()
|
|
1071 {
|
|
1072 c = c1 &&
|
|
1073 (
|
|
1074 c2 ||
|
|
1075 c3
|
|
1076 ) && c4;
|
|
1077 }
|
|
1078
|
|
1079
|
|
1080 void f()
|
|
1081 {
|
|
1082 c = c1 &&
|
|
1083 (
|
|
1084 c2 ||
|
|
1085 c3
|
|
1086 ) && c4;
|
|
1087 }
|
|
1088
|
|
1089
|
|
1090 void f()
|
|
1091 {
|
|
1092 c = c1 &&
|
|
1093 (
|
|
1094 c2 ||
|
|
1095 c3
|
|
1096 ) && c4;
|
|
1097 }
|
|
1098
|
|
1099
|
|
1100 void f()
|
|
1101 {
|
|
1102 if ( c1
|
|
1103 && ( c2
|
|
1104 || c3))
|
|
1105 foo;
|
|
1106 }
|
|
1107
|
|
1108
|
|
1109 void f()
|
|
1110 {
|
|
1111 if ( c1
|
|
1112 && ( c2
|
|
1113 || c3))
|
|
1114 foo;
|
|
1115 }
|
|
1116
|
|
1117
|
|
1118 void f()
|
|
1119 {
|
|
1120 c = c1 && (
|
|
1121 c2 ||
|
|
1122 c3
|
|
1123 ) && c4;
|
|
1124 if (
|
|
1125 c1 && c2
|
|
1126 )
|
|
1127 foo;
|
|
1128 }
|
|
1129
|
|
1130
|
|
1131 void f()
|
|
1132 {
|
|
1133 c = c1 && (
|
|
1134 c2 ||
|
|
1135 c3
|
|
1136 ) && c4;
|
|
1137 if (
|
|
1138 c1 && c2
|
|
1139 )
|
|
1140 foo;
|
|
1141 }
|
|
1142
|
|
1143
|
|
1144 void f()
|
|
1145 {
|
|
1146 switch (x)
|
|
1147 {
|
|
1148 case 1:
|
|
1149 a = b;
|
|
1150 break;
|
|
1151 default:
|
|
1152 a = 0;
|
|
1153 break;
|
|
1154 }
|
|
1155 }
|
|
1156
|
|
1157
|
|
1158 void f()
|
|
1159 {
|
|
1160 invokeme(
|
|
1161 argu,
|
|
1162 ment);
|
|
1163 invokeme(
|
|
1164 argu,
|
|
1165 ment
|
|
1166 );
|
|
1167 invokeme(argu,
|
|
1168 ment
|
|
1169 );
|
|
1170 }
|
|
1171
|
|
1172
|
|
1173 void f()
|
|
1174 {
|
|
1175 statement;
|
|
1176 // comment 1
|
|
1177 // comment 2
|
|
1178 }
|
|
1179
|
|
1180
|
|
1181 void f()
|
|
1182 {
|
|
1183 statement;
|
|
1184 // comment 1
|
|
1185 // comment 2
|
|
1186 }
|
|
1187
|
|
1188
|
|
1189 class CAbc
|
|
1190 {
|
|
1191 int Test() { return FALSE; }
|
|
1192
|
|
1193 public: // comment
|
|
1194 void testfall();
|
|
1195 protected:
|
|
1196 void testfall();
|
|
1197 };
|
|
1198
|
|
1199
|
3123
|
1200 class Foo : public Bar
|
|
1201 {
|
|
1202 public:
|
|
1203 virtual void method1(void) = 0;
|
|
1204 virtual void method2(int arg1,
|
|
1205 int arg2,
|
|
1206 int arg3) = 0;
|
|
1207 };
|
|
1208
|
|
1209
|
828
|
1210 void
|
|
1211 foo()
|
|
1212 {
|
|
1213 if (a)
|
|
1214 {
|
|
1215 } else
|
|
1216 asdf;
|
|
1217 }
|
|
1218
|
|
1219
|
7
|
1220 {
|
|
1221 averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
|
|
1222 asdasdf,
|
|
1223 func(asdf,
|
|
1224 asdfadsf),
|
|
1225 asdfasdf
|
|
1226 );
|
|
1227
|
|
1228 /* those are ugly, but consequent */
|
|
1229
|
|
1230 func()->asd(asdasdf,
|
|
1231 averylongfunctionname(
|
|
1232 abc,
|
|
1233 dec)->averylongfunctionname(
|
|
1234 asdfadsf,
|
|
1235 asdfasdf,
|
|
1236 asdfasdf,
|
|
1237 ),
|
|
1238 func(asdfadf,
|
|
1239 asdfasdf
|
|
1240 ),
|
|
1241 asdasdf
|
|
1242 );
|
|
1243
|
|
1244 averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
|
|
1245 abc,
|
|
1246 dec)->asdfasdfasdf(
|
|
1247 asdfadsf,
|
|
1248 asdfasdf,
|
|
1249 asdfasdf,
|
|
1250 ),
|
|
1251 func(asdfadf,
|
|
1252 asdfasdf),
|
|
1253 asdasdf
|
|
1254 );
|
|
1255 }
|
|
1256
|
829
|
1257
|
|
1258 int main ()
|
|
1259 {
|
|
1260 if (cond1 &&
|
|
1261 cond2
|
|
1262 )
|
|
1263 foo;
|
|
1264 }
|
|
1265
|
2776
|
1266
|
|
1267 void func(int a
|
|
1268 #if defined(FOO)
|
|
1269 , int b
|
|
1270 , int c
|
|
1271 #endif
|
|
1272 )
|
|
1273 {
|
|
1274 }
|
|
1275
|
|
1276
|
|
1277 void
|
|
1278 func(int a
|
|
1279 #if defined(FOO)
|
|
1280 , int b
|
|
1281 , int c
|
|
1282 #endif
|
|
1283 )
|
|
1284 {
|
|
1285 }
|
|
1286
|
2805
|
1287
|
|
1288 void func(void)
|
|
1289 {
|
|
1290 if(x==y)
|
|
1291 if(y==z)
|
|
1292 foo=1;
|
|
1293 else { bar=1;
|
|
1294 baz=2;
|
|
1295 }
|
|
1296 printf("Foo!\n");
|
|
1297 }
|
|
1298
|
2843
|
1299 void func1(void)
|
|
1300 {
|
|
1301 char* tab[] = {"foo", "bar",
|
|
1302 "baz", "quux",
|
|
1303 "this line used", "to be indented incorrectly"};
|
|
1304 foo();
|
|
1305 }
|
|
1306
|
|
1307 void func2(void)
|
|
1308 {
|
|
1309 int tab[] =
|
|
1310 {1, 2,
|
|
1311 3, 4,
|
|
1312 5, 6};
|
|
1313
|
|
1314 printf("This line used to be indented incorrectly.\n");
|
|
1315 }
|
|
1316
|
3186
|
1317 int foo[]
|
|
1318 #ifdef BAR
|
|
1319
|
|
1320 = { 1, 2, 3,
|
|
1321 4, 5, 6 }
|
|
1322
|
|
1323 #endif
|
|
1324 ;
|
|
1325 int baz;
|
|
1326
|
2843
|
1327 void func3(void)
|
|
1328 {
|
|
1329 int tab[] = {
|
|
1330 1, 2,
|
|
1331 3, 4,
|
|
1332 5, 6};
|
|
1333
|
3220
|
1334 printf("Don't you dare indent this line incorrectly!\n");
|
|
1335 }
|
|
1336
|
|
1337 void
|
|
1338 func4(a, b,
|
|
1339 c)
|
|
1340 int a;
|
|
1341 int b;
|
|
1342 int c;
|
|
1343 {
|
|
1344 }
|
|
1345
|
|
1346 void
|
|
1347 func5(
|
|
1348 int a,
|
|
1349 int b)
|
|
1350 {
|
|
1351 }
|
|
1352
|
|
1353 void
|
|
1354 func6(
|
|
1355 int a)
|
|
1356 {
|
2843
|
1357 }
|
|
1358
|
2807
|
1359
|
|
1360 void func(void)
|
|
1361 {
|
2953
|
1362 int tab[] =
|
|
1363 {
|
|
1364 1, 2, 3,
|
|
1365 4, 5, 6};
|
|
1366
|
|
1367 printf("Indent this line correctly!\n");
|
|
1368
|
|
1369 switch (foo)
|
|
1370 {
|
|
1371 case bar:
|
|
1372 printf("bar");
|
|
1373 break;
|
|
1374 case baz: {
|
|
1375 printf("baz");
|
|
1376 break;
|
|
1377 }
|
|
1378 case quux:
|
|
1379 printf("But don't break the indentation of this instruction\n");
|
|
1380 break;
|
|
1381 }
|
|
1382 }
|
|
1383
|
|
1384
|
|
1385 void func(void)
|
|
1386 {
|
2807
|
1387 cout << "a"
|
|
1388 << "b"
|
|
1389 << ") :"
|
|
1390 << "c";
|
|
1391 }
|
|
1392
|
2809
|
1393
|
|
1394 void func(void)
|
|
1395 {
|
|
1396 /*
|
|
1397 * This is a comment.
|
|
1398 */
|
|
1399 foo();
|
|
1400 }
|
|
1401
|
2855
|
1402
|
|
1403 void func(void)
|
|
1404 {
|
|
1405 for (int i = 0; i < 10; ++i)
|
|
1406 if (i & 1) {
|
|
1407 foo(1);
|
|
1408 } else
|
|
1409 foo(0);
|
|
1410 baz();
|
|
1411 }
|
|
1412
|
2857
|
1413
|
2879
|
1414 NAMESPACESTART
|
2857
|
1415 /* valid namespaces with normal indent */
|
|
1416 namespace
|
|
1417 {
|
|
1418 {
|
|
1419 111111111111;
|
|
1420 }
|
|
1421 }
|
|
1422 namespace /* test */
|
|
1423 {
|
|
1424 11111111111111111;
|
|
1425 }
|
|
1426 namespace // test
|
|
1427 {
|
|
1428 111111111111111111;
|
|
1429 }
|
|
1430 namespace
|
|
1431 {
|
|
1432 111111111111111111;
|
|
1433 }
|
|
1434 namespace test
|
|
1435 {
|
|
1436 111111111111111111;
|
|
1437 }
|
|
1438 namespace{
|
|
1439 111111111111111111;
|
|
1440 }
|
|
1441 namespace test{
|
|
1442 111111111111111111;
|
|
1443 }
|
|
1444 namespace {
|
|
1445 111111111111111111;
|
|
1446 }
|
|
1447 namespace test {
|
|
1448 111111111111111111;
|
|
1449 namespace test2 {
|
|
1450 22222222222222222;
|
|
1451 }
|
|
1452 }
|
|
1453
|
|
1454 /* invalid namespaces use block indent */
|
|
1455 namespace test test2 {
|
|
1456 111111111111111111111;
|
|
1457 }
|
|
1458 namespace11111111111 {
|
|
1459 111111111111;
|
|
1460 }
|
|
1461 namespace() {
|
|
1462 1111111111111;
|
|
1463 }
|
|
1464 namespace()
|
|
1465 {
|
|
1466 111111111111111111;
|
|
1467 }
|
|
1468 namespace test test2
|
|
1469 {
|
|
1470 1111111111111111111;
|
|
1471 }
|
|
1472 namespace111111111
|
|
1473 {
|
|
1474 111111111111111111;
|
|
1475 }
|
|
1476 NAMESPACEEND
|
|
1477
|
|
1478
|
2879
|
1479
|
|
1480 JSSTART
|
|
1481 var bar = {
|
|
1482 foo: {
|
|
1483 that: this,
|
|
1484 some: ok,
|
|
1485 },
|
|
1486 "bar":{
|
|
1487 a : 2,
|
|
1488 b: "123abc",
|
|
1489 x: 4,
|
|
1490 "y": 5
|
|
1491 }
|
|
1492 }
|
|
1493 JSEND
|
|
1494
|
2968
|
1495
|
|
1496 JSSTART
|
|
1497 var foo = [
|
|
1498 1, // indent 8 more
|
|
1499 2,
|
|
1500 3
|
|
1501 ]; // indent 8 less
|
|
1502 JSEND
|
|
1503
|
|
1504
|
|
1505 JSSTART
|
|
1506 function bar() {
|
|
1507 var foo = [
|
|
1508 1,
|
|
1509 2,
|
|
1510 3
|
|
1511 ]; // indent 16 less
|
|
1512 }
|
|
1513 JSEND
|
|
1514
|
|
1515
|
|
1516 JSSTART
|
|
1517 (function($){
|
|
1518
|
|
1519 var class_name='myclass';
|
|
1520
|
|
1521 function private_method() {
|
|
1522 }
|
|
1523
|
|
1524 var public_method={
|
|
1525 method: function(options,args){
|
|
1526 private_method();
|
|
1527 }
|
|
1528 }
|
|
1529
|
|
1530 function init(options) {
|
|
1531
|
|
1532 $(this).data(class_name+'_public',$.extend({},{
|
|
1533 foo: 'bar',
|
|
1534 bar: 2, // indent 8 more
|
|
1535 foobar: [ // indent 8 more
|
|
1536 1, // indent 8 more
|
|
1537 2, // indent 16 more
|
|
1538 3 // indent 16 more
|
|
1539 ],
|
|
1540 callback: function(){ // indent 8 more
|
|
1541 return true; // indent 8 more
|
|
1542 } // indent 8 more
|
|
1543 }, options||{}));
|
|
1544 }
|
|
1545
|
|
1546 $.fn[class_name]=function() {
|
|
1547
|
|
1548 var _arguments=arguments;
|
|
1549 return this.each(function(){
|
|
1550
|
|
1551 var options=$(this).data(class_name+'_public');
|
|
1552 if (!options) {
|
|
1553 init.apply(this,_arguments);
|
|
1554
|
|
1555 } else {
|
|
1556 var method=public_method[_arguments[0]];
|
|
1557
|
|
1558 if (typeof(method)!='function') {
|
|
1559 console.log(class_name+' has no method "'+_arguments[0]+'"');
|
|
1560 return false;
|
|
1561 }
|
|
1562 _arguments[0]=options;
|
|
1563 method.apply(this,_arguments);
|
|
1564 }
|
|
1565 });
|
|
1566 }
|
|
1567
|
|
1568 })(jQuery);
|
|
1569 JSEND
|
|
1570
|
|
1571
|
|
1572 JSSTART
|
|
1573 function init(options) {
|
|
1574 $(this).data(class_name+'_public',$.extend({},{
|
|
1575 foo: 'bar',
|
|
1576 bar: 2,
|
|
1577 foobar: [
|
|
1578 1, // indent 8 more
|
|
1579 2, // indent 8 more
|
|
1580 3 // indent 8 more
|
|
1581 ],
|
|
1582 callback: function(){
|
|
1583 return true;
|
|
1584 }
|
|
1585 }, options||{}));
|
|
1586 }
|
|
1587 JSEND
|
|
1588
|
|
1589
|
|
1590 JSSTART
|
|
1591 (function($){
|
|
1592 function init(options) {
|
|
1593 $(this).data(class_name+'_public',$.extend({},{
|
|
1594 foo: 'bar',
|
|
1595 bar: 2, // indent 8 more
|
|
1596 foobar: [ // indent 8 more
|
|
1597 1, // indent 8 more
|
|
1598 2, // indent 16 more
|
|
1599 3 // indent 16 more
|
|
1600 ],
|
|
1601 callback: function(){ // indent 8 more
|
|
1602 return true; // indent 8 more
|
|
1603 } // indent 8 more
|
|
1604 }, options||{}));
|
|
1605 }
|
|
1606 })(jQuery);
|
|
1607 JSEND
|
|
1608
|