Bram Moolenaar | 9e54a0e | 2006-04-14 20:42:25 +0000 | [diff] [blame] | 1 | /* start of AUTO matically checked vim: set ts=4 : */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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 | |
| 302 | { |
| 303 | int a, |
| 304 | b; |
| 305 | } |
| 306 | |
| 307 | { |
| 308 | struct Type |
| 309 | { |
| 310 | int i; |
| 311 | char *str; |
| 312 | } var[] = |
| 313 | { |
| 314 | 0, "zero", |
| 315 | 1, "one", |
| 316 | 2, "two", |
| 317 | 3, "three" |
| 318 | }; |
| 319 | |
| 320 | float matrix[3][3] = |
| 321 | { |
| 322 | { |
| 323 | 0, |
| 324 | 1, |
| 325 | 2 |
| 326 | }, |
| 327 | { |
| 328 | 3, |
| 329 | 4, |
| 330 | 5 |
| 331 | }, |
| 332 | { |
| 333 | 6, |
| 334 | 7, |
| 335 | 8 |
| 336 | } |
| 337 | }; |
| 338 | } |
| 339 | |
| 340 | { |
| 341 | /* blah ( blah */ |
| 342 | /* where does this go? */ |
| 343 | |
| 344 | /* blah ( blah */ |
| 345 | cmd; |
| 346 | |
| 347 | func(arg1, |
| 348 | /* comment */ |
| 349 | arg2); |
| 350 | a; |
| 351 | { |
| 352 | b; |
| 353 | { |
| 354 | c; /* Hey, NOW it indents?! */ |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | { |
| 359 | func(arg1, |
| 360 | arg2, |
| 361 | arg3); |
| 362 | /* Hey, what am I doing here? Is this coz of the ","? */ |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | main () |
| 367 | { |
| 368 | if (cond) |
| 369 | { |
| 370 | a = b; |
| 371 | } |
| 372 | if (cond) { |
| 373 | a = c; |
| 374 | } |
| 375 | if (cond) |
| 376 | a = d; |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | { |
| 381 | case 2: if (asdf && |
| 382 | asdfasdf) |
| 383 | aasdf; |
| 384 | a = 9; |
| 385 | case 3: if (asdf) |
| 386 | aasdf; |
| 387 | a = 9; |
| 388 | case 4: x = 1; |
| 389 | y = 2; |
| 390 | |
| 391 | label: if (asdf) |
| 392 | here; |
| 393 | |
| 394 | label: if (asdf && |
| 395 | asdfasdf) |
| 396 | { |
| 397 | } |
| 398 | |
| 399 | label: if (asdf && |
| 400 | asdfasdf) { |
| 401 | there; |
| 402 | } |
| 403 | |
| 404 | label: if (asdf && |
| 405 | asdfasdf) |
| 406 | there; |
| 407 | } |
| 408 | |
| 409 | { |
| 410 | /* |
| 411 | hello with ":set comments= cino=c5" |
| 412 | */ |
| 413 | |
| 414 | /* |
| 415 | hello with ":set comments= cino=" |
| 416 | */ |
| 417 | } |
| 418 | |
| 419 | |
| 420 | { |
| 421 | if (a < b) { |
| 422 | a = a + 1; |
| 423 | } else |
| 424 | a = a + 2; |
| 425 | |
| 426 | if (a) |
| 427 | do { |
| 428 | testing; |
| 429 | } while (asdfasdf); |
| 430 | a = b + 1; |
| 431 | asdfasdf |
| 432 | } |
| 433 | |
| 434 | class bob |
| 435 | { |
| 436 | int foo() {return 1;} |
| 437 | int bar; |
| 438 | } |
| 439 | |
| 440 | main() |
| 441 | { |
| 442 | while(1) |
| 443 | if (foo) |
| 444 | { |
| 445 | bar; |
| 446 | } |
| 447 | else { |
| 448 | asdf; |
| 449 | } |
| 450 | misplacedline; |
| 451 | } |
| 452 | |
| 453 | { |
| 454 | if (clipboard.state == SELECT_DONE |
| 455 | && ((row == clipboard.start.lnum |
| 456 | && col >= clipboard.start.col) |
| 457 | || row > clipboard.start.lnum)) |
| 458 | } |
| 459 | |
| 460 | { |
| 461 | if (1) {i += 4;} |
| 462 | where_am_i; |
| 463 | return 0; |
| 464 | } |
| 465 | |
| 466 | { |
| 467 | { |
| 468 | } // sdf(asdf |
| 469 | if (asdf) |
| 470 | asd; |
| 471 | } |
| 472 | |
| 473 | { |
| 474 | label1: |
| 475 | label2: |
| 476 | } |
| 477 | |
| 478 | { |
| 479 | int fooRet = foo(pBar1, false /*fKB*/, |
| 480 | true /*fPTB*/, 3 /*nT*/, false /*fDF*/); |
| 481 | f() { |
| 482 | for ( i = 0; |
| 483 | i < m; |
| 484 | /* c */ i++ ) { |
| 485 | a = b; |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | { |
| 491 | f1(/*comment*/); |
| 492 | f2(); |
| 493 | } |
| 494 | |
| 495 | { |
| 496 | do { |
| 497 | if (foo) { |
| 498 | } else |
| 499 | ; |
| 500 | } while (foo); |
| 501 | foo(); // was wrong |
| 502 | } |
| 503 | |
| 504 | int x; // no extra indent because of the ; |
| 505 | void func() |
| 506 | { |
| 507 | } |
| 508 | |
| 509 | char *tab[] = {"aaa", |
| 510 | "};", /* }; */ NULL} |
| 511 | int indented; |
| 512 | {} |
| 513 | |
| 514 | char *a[] = {"aaa", "bbb", |
| 515 | "ccc", NULL}; |
| 516 | // here |
| 517 | |
| 518 | char *tab[] = {"aaa", |
| 519 | "xx", /* xx */}; /* asdf */ |
| 520 | int not_indented; |
| 521 | |
| 522 | { |
| 523 | do { |
| 524 | switch (bla) |
| 525 | { |
| 526 | case 1: if (foo) |
| 527 | bar; |
| 528 | } |
| 529 | } while (boo); |
| 530 | wrong; |
| 531 | } |
| 532 | |
| 533 | int foo, |
| 534 | bar; |
| 535 | int foo; |
| 536 | |
| 537 | #if defined(foo) \ |
| 538 | && defined(bar) |
| 539 | char * xx = "asdf\ |
| 540 | foo\ |
| 541 | bor"; |
| 542 | int x; |
| 543 | |
| 544 | char *foo = "asdf\ |
| 545 | asdf\ |
| 546 | asdf", |
| 547 | *bar; |
| 548 | |
| 549 | void f() |
| 550 | { |
| 551 | #if defined(foo) \ |
| 552 | && defined(bar) |
| 553 | char *foo = "asdf\ |
| 554 | asdf\ |
| 555 | asdf", |
| 556 | *bar; |
| 557 | { |
| 558 | int i; |
| 559 | char *foo = "asdf\ |
| 560 | asdf\ |
| 561 | asdf", |
| 562 | *bar; |
| 563 | } |
| 564 | #endif |
| 565 | } |
| 566 | #endif |
| 567 | |
| 568 | int y; // comment |
| 569 | // comment |
| 570 | |
| 571 | // comment |
| 572 | |
| 573 | { |
| 574 | Constructor(int a, |
| 575 | int b ) : BaseClass(a) |
| 576 | { |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | void foo() |
| 581 | { |
| 582 | char one, |
| 583 | two; |
| 584 | struct bla piet, |
| 585 | jan; |
| 586 | enum foo kees, |
| 587 | jannie; |
| 588 | static unsigned sdf, |
| 589 | krap; |
| 590 | unsigned int piet, |
| 591 | jan; |
| 592 | int |
| 593 | kees, |
| 594 | jan; |
| 595 | } |
| 596 | |
| 597 | { |
| 598 | t(int f, |
| 599 | int d); // ) |
| 600 | d(); |
| 601 | } |
| 602 | |
| 603 | Constructor::Constructor(int a, |
| 604 | int b |
| 605 | ) : |
| 606 | BaseClass(a, |
| 607 | b, |
| 608 | c), |
| 609 | mMember(b), |
| 610 | { |
| 611 | } |
| 612 | |
| 613 | Constructor::Constructor(int a, |
| 614 | int b ) : |
| 615 | BaseClass(a) |
| 616 | { |
| 617 | } |
| 618 | |
| 619 | Constructor::Constructor(int a, |
| 620 | int b ) /*x*/ : /*x*/ BaseClass(a), |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 621 | member(b) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 622 | { |
| 623 | } |
| 624 | |
| 625 | class CAbc : |
| 626 | public BaseClass1, |
| 627 | protected BaseClass2 |
| 628 | { |
| 629 | int Test() { return FALSE; } |
| 630 | int Test1() { return TRUE; } |
| 631 | |
| 632 | CAbc(int a, int b ) : |
| 633 | BaseClass(a) |
| 634 | { |
| 635 | switch(xxx) |
| 636 | { |
| 637 | case abc: |
| 638 | asdf(); |
| 639 | break; |
| 640 | |
| 641 | case 999: |
| 642 | baer(); |
| 643 | break; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | public: // <-- this was incoreectly indented before!! |
| 648 | void testfall(); |
| 649 | protected: |
| 650 | void testfall(); |
| 651 | }; |
| 652 | |
| 653 | class CAbc : public BaseClass1, |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 654 | protected BaseClass2 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 655 | { |
| 656 | }; |
| 657 | |
| 658 | static struct |
| 659 | { |
| 660 | int a; |
| 661 | int b; |
| 662 | } variable[COUNT] = |
| 663 | { |
| 664 | { |
| 665 | 123, |
| 666 | 456 |
| 667 | }, |
| 668 | { |
| 669 | 123, |
| 670 | 456 |
| 671 | } |
| 672 | }; |
| 673 | |
| 674 | static struct |
| 675 | { |
| 676 | int a; |
| 677 | int b; |
| 678 | } variable[COUNT] = |
| 679 | { |
| 680 | { 123, 456 }, |
| 681 | { 123, 456 } |
| 682 | }; |
| 683 | |
| 684 | void asdf() /* ind_maxparen may cause trouble here */ |
| 685 | { |
| 686 | if ((0 |
| 687 | && 1 |
| 688 | && 1 |
| 689 | && 1 |
| 690 | && 1 |
| 691 | && 1 |
| 692 | && 1 |
| 693 | && 1 |
| 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)) break; |
| 712 | } |
| 713 | |
Bram Moolenaar | 18144c8 | 2006-04-12 21:52:12 +0000 | [diff] [blame] | 714 | foo() |
| 715 | { |
| 716 | a = cond ? foo() : asdf |
| 717 | + asdf; |
| 718 | |
| 719 | a = cond ? |
| 720 | foo() : asdf |
| 721 | + asdf; |
| 722 | } |
| 723 | |
| 724 | int main(void) |
| 725 | { |
| 726 | if (a) |
| 727 | if (b) |
| 728 | 2; |
| 729 | else 3; |
| 730 | next_line_of_code(); |
| 731 | } |
| 732 | |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 733 | barry() |
| 734 | { |
| 735 | Foo::Foo (int one, |
| 736 | int two) |
| 737 | : something(4) |
| 738 | {} |
| 739 | } |
| 740 | |
| 741 | barry() |
| 742 | { |
| 743 | Foo::Foo (int one, int two) |
| 744 | : something(4) |
| 745 | {} |
| 746 | } |
| 747 | |
| 748 | Constructor::Constructor(int a, |
| 749 | int b |
| 750 | ) : |
| 751 | BaseClass(a, |
| 752 | b, |
| 753 | c), |
| 754 | mMember(b) |
| 755 | { |
| 756 | } |
Bram Moolenaar | 9e54a0e | 2006-04-14 20:42:25 +0000 | [diff] [blame] | 757 | int main () |
| 758 | { |
| 759 | if (lala) |
| 760 | do |
| 761 | ++(*lolo); |
| 762 | while (lili |
| 763 | && lele); |
| 764 | lulu; |
| 765 | } |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 766 | |
Bram Moolenaar | 9e54a0e | 2006-04-14 20:42:25 +0000 | [diff] [blame] | 767 | int main () |
| 768 | { |
| 769 | switch (c) |
| 770 | { |
| 771 | case 'c': if (cond) |
| 772 | { |
| 773 | } |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | main() |
| 778 | { |
| 779 | (void) MyFancyFuasdfadsfnction( |
| 780 | argument); |
| 781 | } |
| 782 | |
| 783 | main() |
| 784 | { |
| 785 | char foo[] = "/*"; |
| 786 | /* as |
| 787 | df */ |
| 788 | hello |
| 789 | } |
Bram Moolenaar | ed38b0a | 2011-05-25 15:16:18 +0200 | [diff] [blame] | 790 | |
| 791 | /* valid namespaces with normal indent */ |
| 792 | namespace |
| 793 | { |
| 794 | { |
| 795 | 111111111111; |
| 796 | } |
| 797 | } |
| 798 | namespace /* test */ |
| 799 | { |
| 800 | 11111111111111111; |
| 801 | } |
| 802 | namespace // test |
| 803 | { |
| 804 | 111111111111111111; |
| 805 | } |
| 806 | namespace |
| 807 | { |
| 808 | 111111111111111111; |
| 809 | } |
| 810 | namespace test |
| 811 | { |
| 812 | 111111111111111111; |
| 813 | } |
| 814 | namespace{ |
| 815 | 111111111111111111; |
| 816 | } |
| 817 | namespace test{ |
| 818 | 111111111111111111; |
| 819 | } |
| 820 | namespace { |
| 821 | 111111111111111111; |
| 822 | } |
| 823 | namespace test { |
| 824 | 111111111111111111; |
| 825 | namespace test2 { |
| 826 | 22222222222222222; |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | /* invalid namespaces use block indent */ |
| 831 | namespace test test2 { |
| 832 | 111111111111111111111; |
| 833 | } |
| 834 | namespace11111111111 { |
| 835 | 111111111111; |
| 836 | } |
| 837 | namespace() { |
| 838 | 1111111111111; |
| 839 | } |
| 840 | namespace() |
| 841 | { |
| 842 | 111111111111111111; |
| 843 | } |
| 844 | namespace test test2 |
| 845 | { |
| 846 | 1111111111111111111; |
| 847 | } |
| 848 | namespace111111111 |
| 849 | { |
| 850 | 111111111111111111; |
| 851 | } |
| 852 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 853 | /* end of AUTO */ |
| 854 | |
| 855 | |
| 856 | { |
| 857 | |
| 858 | /* this is |
| 859 | * a real serious |
| 860 | * about life, the |
| 861 | * universe, and the |
| 862 | * rest important big |
| 863 | * comment |
| 864 | */ |
| 865 | /* insert " about life, the universe, and the rest" after "serious" */ |
| 866 | } |
| 867 | |
| 868 | |
| 869 | { |
| 870 | /* |
| 871 | * Testing for comments, without 'cin' set |
| 872 | */ |
| 873 | about life |
| 874 | |
| 875 | /* |
| 876 | * what happens here? |
| 877 | */ |
| 878 | there |
| 879 | |
| 880 | /* |
| 881 | the end of the comment, try inserting a line below */ |
| 882 | line |
| 883 | |
| 884 | /* how about |
| 885 | hello |
| 886 | this one */ |
| 887 | } |
| 888 | |
| 889 | |
| 890 | { |
| 891 | var = this + that + vec[0] * vec[0] |
| 892 | + vec[1] * vec[1] |
| 893 | + vec2[2] * vec[2]; |
| 894 | } |
| 895 | |
| 896 | |
| 897 | { |
| 898 | asdf asdflkajds f; |
| 899 | if (tes & ting) { |
| 900 | asdf asdf asdf ; |
| 901 | asdfa sdf asdf; |
| 902 | } |
| 903 | testing1; |
| 904 | if (tes & ting) |
| 905 | { |
| 906 | asdf asdf asdf ; |
| 907 | asdfa sdf asdf; |
| 908 | } |
| 909 | testing2; |
| 910 | } |
| 911 | |
| 912 | |
| 913 | main ( int first_par, /* |
| 914 | * Comment for |
| 915 | * first par |
| 916 | */ |
| 917 | int second_par /* |
| 918 | * Comment for |
| 919 | * second par |
| 920 | */ |
| 921 | ) |
| 922 | { |
| 923 | func( first_par, /* |
| 924 | * Comment for |
| 925 | * first par |
| 926 | */ |
| 927 | second_par /* |
| 928 | * Comment for |
| 929 | * second par |
| 930 | */ |
| 931 | ); |
| 932 | |
| 933 | } |
| 934 | |
| 935 | |
| 936 | { |
| 937 | do |
| 938 | { |
| 939 | if () |
| 940 | { |
| 941 | if () |
| 942 | asdf; |
| 943 | else |
| 944 | asdf; |
| 945 | } |
| 946 | } while (); |
| 947 | cmd; /* this should go under the } */ |
| 948 | } |
| 949 | |
| 950 | |
| 951 | void f() |
| 952 | { |
| 953 | if ( k() ) { |
| 954 | l(); |
| 955 | |
| 956 | } else { /* Start (two words) end */ |
| 957 | m(); |
| 958 | } |
| 959 | |
| 960 | n(); |
| 961 | } |
| 962 | |
| 963 | |
| 964 | void f() |
| 965 | { |
| 966 | if ( k() ) |
| 967 | { |
| 968 | l(); |
| 969 | } else { /* Start (two words) end */ |
| 970 | m(); |
| 971 | } |
| 972 | n(); /* should be under the if () */ |
| 973 | } |
| 974 | |
| 975 | |
| 976 | void bar(void) |
| 977 | { |
| 978 | static array[2][2] = |
| 979 | { |
| 980 | { 1, 2 }, |
| 981 | { 3, 4 }, |
| 982 | } |
| 983 | |
| 984 | while (a) |
| 985 | { |
| 986 | foo(&a); |
| 987 | } |
| 988 | |
| 989 | { |
| 990 | int a; |
| 991 | { |
| 992 | a = a + 1; |
| 993 | } |
| 994 | } |
| 995 | b = a; |
| 996 | } |
| 997 | |
| 998 | void func(void) |
| 999 | { |
| 1000 | a = 1; |
| 1001 | { |
| 1002 | b = 2; |
| 1003 | } |
| 1004 | c = 3; |
| 1005 | d = 4; |
| 1006 | } |
| 1007 | /* foo */ |
| 1008 | |
| 1009 | |
| 1010 | a() |
| 1011 | { |
| 1012 | do { |
| 1013 | a = a + |
| 1014 | a; |
| 1015 | } while ( a ); /* add text under this line */ |
| 1016 | here |
| 1017 | if ( a ) |
| 1018 | a; |
| 1019 | } |
| 1020 | |
| 1021 | |
| 1022 | a() |
| 1023 | { |
| 1024 | label1: |
| 1025 | /* hmm */ |
| 1026 | // comment |
| 1027 | label2: b(); |
| 1028 | label3 /* post */: |
| 1029 | /* pre */ label4: |
| 1030 | f(/*com*/); |
| 1031 | if (/*com*/) |
| 1032 | cmd(); |
| 1033 | } |
| 1034 | |
| 1035 | |
| 1036 | /* |
| 1037 | * A simple comment |
| 1038 | */ |
| 1039 | |
| 1040 | /* |
| 1041 | ** A different comment |
| 1042 | */ |
| 1043 | |
| 1044 | |
| 1045 | void f() |
| 1046 | { |
| 1047 | |
| 1048 | /********* |
| 1049 | A comment. |
| 1050 | *********/ |
| 1051 | } |
| 1052 | |
| 1053 | |
| 1054 | void f() |
| 1055 | { |
| 1056 | |
| 1057 | /********* |
| 1058 | A comment. |
| 1059 | *********/ |
| 1060 | } |
| 1061 | |
| 1062 | |
| 1063 | void f() |
| 1064 | { |
| 1065 | c = c1 && |
| 1066 | ( |
| 1067 | c2 || |
| 1068 | c3 |
| 1069 | ) && c4; |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | void f() |
| 1074 | { |
| 1075 | c = c1 && |
| 1076 | ( |
| 1077 | c2 || |
| 1078 | c3 |
| 1079 | ) && c4; |
| 1080 | } |
| 1081 | |
| 1082 | |
| 1083 | void f() |
| 1084 | { |
| 1085 | c = c1 && |
| 1086 | ( |
| 1087 | c2 || |
| 1088 | c3 |
| 1089 | ) && c4; |
| 1090 | } |
| 1091 | |
| 1092 | |
| 1093 | void f() |
| 1094 | { |
| 1095 | if ( c1 |
| 1096 | && ( c2 |
| 1097 | || c3)) |
| 1098 | foo; |
| 1099 | } |
| 1100 | |
| 1101 | |
| 1102 | void f() |
| 1103 | { |
| 1104 | if ( c1 |
| 1105 | && ( c2 |
| 1106 | || c3)) |
| 1107 | foo; |
| 1108 | } |
| 1109 | |
| 1110 | |
| 1111 | void f() |
| 1112 | { |
| 1113 | c = c1 && ( |
| 1114 | c2 || |
| 1115 | c3 |
| 1116 | ) && c4; |
| 1117 | if ( |
| 1118 | c1 && c2 |
| 1119 | ) |
| 1120 | foo; |
| 1121 | } |
| 1122 | |
| 1123 | |
| 1124 | void f() |
| 1125 | { |
| 1126 | c = c1 && ( |
| 1127 | c2 || |
| 1128 | c3 |
| 1129 | ) && c4; |
| 1130 | if ( |
| 1131 | c1 && c2 |
| 1132 | ) |
| 1133 | foo; |
| 1134 | } |
| 1135 | |
| 1136 | |
| 1137 | void f() |
| 1138 | { |
| 1139 | switch (x) |
| 1140 | { |
| 1141 | case 1: |
| 1142 | a = b; |
| 1143 | break; |
| 1144 | default: |
| 1145 | a = 0; |
| 1146 | break; |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | |
| 1151 | void f() |
| 1152 | { |
| 1153 | invokeme( |
| 1154 | argu, |
| 1155 | ment); |
| 1156 | invokeme( |
| 1157 | argu, |
| 1158 | ment |
| 1159 | ); |
| 1160 | invokeme(argu, |
| 1161 | ment |
| 1162 | ); |
| 1163 | } |
| 1164 | |
| 1165 | |
| 1166 | void f() |
| 1167 | { |
| 1168 | statement; |
| 1169 | // comment 1 |
| 1170 | // comment 2 |
| 1171 | } |
| 1172 | |
| 1173 | |
| 1174 | void f() |
| 1175 | { |
| 1176 | statement; |
| 1177 | // comment 1 |
| 1178 | // comment 2 |
| 1179 | } |
| 1180 | |
| 1181 | |
| 1182 | class CAbc |
| 1183 | { |
| 1184 | int Test() { return FALSE; } |
| 1185 | |
| 1186 | public: // comment |
| 1187 | void testfall(); |
| 1188 | protected: |
| 1189 | void testfall(); |
| 1190 | }; |
| 1191 | |
| 1192 | |
Bram Moolenaar | 7fc904b | 2006-04-13 20:37:35 +0000 | [diff] [blame] | 1193 | void |
| 1194 | foo() |
| 1195 | { |
| 1196 | if (a) |
| 1197 | { |
| 1198 | } else |
| 1199 | asdf; |
| 1200 | } |
| 1201 | |
| 1202 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1203 | { |
| 1204 | averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd( |
| 1205 | asdasdf, |
| 1206 | func(asdf, |
| 1207 | asdfadsf), |
| 1208 | asdfasdf |
| 1209 | ); |
| 1210 | |
| 1211 | /* those are ugly, but consequent */ |
| 1212 | |
| 1213 | func()->asd(asdasdf, |
| 1214 | averylongfunctionname( |
| 1215 | abc, |
| 1216 | dec)->averylongfunctionname( |
| 1217 | asdfadsf, |
| 1218 | asdfasdf, |
| 1219 | asdfasdf, |
| 1220 | ), |
| 1221 | func(asdfadf, |
| 1222 | asdfasdf |
| 1223 | ), |
| 1224 | asdasdf |
| 1225 | ); |
| 1226 | |
| 1227 | averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf( |
| 1228 | abc, |
| 1229 | dec)->asdfasdfasdf( |
| 1230 | asdfadsf, |
| 1231 | asdfasdf, |
| 1232 | asdfasdf, |
| 1233 | ), |
| 1234 | func(asdfadf, |
| 1235 | asdfasdf), |
| 1236 | asdasdf |
| 1237 | ); |
| 1238 | } |
| 1239 | |
Bram Moolenaar | 9e54a0e | 2006-04-14 20:42:25 +0000 | [diff] [blame] | 1240 | |
| 1241 | int main () |
| 1242 | { |
| 1243 | if (cond1 && |
| 1244 | cond2 |
| 1245 | ) |
| 1246 | foo; |
| 1247 | } |
| 1248 | |
Bram Moolenaar | 8d2d71d | 2011-04-28 13:02:09 +0200 | [diff] [blame] | 1249 | |
| 1250 | void func(int a |
| 1251 | #if defined(FOO) |
| 1252 | , int b |
| 1253 | , int c |
| 1254 | #endif |
| 1255 | ) |
| 1256 | { |
| 1257 | } |
| 1258 | |
| 1259 | |
| 1260 | void |
| 1261 | func(int a |
| 1262 | #if defined(FOO) |
| 1263 | , int b |
| 1264 | , int c |
| 1265 | #endif |
| 1266 | ) |
| 1267 | { |
| 1268 | } |
| 1269 | |
Bram Moolenaar | 4ae06c1 | 2011-05-10 11:39:19 +0200 | [diff] [blame] | 1270 | |
| 1271 | void func(void) |
| 1272 | { |
| 1273 | if(x==y) |
| 1274 | if(y==z) |
| 1275 | foo=1; |
| 1276 | else { bar=1; |
| 1277 | baz=2; |
| 1278 | } |
| 1279 | printf("Foo!\n"); |
| 1280 | } |
| 1281 | |
Bram Moolenaar | 496f951 | 2011-05-19 16:35:09 +0200 | [diff] [blame] | 1282 | void func1(void) |
| 1283 | { |
| 1284 | char* tab[] = {"foo", "bar", |
| 1285 | "baz", "quux", |
| 1286 | "this line used", "to be indented incorrectly"}; |
| 1287 | foo(); |
| 1288 | } |
| 1289 | |
| 1290 | void func2(void) |
| 1291 | { |
| 1292 | int tab[] = |
| 1293 | {1, 2, |
| 1294 | 3, 4, |
| 1295 | 5, 6}; |
| 1296 | |
| 1297 | printf("This line used to be indented incorrectly.\n"); |
| 1298 | } |
| 1299 | |
| 1300 | void func3(void) |
| 1301 | { |
| 1302 | int tab[] = { |
| 1303 | 1, 2, |
| 1304 | 3, 4, |
| 1305 | 5, 6}; |
| 1306 | |
| 1307 | printf("Don't you dare indent this line incorrectly!\n); |
| 1308 | } |
| 1309 | |
Bram Moolenaar | aede6ce | 2011-05-10 11:56:30 +0200 | [diff] [blame] | 1310 | |
| 1311 | void func(void) |
| 1312 | { |
Bram Moolenaar | 50f42ca | 2011-07-15 14:12:30 +0200 | [diff] [blame^] | 1313 | int tab[] = |
| 1314 | { |
| 1315 | 1, 2, 3, |
| 1316 | 4, 5, 6}; |
| 1317 | |
| 1318 | printf("Indent this line correctly!\n"); |
| 1319 | |
| 1320 | switch (foo) |
| 1321 | { |
| 1322 | case bar: |
| 1323 | printf("bar"); |
| 1324 | break; |
| 1325 | case baz: { |
| 1326 | printf("baz"); |
| 1327 | break; |
| 1328 | } |
| 1329 | case quux: |
| 1330 | printf("But don't break the indentation of this instruction\n"); |
| 1331 | break; |
| 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | |
| 1336 | void func(void) |
| 1337 | { |
Bram Moolenaar | aede6ce | 2011-05-10 11:56:30 +0200 | [diff] [blame] | 1338 | cout << "a" |
| 1339 | << "b" |
| 1340 | << ") :" |
| 1341 | << "c"; |
| 1342 | } |
| 1343 | |
Bram Moolenaar | a4271d5 | 2011-05-10 13:38:27 +0200 | [diff] [blame] | 1344 | |
| 1345 | void func(void) |
| 1346 | { |
| 1347 | /* |
| 1348 | * This is a comment. |
| 1349 | */ |
| 1350 | foo(); |
| 1351 | } |
| 1352 | |
Bram Moolenaar | 334adf0 | 2011-05-25 13:34:04 +0200 | [diff] [blame] | 1353 | |
| 1354 | void func(void) |
| 1355 | { |
| 1356 | for (int i = 0; i < 10; ++i) |
| 1357 | if (i & 1) { |
| 1358 | foo(1); |
| 1359 | } else |
| 1360 | foo(0); |
| 1361 | baz(); |
| 1362 | } |
| 1363 | |
Bram Moolenaar | ed38b0a | 2011-05-25 15:16:18 +0200 | [diff] [blame] | 1364 | |
Bram Moolenaar | 6ec154b | 2011-06-12 21:51:08 +0200 | [diff] [blame] | 1365 | NAMESPACESTART |
Bram Moolenaar | ed38b0a | 2011-05-25 15:16:18 +0200 | [diff] [blame] | 1366 | /* valid namespaces with normal indent */ |
| 1367 | namespace |
| 1368 | { |
| 1369 | { |
| 1370 | 111111111111; |
| 1371 | } |
| 1372 | } |
| 1373 | namespace /* test */ |
| 1374 | { |
| 1375 | 11111111111111111; |
| 1376 | } |
| 1377 | namespace // test |
| 1378 | { |
| 1379 | 111111111111111111; |
| 1380 | } |
| 1381 | namespace |
| 1382 | { |
| 1383 | 111111111111111111; |
| 1384 | } |
| 1385 | namespace test |
| 1386 | { |
| 1387 | 111111111111111111; |
| 1388 | } |
| 1389 | namespace{ |
| 1390 | 111111111111111111; |
| 1391 | } |
| 1392 | namespace test{ |
| 1393 | 111111111111111111; |
| 1394 | } |
| 1395 | namespace { |
| 1396 | 111111111111111111; |
| 1397 | } |
| 1398 | namespace test { |
| 1399 | 111111111111111111; |
| 1400 | namespace test2 { |
| 1401 | 22222222222222222; |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | /* invalid namespaces use block indent */ |
| 1406 | namespace test test2 { |
| 1407 | 111111111111111111111; |
| 1408 | } |
| 1409 | namespace11111111111 { |
| 1410 | 111111111111; |
| 1411 | } |
| 1412 | namespace() { |
| 1413 | 1111111111111; |
| 1414 | } |
| 1415 | namespace() |
| 1416 | { |
| 1417 | 111111111111111111; |
| 1418 | } |
| 1419 | namespace test test2 |
| 1420 | { |
| 1421 | 1111111111111111111; |
| 1422 | } |
| 1423 | namespace111111111 |
| 1424 | { |
| 1425 | 111111111111111111; |
| 1426 | } |
| 1427 | NAMESPACEEND |
| 1428 | |
| 1429 | |
Bram Moolenaar | 6ec154b | 2011-06-12 21:51:08 +0200 | [diff] [blame] | 1430 | |
| 1431 | JSSTART |
| 1432 | var bar = { |
| 1433 | foo: { |
| 1434 | that: this, |
| 1435 | some: ok, |
| 1436 | }, |
| 1437 | "bar":{ |
| 1438 | a : 2, |
| 1439 | b: "123abc", |
| 1440 | x: 4, |
| 1441 | "y": 5 |
| 1442 | } |
| 1443 | } |
| 1444 | JSEND |
| 1445 | |