Mercurial > vim
annotate src/testdir/test3.ok @ 7164:d3c57e7f489a v7.4.893
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 13 16:13:39 2015 +0200
patch 7.4.893
Problem: C indenting is wrong below a "case (foo):" because it is
recognized as a C++ base class construct. Issue #38.
Solution: Check for the case keyword.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 13 Oct 2015 16:15:05 +0200 |
parents | accd3a0e9bf4 |
children | c6a7305972fe |
rev | line source |
---|---|
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 | |
4187 | 309 public static enum |
310 { | |
311 yes = 0, | |
312 no, | |
313 maybe | |
314 } soppie; | |
315 | |
316 static private enum | |
317 { | |
318 yes = 0, | |
319 no, | |
320 maybe | |
321 } soppie; | |
322 | |
7 | 323 { |
324 int a, | |
325 b; | |
326 } | |
327 | |
328 { | |
329 struct Type | |
330 { | |
331 int i; | |
332 char *str; | |
333 } var[] = | |
334 { | |
335 0, "zero", | |
336 1, "one", | |
337 2, "two", | |
338 3, "three" | |
339 }; | |
340 | |
341 float matrix[3][3] = | |
342 { | |
343 { | |
344 0, | |
345 1, | |
346 2 | |
347 }, | |
348 { | |
349 3, | |
350 4, | |
351 5 | |
352 }, | |
353 { | |
354 6, | |
355 7, | |
356 8 | |
357 } | |
358 }; | |
359 } | |
360 | |
361 { | |
362 /* blah ( blah */ | |
363 /* where does this go? */ | |
364 | |
365 /* blah ( blah */ | |
366 cmd; | |
367 | |
368 func(arg1, | |
369 /* comment */ | |
370 arg2); | |
371 a; | |
372 { | |
373 b; | |
374 { | |
375 c; /* Hey, NOW it indents?! */ | |
376 } | |
377 } | |
378 | |
379 { | |
380 func(arg1, | |
381 arg2, | |
382 arg3); | |
383 /* Hey, what am I doing here? Is this coz of the ","? */ | |
384 } | |
385 } | |
386 | |
387 main () | |
388 { | |
389 if (cond) | |
390 { | |
391 a = b; | |
392 } | |
393 if (cond) { | |
394 a = c; | |
395 } | |
396 if (cond) | |
397 a = d; | |
398 return; | |
399 } | |
400 | |
401 { | |
402 case 2: if (asdf && | |
403 asdfasdf) | |
404 aasdf; | |
405 a = 9; | |
406 case 3: if (asdf) | |
407 aasdf; | |
408 a = 9; | |
409 case 4: x = 1; | |
410 y = 2; | |
411 | |
412 label: if (asdf) | |
413 here; | |
414 | |
415 label: if (asdf && | |
416 asdfasdf) | |
417 { | |
418 } | |
419 | |
420 label: if (asdf && | |
421 asdfasdf) { | |
422 there; | |
423 } | |
424 | |
425 label: if (asdf && | |
426 asdfasdf) | |
427 there; | |
428 } | |
429 | |
430 { | |
431 /* | |
432 hello with ":set comments= cino=c5" | |
433 */ | |
434 | |
435 /* | |
436 hello with ":set comments= cino=" | |
437 */ | |
438 } | |
439 | |
440 | |
441 { | |
442 if (a < b) { | |
443 a = a + 1; | |
444 } else | |
445 a = a + 2; | |
446 | |
447 if (a) | |
448 do { | |
449 testing; | |
450 } while (asdfasdf); | |
451 a = b + 1; | |
452 asdfasdf | |
453 } | |
454 | |
6114 | 455 { |
456 for ( int i = 0; | |
457 i < 10; i++ ) | |
458 { | |
459 } | |
460 i = 0; | |
461 } | |
462 | |
7 | 463 class bob |
464 { | |
465 int foo() {return 1;} | |
466 int bar; | |
467 } | |
468 | |
469 main() | |
470 { | |
471 while(1) | |
472 if (foo) | |
473 { | |
474 bar; | |
475 } | |
476 else { | |
477 asdf; | |
478 } | |
479 misplacedline; | |
480 } | |
481 | |
482 { | |
483 if (clipboard.state == SELECT_DONE | |
484 && ((row == clipboard.start.lnum | |
485 && col >= clipboard.start.col) | |
486 || row > clipboard.start.lnum)) | |
487 } | |
488 | |
489 { | |
490 if (1) {i += 4;} | |
491 where_am_i; | |
492 return 0; | |
493 } | |
494 | |
495 { | |
496 { | |
497 } // sdf(asdf | |
498 if (asdf) | |
499 asd; | |
500 } | |
501 | |
502 { | |
503 label1: | |
504 label2: | |
505 } | |
506 | |
507 { | |
508 int fooRet = foo(pBar1, false /*fKB*/, | |
509 true /*fPTB*/, 3 /*nT*/, false /*fDF*/); | |
510 f() { | |
511 for ( i = 0; | |
512 i < m; | |
513 /* c */ i++ ) { | |
514 a = b; | |
515 } | |
516 } | |
517 } | |
518 | |
519 { | |
520 f1(/*comment*/); | |
521 f2(); | |
522 } | |
523 | |
524 { | |
525 do { | |
526 if (foo) { | |
527 } else | |
528 ; | |
529 } while (foo); | |
530 foo(); // was wrong | |
531 } | |
532 | |
533 int x; // no extra indent because of the ; | |
534 void func() | |
535 { | |
536 } | |
537 | |
538 char *tab[] = {"aaa", | |
539 "};", /* }; */ NULL} | |
540 int indented; | |
541 {} | |
542 | |
543 char *a[] = {"aaa", "bbb", | |
544 "ccc", NULL}; | |
545 // here | |
546 | |
547 char *tab[] = {"aaa", | |
548 "xx", /* xx */}; /* asdf */ | |
549 int not_indented; | |
550 | |
551 { | |
552 do { | |
553 switch (bla) | |
554 { | |
555 case 1: if (foo) | |
556 bar; | |
557 } | |
558 } while (boo); | |
559 wrong; | |
560 } | |
561 | |
562 int foo, | |
563 bar; | |
564 int foo; | |
565 | |
566 #if defined(foo) \ | |
567 && defined(bar) | |
568 char * xx = "asdf\ | |
569 foo\ | |
570 bor"; | |
571 int x; | |
572 | |
573 char *foo = "asdf\ | |
574 asdf\ | |
575 asdf", | |
576 *bar; | |
577 | |
578 void f() | |
579 { | |
580 #if defined(foo) \ | |
581 && defined(bar) | |
582 char *foo = "asdf\ | |
583 asdf\ | |
584 asdf", | |
585 *bar; | |
586 { | |
587 int i; | |
588 char *foo = "asdf\ | |
589 asdf\ | |
590 asdf", | |
591 *bar; | |
592 } | |
593 #endif | |
594 } | |
595 #endif | |
596 | |
597 int y; // comment | |
598 // comment | |
599 | |
600 // comment | |
601 | |
602 { | |
603 Constructor(int a, | |
604 int b ) : BaseClass(a) | |
605 { | |
606 } | |
607 } | |
608 | |
609 void foo() | |
610 { | |
611 char one, | |
612 two; | |
613 struct bla piet, | |
614 jan; | |
615 enum foo kees, | |
616 jannie; | |
617 static unsigned sdf, | |
618 krap; | |
619 unsigned int piet, | |
620 jan; | |
621 int | |
622 kees, | |
623 jan; | |
624 } | |
625 | |
626 { | |
627 t(int f, | |
628 int d); // ) | |
629 d(); | |
630 } | |
631 | |
632 Constructor::Constructor(int a, | |
633 int b | |
634 ) : | |
635 BaseClass(a, | |
636 b, | |
637 c), | |
638 mMember(b), | |
639 { | |
640 } | |
641 | |
642 Constructor::Constructor(int a, | |
643 int b ) : | |
644 BaseClass(a) | |
645 { | |
646 } | |
647 | |
648 Constructor::Constructor(int a, | |
649 int b ) /*x*/ : /*x*/ BaseClass(a), | |
828 | 650 member(b) |
7 | 651 { |
652 } | |
653 | |
654 class CAbc : | |
655 public BaseClass1, | |
656 protected BaseClass2 | |
657 { | |
658 int Test() { return FALSE; } | |
659 int Test1() { return TRUE; } | |
660 | |
661 CAbc(int a, int b ) : | |
662 BaseClass(a) | |
663 { | |
664 switch(xxx) | |
665 { | |
666 case abc: | |
667 asdf(); | |
668 break; | |
669 | |
670 case 999: | |
671 baer(); | |
672 break; | |
673 } | |
674 } | |
675 | |
676 public: // <-- this was incoreectly indented before!! | |
677 void testfall(); | |
678 protected: | |
679 void testfall(); | |
680 }; | |
681 | |
682 class CAbc : public BaseClass1, | |
828 | 683 protected BaseClass2 |
7 | 684 { |
685 }; | |
686 | |
687 static struct | |
688 { | |
689 int a; | |
690 int b; | |
691 } variable[COUNT] = | |
692 { | |
693 { | |
694 123, | |
695 456 | |
696 }, | |
697 { | |
698 123, | |
699 456 | |
700 } | |
701 }; | |
702 | |
703 static struct | |
704 { | |
705 int a; | |
706 int b; | |
707 } variable[COUNT] = | |
708 { | |
709 { 123, 456 }, | |
710 { 123, 456 } | |
711 }; | |
712 | |
713 void asdf() /* ind_maxparen may cause trouble here */ | |
714 { | |
715 if ((0 | |
716 && 1 | |
717 && 1 | |
718 && 1 | |
719 && 1 | |
720 && 1 | |
721 && 1 | |
722 && 1 | |
723 && 1 | |
724 && 1 | |
725 && 1 | |
726 && 1 | |
727 && 1 | |
728 && 1 | |
729 && 1 | |
730 && 1 | |
731 && 1 | |
732 && 1 | |
733 && 1 | |
734 && 1 | |
735 && 1 | |
736 && 1 | |
737 && 1 | |
738 && 1 | |
739 && 1 | |
740 && 1)) break; | |
741 } | |
742 | |
827 | 743 foo() |
744 { | |
745 a = cond ? foo() : asdf | |
746 + asdf; | |
747 | |
748 a = cond ? | |
749 foo() : asdf | |
750 + asdf; | |
751 } | |
752 | |
753 int main(void) | |
754 { | |
755 if (a) | |
756 if (b) | |
757 2; | |
758 else 3; | |
759 next_line_of_code(); | |
760 } | |
761 | |
828 | 762 barry() |
763 { | |
764 Foo::Foo (int one, | |
765 int two) | |
766 : something(4) | |
767 {} | |
768 } | |
769 | |
770 barry() | |
771 { | |
772 Foo::Foo (int one, int two) | |
773 : something(4) | |
774 {} | |
775 } | |
776 | |
777 Constructor::Constructor(int a, | |
778 int b | |
779 ) : | |
780 BaseClass(a, | |
781 b, | |
782 c), | |
783 mMember(b) | |
784 { | |
785 } | |
829 | 786 int main () |
787 { | |
788 if (lala) | |
789 do | |
790 ++(*lolo); | |
791 while (lili | |
792 && lele); | |
793 lulu; | |
794 } | |
828 | 795 |
829 | 796 int main () |
797 { | |
798 switch (c) | |
799 { | |
800 case 'c': if (cond) | |
801 { | |
802 } | |
803 } | |
804 } | |
805 | |
806 main() | |
807 { | |
808 (void) MyFancyFuasdfadsfnction( | |
809 argument); | |
810 } | |
811 | |
812 main() | |
813 { | |
814 char foo[] = "/*"; | |
815 /* as | |
816 df */ | |
817 hello | |
818 } | |
2857 | 819 |
820 /* valid namespaces with normal indent */ | |
821 namespace | |
822 { | |
823 { | |
824 111111111111; | |
825 } | |
826 } | |
827 namespace /* test */ | |
828 { | |
829 11111111111111111; | |
830 } | |
831 namespace // test | |
832 { | |
833 111111111111111111; | |
834 } | |
835 namespace | |
836 { | |
837 111111111111111111; | |
838 } | |
839 namespace test | |
840 { | |
841 111111111111111111; | |
842 } | |
843 namespace{ | |
844 111111111111111111; | |
845 } | |
846 namespace test{ | |
847 111111111111111111; | |
848 } | |
849 namespace { | |
850 111111111111111111; | |
851 } | |
852 namespace test { | |
853 111111111111111111; | |
854 namespace test2 { | |
855 22222222222222222; | |
856 } | |
857 } | |
858 | |
859 /* invalid namespaces use block indent */ | |
860 namespace test test2 { | |
861 111111111111111111111; | |
862 } | |
863 namespace11111111111 { | |
864 111111111111; | |
865 } | |
866 namespace() { | |
867 1111111111111; | |
868 } | |
869 namespace() | |
870 { | |
871 111111111111111111; | |
872 } | |
873 namespace test test2 | |
874 { | |
875 1111111111111111111; | |
876 } | |
877 namespace111111111 | |
878 { | |
879 111111111111111111; | |
880 } | |
881 | |
6971 | 882 void getstring() { |
883 /* Raw strings */ | |
884 const char* s = R"( | |
885 test { | |
886 # comment | |
887 field: 123 | |
888 } | |
889 )"; | |
890 } | |
891 | |
892 void getstring() { | |
893 const char* s = R"foo( | |
894 test { | |
895 # comment | |
896 field: 123 | |
897 } | |
898 )foo"; | |
899 } | |
900 | |
7160
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
901 { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
902 int a[4] = { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
903 [0] = 0, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
904 [1] = 1, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
905 [2] = 2, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
906 [3] = 3, |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
907 }; |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
908 } |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
909 |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
910 { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
911 a = b[2] |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
912 + 3; |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
913 } |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
914 |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
915 { |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
916 if (1) |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
917 /* aaaaa |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
918 * bbbbb |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
919 */ |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
920 a = 1; |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
921 } |
accd3a0e9bf4
commit https://github.com/vim/vim/commit/089af18d1fd0961ff504ee72db0156bbfe509cdf
Christian Brabandt <cb@256bit.org>
parents:
6971
diff
changeset
|
922 |
7164
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
923 void func() |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
924 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
925 switch (foo) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
926 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
927 case (bar): |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
928 if (baz()) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
929 quux(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
930 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
931 case (shmoo): |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
932 if (!bar) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
933 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
934 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
935 case (foo1): |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
936 switch (bar) |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
937 { |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
938 case baz: |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
939 baz_f(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
940 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
941 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
942 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
943 default: |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
944 baz(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
945 baz(); |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
946 break; |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
947 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
948 } |
d3c57e7f489a
commit https://github.com/vim/vim/commit/d1b15dec4d00d7ed5e92ff4e0fb7fc2e0818e479
Christian Brabandt <cb@256bit.org>
parents:
7160
diff
changeset
|
949 |
7 | 950 /* end of AUTO */ |
951 | |
952 | |
953 { | |
954 | |
955 /* this is | |
956 * a real serious | |
957 * about life, the | |
958 * universe, and the | |
959 * rest important big | |
960 * comment | |
961 */ | |
962 /* insert " about life, the universe, and the rest" after "serious" */ | |
963 } | |
964 | |
965 | |
966 { | |
967 /* | |
968 * Testing for comments, without 'cin' set | |
969 */ | |
970 about life | |
971 | |
972 /* | |
973 * what happens here? | |
974 */ | |
975 there | |
976 | |
977 /* | |
978 the end of the comment, try inserting a line below */ | |
979 line | |
980 | |
981 /* how about | |
982 hello | |
983 this one */ | |
984 } | |
985 | |
986 | |
987 { | |
988 var = this + that + vec[0] * vec[0] | |
989 + vec[1] * vec[1] | |
990 + vec2[2] * vec[2]; | |
991 } | |
992 | |
993 | |
994 { | |
995 asdf asdflkajds f; | |
996 if (tes & ting) { | |
997 asdf asdf asdf ; | |
998 asdfa sdf asdf; | |
999 } | |
1000 testing1; | |
1001 if (tes & ting) | |
1002 { | |
1003 asdf asdf asdf ; | |
1004 asdfa sdf asdf; | |
1005 } | |
1006 testing2; | |
1007 } | |
1008 | |
1009 | |
1010 main ( int first_par, /* | |
1011 * Comment for | |
1012 * first par | |
1013 */ | |
1014 int second_par /* | |
1015 * Comment for | |
1016 * second par | |
1017 */ | |
1018 ) | |
1019 { | |
1020 func( first_par, /* | |
1021 * Comment for | |
1022 * first par | |
1023 */ | |
1024 second_par /* | |
1025 * Comment for | |
1026 * second par | |
1027 */ | |
1028 ); | |
1029 | |
1030 } | |
1031 | |
1032 | |
3578 | 1033 main(void) |
1034 { | |
1035 /* Make sure that cino=X0s is not parsed like cino=Xs. */ | |
1036 if (cond) | |
1037 foo(); | |
1038 else | |
1039 { | |
1040 bar(); | |
1041 } | |
1042 } | |
1043 | |
1044 | |
7 | 1045 { |
1046 do | |
1047 { | |
1048 if () | |
1049 { | |
1050 if () | |
1051 asdf; | |
1052 else | |
1053 asdf; | |
1054 } | |
1055 } while (); | |
1056 cmd; /* this should go under the } */ | |
1057 } | |
1058 | |
1059 | |
1060 void f() | |
1061 { | |
1062 if ( k() ) { | |
1063 l(); | |
1064 | |
1065 } else { /* Start (two words) end */ | |
1066 m(); | |
1067 } | |
1068 | |
1069 n(); | |
1070 } | |
1071 | |
1072 | |
1073 void f() | |
1074 { | |
1075 if ( k() ) | |
1076 { | |
1077 l(); | |
1078 } else { /* Start (two words) end */ | |
1079 m(); | |
1080 } | |
1081 n(); /* should be under the if () */ | |
1082 } | |
1083 | |
1084 | |
1085 void bar(void) | |
1086 { | |
1087 static array[2][2] = | |
1088 { | |
1089 { 1, 2 }, | |
1090 { 3, 4 }, | |
1091 } | |
1092 | |
1093 while (a) | |
1094 { | |
1095 foo(&a); | |
1096 } | |
1097 | |
1098 { | |
1099 int a; | |
1100 { | |
1101 a = a + 1; | |
1102 } | |
1103 } | |
1104 b = a; | |
1105 } | |
1106 | |
1107 void func(void) | |
1108 { | |
1109 a = 1; | |
1110 { | |
1111 b = 2; | |
1112 } | |
1113 c = 3; | |
1114 d = 4; | |
1115 } | |
1116 /* foo */ | |
1117 | |
1118 | |
1119 a() | |
1120 { | |
1121 do { | |
1122 a = a + | |
1123 a; | |
1124 } while ( a ); /* add text under this line */ | |
1125 here | |
1126 if ( a ) | |
1127 a; | |
1128 } | |
1129 | |
1130 | |
1131 a() | |
1132 { | |
1133 label1: | |
1134 /* hmm */ | |
1135 // comment | |
1136 label2: b(); | |
1137 label3 /* post */: | |
1138 /* pre */ label4: | |
1139 f(/*com*/); | |
1140 if (/*com*/) | |
1141 cmd(); | |
1142 } | |
1143 | |
1144 | |
1145 /* | |
1146 * A simple comment | |
1147 */ | |
1148 | |
1149 /* | |
1150 ** A different comment | |
1151 */ | |
1152 | |
1153 | |
1154 void f() | |
1155 { | |
1156 | |
1157 /********* | |
1158 A comment. | |
1159 *********/ | |
1160 } | |
1161 | |
1162 | |
1163 void f() | |
1164 { | |
1165 | |
1166 /********* | |
1167 A comment. | |
1168 *********/ | |
1169 } | |
1170 | |
1171 | |
1172 void f() | |
1173 { | |
1174 c = c1 && | |
1175 ( | |
1176 c2 || | |
1177 c3 | |
1178 ) && c4; | |
1179 } | |
1180 | |
1181 | |
1182 void f() | |
1183 { | |
1184 c = c1 && | |
1185 ( | |
1186 c2 || | |
1187 c3 | |
1188 ) && c4; | |
1189 } | |
1190 | |
1191 | |
1192 void f() | |
1193 { | |
1194 c = c1 && | |
1195 ( | |
1196 c2 || | |
1197 c3 | |
1198 ) && c4; | |
1199 } | |
1200 | |
1201 | |
1202 void f() | |
1203 { | |
1204 if ( c1 | |
1205 && ( c2 | |
1206 || c3)) | |
1207 foo; | |
1208 } | |
1209 | |
1210 | |
1211 void f() | |
1212 { | |
1213 if ( c1 | |
1214 && ( c2 | |
1215 || c3)) | |
1216 foo; | |
1217 } | |
1218 | |
1219 | |
1220 void f() | |
1221 { | |
1222 c = c1 && ( | |
1223 c2 || | |
1224 c3 | |
1225 ) && c4; | |
1226 if ( | |
1227 c1 && c2 | |
1228 ) | |
1229 foo; | |
1230 } | |
1231 | |
1232 | |
1233 void f() | |
1234 { | |
1235 c = c1 && ( | |
1236 c2 || | |
1237 c3 | |
1238 ) && c4; | |
1239 if ( | |
1240 c1 && c2 | |
1241 ) | |
1242 foo; | |
1243 } | |
1244 | |
1245 | |
1246 void f() | |
1247 { | |
1248 switch (x) | |
1249 { | |
1250 case 1: | |
1251 a = b; | |
1252 break; | |
1253 default: | |
1254 a = 0; | |
1255 break; | |
1256 } | |
1257 } | |
1258 | |
1259 | |
1260 void f() | |
1261 { | |
1262 invokeme( | |
1263 argu, | |
1264 ment); | |
1265 invokeme( | |
1266 argu, | |
1267 ment | |
1268 ); | |
1269 invokeme(argu, | |
1270 ment | |
1271 ); | |
1272 } | |
1273 | |
1274 | |
1275 void f() | |
1276 { | |
1277 statement; | |
1278 // comment 1 | |
1279 // comment 2 | |
1280 } | |
1281 | |
1282 | |
1283 void f() | |
1284 { | |
1285 statement; | |
1286 // comment 1 | |
1287 // comment 2 | |
1288 } | |
1289 | |
1290 | |
1291 class CAbc | |
1292 { | |
1293 int Test() { return FALSE; } | |
1294 | |
1295 public: // comment | |
1296 void testfall(); | |
1297 protected: | |
1298 void testfall(); | |
1299 }; | |
1300 | |
1301 | |
3123 | 1302 class Foo : public Bar |
1303 { | |
1304 public: | |
1305 virtual void method1(void) = 0; | |
1306 virtual void method2(int arg1, | |
1307 int arg2, | |
1308 int arg3) = 0; | |
1309 }; | |
1310 | |
1311 | |
828 | 1312 void |
1313 foo() | |
1314 { | |
1315 if (a) | |
1316 { | |
1317 } else | |
1318 asdf; | |
1319 } | |
1320 | |
1321 | |
7 | 1322 { |
1323 averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( | |
1324 asdasdf, | |
1325 func(asdf, | |
1326 asdfadsf), | |
1327 asdfasdf | |
1328 ); | |
1329 | |
1330 /* those are ugly, but consequent */ | |
1331 | |
1332 func()->asd(asdasdf, | |
1333 averylongfunctionname( | |
1334 abc, | |
1335 dec)->averylongfunctionname( | |
1336 asdfadsf, | |
1337 asdfasdf, | |
1338 asdfasdf, | |
1339 ), | |
1340 func(asdfadf, | |
1341 asdfasdf | |
1342 ), | |
1343 asdasdf | |
1344 ); | |
1345 | |
1346 averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( | |
1347 abc, | |
1348 dec)->asdfasdfasdf( | |
1349 asdfadsf, | |
1350 asdfasdf, | |
1351 asdfasdf, | |
1352 ), | |
1353 func(asdfadf, | |
1354 asdfasdf), | |
1355 asdasdf | |
1356 ); | |
1357 } | |
1358 | |
829 | 1359 |
1360 int main () | |
1361 { | |
1362 if (cond1 && | |
1363 cond2 | |
1364 ) | |
1365 foo; | |
1366 } | |
1367 | |
2776 | 1368 |
1369 void func(int a | |
1370 #if defined(FOO) | |
1371 , int b | |
1372 , int c | |
1373 #endif | |
1374 ) | |
1375 { | |
1376 } | |
1377 | |
1378 | |
1379 void | |
1380 func(int a | |
1381 #if defined(FOO) | |
1382 , int b | |
1383 , int c | |
1384 #endif | |
1385 ) | |
1386 { | |
1387 } | |
1388 | |
2805 | 1389 |
1390 void func(void) | |
1391 { | |
1392 if(x==y) | |
1393 if(y==z) | |
1394 foo=1; | |
1395 else { bar=1; | |
1396 baz=2; | |
1397 } | |
1398 printf("Foo!\n"); | |
1399 } | |
1400 | |
2843 | 1401 void func1(void) |
1402 { | |
1403 char* tab[] = {"foo", "bar", | |
1404 "baz", "quux", | |
1405 "this line used", "to be indented incorrectly"}; | |
1406 foo(); | |
1407 } | |
1408 | |
1409 void func2(void) | |
1410 { | |
1411 int tab[] = | |
1412 {1, 2, | |
1413 3, 4, | |
1414 5, 6}; | |
1415 | |
1416 printf("This line used to be indented incorrectly.\n"); | |
1417 } | |
1418 | |
3186 | 1419 int foo[] |
1420 #ifdef BAR | |
1421 | |
1422 = { 1, 2, 3, | |
1423 4, 5, 6 } | |
1424 | |
1425 #endif | |
1426 ; | |
1427 int baz; | |
1428 | |
2843 | 1429 void func3(void) |
1430 { | |
1431 int tab[] = { | |
1432 1, 2, | |
1433 3, 4, | |
1434 5, 6}; | |
1435 | |
3220 | 1436 printf("Don't you dare indent this line incorrectly!\n"); |
1437 } | |
1438 | |
1439 void | |
1440 func4(a, b, | |
1441 c) | |
1442 int a; | |
1443 int b; | |
1444 int c; | |
1445 { | |
1446 } | |
1447 | |
1448 void | |
1449 func5( | |
1450 int a, | |
1451 int b) | |
1452 { | |
1453 } | |
1454 | |
1455 void | |
1456 func6( | |
1457 int a) | |
1458 { | |
2843 | 1459 } |
1460 | |
2807 | 1461 |
1462 void func(void) | |
1463 { | |
2953 | 1464 int tab[] = |
1465 { | |
1466 1, 2, 3, | |
1467 4, 5, 6}; | |
1468 | |
1469 printf("Indent this line correctly!\n"); | |
1470 | |
1471 switch (foo) | |
1472 { | |
1473 case bar: | |
1474 printf("bar"); | |
1475 break; | |
1476 case baz: { | |
1477 printf("baz"); | |
1478 break; | |
1479 } | |
1480 case quux: | |
1481 printf("But don't break the indentation of this instruction\n"); | |
1482 break; | |
1483 } | |
1484 } | |
1485 | |
1486 | |
1487 void func(void) | |
1488 { | |
2807 | 1489 cout << "a" |
1490 << "b" | |
1491 << ") :" | |
1492 << "c"; | |
1493 } | |
1494 | |
2809 | 1495 |
1496 void func(void) | |
1497 { | |
1498 /* | |
1499 * This is a comment. | |
1500 */ | |
1501 foo(); | |
1502 } | |
1503 | |
2855 | 1504 |
1505 void func(void) | |
1506 { | |
1507 for (int i = 0; i < 10; ++i) | |
1508 if (i & 1) { | |
1509 foo(1); | |
1510 } else | |
1511 foo(0); | |
1512 baz(); | |
1513 } | |
1514 | |
2857 | 1515 |
3454 | 1516 void func(void) |
1517 { | |
1518 if (condition1 | |
1519 && condition2) | |
1520 action(); | |
1521 function(argument1 | |
1522 && argument2); | |
1523 | |
1524 if (c1 && (c2 || | |
1525 c3)) | |
1526 foo; | |
1527 if (c1 && | |
1528 (c2 || c3)) | |
1529 { | |
1530 } | |
1531 | |
1532 if ( c1 | |
1533 && ( c2 | |
1534 || c3)) | |
1535 foo; | |
1536 func( c1 | |
1537 && ( c2 | |
1538 || c3)) | |
1539 foo; | |
1540 } | |
1541 | |
1542 | |
1543 void func(void) | |
1544 { | |
1545 if (condition1 | |
1546 && condition2) | |
1547 action(); | |
1548 function(argument1 | |
1549 && argument2); | |
1550 | |
1551 if (c1 && (c2 || | |
1552 c3)) | |
1553 foo; | |
1554 if (c1 && | |
1555 (c2 || c3)) | |
1556 { | |
1557 } | |
1558 | |
1559 if ( c1 | |
1560 && ( c2 | |
1561 || c3)) | |
1562 foo; | |
1563 func( c1 | |
1564 && ( c2 | |
1565 || c3)) | |
1566 foo; | |
1567 } | |
1568 | |
1569 | |
1570 void func(void) | |
1571 { | |
1572 if (condition1 | |
1573 && condition2) | |
1574 action(); | |
1575 function(argument1 | |
1576 && argument2); | |
1577 | |
1578 if (c1 && (c2 || | |
1579 c3)) | |
1580 foo; | |
1581 if (c1 && | |
1582 (c2 || c3)) | |
1583 { | |
1584 } | |
1585 if (c123456789 | |
1586 && (c22345 | |
1587 || c3)) | |
1588 printf("foo\n"); | |
1589 | |
1590 c = c1 && | |
1591 ( | |
1592 c2 || | |
1593 c3 | |
1594 ) && c4; | |
1595 } | |
1596 | |
1597 | |
1598 void func(void) | |
1599 { | |
1600 if (condition1 | |
1601 && condition2) | |
1602 action(); | |
1603 function(argument1 | |
1604 && argument2); | |
1605 | |
1606 if (c1 && (c2 || | |
1607 c3)) | |
1608 foo; | |
1609 if (c1 && | |
1610 (c2 || c3)) | |
1611 { | |
1612 } | |
1613 if (c123456789 | |
1614 && (c22345 | |
1615 || c3)) | |
1616 printf("foo\n"); | |
1617 | |
1618 if ( c1 | |
1619 && ( c2 | |
1620 || c3)) | |
1621 foo; | |
1622 | |
1623 a_long_line( | |
1624 argument, | |
1625 argument); | |
1626 a_short_line(argument, | |
1627 argument); | |
1628 } | |
1629 | |
1630 | |
1631 void func(void) | |
1632 { | |
1633 if (condition1 | |
1634 && condition2) | |
1635 action(); | |
1636 function(argument1 | |
1637 && argument2); | |
1638 | |
1639 if (c1 && (c2 || | |
1640 c3)) | |
1641 foo; | |
1642 if (c1 && | |
1643 (c2 || c3)) | |
1644 { | |
1645 } | |
1646 if (c123456789 | |
1647 && (c22345 | |
1648 || c3)) | |
1649 printf("foo\n"); | |
1650 } | |
1651 | |
1652 | |
1653 void func(void) | |
1654 { | |
1655 if (condition1 | |
1656 && condition2) | |
1657 action(); | |
1658 function(argument1 | |
1659 && argument2); | |
1660 | |
1661 if (c1 && (c2 || | |
1662 c3)) | |
1663 foo; | |
1664 if (c1 && | |
1665 (c2 || c3)) | |
1666 { | |
1667 } | |
1668 if (c123456789 | |
1669 && (c22345 | |
1670 || c3)) | |
1671 printf("foo\n"); | |
1672 | |
1673 if ( c1 | |
1674 && ( c2 | |
1675 || c3)) | |
1676 foo; | |
1677 func( c1 | |
1678 && ( c2 | |
1679 || c3)) | |
1680 foo; | |
1681 } | |
1682 | |
1683 | |
1684 void func(void) | |
1685 { | |
1686 if (condition1 | |
1687 && condition2) | |
1688 action(); | |
1689 function(argument1 | |
1690 && argument2); | |
1691 | |
1692 if (c1 && (c2 || | |
1693 c3)) | |
1694 foo; | |
1695 if (c1 && | |
1696 (c2 || c3)) | |
1697 { | |
1698 } | |
1699 } | |
1700 | |
1701 | |
2879 | 1702 NAMESPACESTART |
2857 | 1703 /* valid namespaces with normal indent */ |
1704 namespace | |
1705 { | |
1706 { | |
1707 111111111111; | |
1708 } | |
1709 } | |
1710 namespace /* test */ | |
1711 { | |
1712 11111111111111111; | |
1713 } | |
1714 namespace // test | |
1715 { | |
1716 111111111111111111; | |
1717 } | |
1718 namespace | |
1719 { | |
1720 111111111111111111; | |
1721 } | |
1722 namespace test | |
1723 { | |
1724 111111111111111111; | |
1725 } | |
1726 namespace{ | |
1727 111111111111111111; | |
1728 } | |
1729 namespace test{ | |
1730 111111111111111111; | |
1731 } | |
1732 namespace { | |
1733 111111111111111111; | |
1734 } | |
1735 namespace test { | |
1736 111111111111111111; | |
1737 namespace test2 { | |
1738 22222222222222222; | |
1739 } | |
1740 } | |
1741 | |
1742 /* invalid namespaces use block indent */ | |
1743 namespace test test2 { | |
1744 111111111111111111111; | |
1745 } | |
1746 namespace11111111111 { | |
1747 111111111111; | |
1748 } | |
1749 namespace() { | |
1750 1111111111111; | |
1751 } | |
1752 namespace() | |
1753 { | |
1754 111111111111111111; | |
1755 } | |
1756 namespace test test2 | |
1757 { | |
1758 1111111111111111111; | |
1759 } | |
1760 namespace111111111 | |
1761 { | |
1762 111111111111111111; | |
1763 } | |
1764 NAMESPACEEND | |
1765 | |
1766 | |
2879 | 1767 |
1768 JSSTART | |
1769 var bar = { | |
1770 foo: { | |
1771 that: this, | |
1772 some: ok, | |
1773 }, | |
1774 "bar":{ | |
1775 a : 2, | |
1776 b: "123abc", | |
1777 x: 4, | |
1778 "y": 5 | |
1779 } | |
1780 } | |
1781 JSEND | |
1782 | |
2968 | 1783 |
1784 JSSTART | |
1785 var foo = [ | |
6030 | 1786 1, |
2968 | 1787 2, |
1788 3 | |
6030 | 1789 ]; |
2968 | 1790 JSEND |
1791 | |
1792 | |
1793 JSSTART | |
1794 function bar() { | |
1795 var foo = [ | |
1796 1, | |
1797 2, | |
1798 3 | |
6030 | 1799 ]; |
2968 | 1800 } |
1801 JSEND | |
1802 | |
1803 | |
1804 JSSTART | |
1805 (function($){ | |
1806 | |
6020 | 1807 if (cond && |
1808 cond) { | |
1809 stmt; | |
1810 } | |
6030 | 1811 window.something.left = |
1812 (width - 50 + offset) + "px"; | |
2968 | 1813 var class_name='myclass'; |
1814 | |
1815 function private_method() { | |
1816 } | |
1817 | |
1818 var public_method={ | |
1819 method: function(options,args){ | |
1820 private_method(); | |
1821 } | |
1822 } | |
1823 | |
1824 function init(options) { | |
1825 | |
1826 $(this).data(class_name+'_public',$.extend({},{ | |
1827 foo: 'bar', | |
6030 | 1828 bar: 2, |
1829 foobar: [ | |
1830 1, | |
1831 2, | |
1832 3 | |
2968 | 1833 ], |
6030 | 1834 callback: function(){ |
1835 return true; | |
1836 } | |
2968 | 1837 }, options||{})); |
1838 } | |
1839 | |
1840 $.fn[class_name]=function() { | |
1841 | |
1842 var _arguments=arguments; | |
1843 return this.each(function(){ | |
1844 | |
1845 var options=$(this).data(class_name+'_public'); | |
1846 if (!options) { | |
1847 init.apply(this,_arguments); | |
1848 | |
1849 } else { | |
1850 var method=public_method[_arguments[0]]; | |
1851 | |
1852 if (typeof(method)!='function') { | |
1853 console.log(class_name+' has no method "'+_arguments[0]+'"'); | |
1854 return false; | |
1855 } | |
1856 _arguments[0]=options; | |
1857 method.apply(this,_arguments); | |
1858 } | |
1859 }); | |
1860 } | |
1861 | |
1862 })(jQuery); | |
1863 JSEND | |
1864 | |
1865 | |
1866 JSSTART | |
1867 function init(options) { | |
1868 $(this).data(class_name+'_public',$.extend({},{ | |
1869 foo: 'bar', | |
1870 bar: 2, | |
1871 foobar: [ | |
6030 | 1872 1, |
1873 2, | |
1874 3 | |
2968 | 1875 ], |
1876 callback: function(){ | |
1877 return true; | |
1878 } | |
1879 }, options||{})); | |
1880 } | |
1881 JSEND | |
1882 | |
1883 | |
1884 JSSTART | |
1885 (function($){ | |
1886 function init(options) { | |
1887 $(this).data(class_name+'_public',$.extend({},{ | |
1888 foo: 'bar', | |
6030 | 1889 bar: 2, |
1890 foobar: [ | |
1891 1, | |
1892 2, | |
1893 3 | |
2968 | 1894 ], |
6030 | 1895 callback: function(){ |
1896 return true; | |
1897 } | |
2968 | 1898 }, options||{})); |
1899 } | |
1900 })(jQuery); | |
1901 JSEND | |
1902 | |
6691 | 1903 |
1904 JSSTART | |
1905 // Results of JavaScript indent | |
1906 // 1 | |
1907 (function(){ | |
1908 var a = [ | |
1909 'a', | |
1910 'b', | |
1911 'c', | |
1912 'd', | |
1913 'e', | |
1914 'f', | |
1915 'g', | |
1916 'h', | |
1917 'i' | |
1918 ]; | |
1919 }()) | |
1920 | |
1921 // 2 | |
1922 (function(){ | |
1923 var a = [ | |
1924 0 + | |
1925 5 * | |
1926 9 * | |
1927 'a', | |
1928 'b', | |
1929 0 + | |
1930 5 * | |
1931 9 * | |
1932 'c', | |
1933 'd', | |
1934 'e', | |
1935 'f', | |
1936 'g', | |
1937 'h', | |
1938 'i' | |
1939 ]; | |
1940 }()) | |
1941 | |
1942 // 3 | |
1943 (function(){ | |
1944 var a = [ | |
1945 0 + | |
1946 // comment 1 | |
1947 5 * | |
1948 /* comment 2 */ | |
1949 9 * | |
1950 'a', | |
1951 'b', | |
1952 0 + | |
1953 5 * | |
1954 9 * | |
1955 'c', | |
1956 'd', | |
1957 'e', | |
1958 'f', | |
1959 'g', | |
1960 'h', | |
1961 'i' | |
1962 ]; | |
1963 }()) | |
1964 | |
1965 // 4 | |
1966 { | |
1967 var a = [ | |
1968 0, | |
1969 1 | |
1970 ]; | |
1971 var b; | |
1972 var c; | |
1973 } | |
1974 | |
1975 // 5 | |
1976 { | |
1977 var a = [ | |
1978 [ | |
1979 0 | |
1980 ], | |
1981 2, | |
1982 3 | |
1983 ]; | |
1984 } | |
1985 | |
1986 // 6 | |
1987 { | |
1988 var a = [ | |
1989 [ | |
1990 0, | |
1991 1 | |
1992 ], | |
1993 2, | |
1994 3 | |
1995 ]; | |
1996 } | |
1997 | |
1998 // 7 | |
1999 { | |
2000 var a = [ | |
2001 // [ | |
2002 0, | |
2003 // 1 | |
2004 // ], | |
2005 2, | |
2006 3 | |
2007 ]; | |
2008 } | |
2009 | |
2010 // 8 | |
2011 var x = [ | |
2012 (function(){ | |
2013 var a, | |
2014 b, | |
2015 c, | |
2016 d, | |
2017 e, | |
2018 f, | |
2019 g, | |
2020 h, | |
2021 i; | |
2022 }) | |
2023 ]; | |
2024 | |
2025 // 9 | |
2026 var a = [ | |
2027 0 + | |
2028 5 * | |
2029 9 * | |
2030 'a', | |
2031 'b', | |
2032 0 + | |
2033 5 * | |
2034 9 * | |
2035 'c', | |
2036 'd', | |
2037 'e', | |
2038 'f', | |
2039 'g', | |
2040 'h', | |
2041 'i' | |
2042 ]; | |
2043 | |
2044 // 10 | |
2045 var a, | |
2046 b, | |
2047 c, | |
2048 d, | |
2049 e, | |
2050 f, | |
2051 g, | |
2052 h, | |
2053 i; | |
2054 JSEND | |
2055 |