Home | History | Annotate | Line # | Download | only in indent
opt_lp.c revision 1.8
      1 /* $NetBSD: opt_lp.c,v 1.8 2023/06/08 20:28:50 rillig Exp $ */
      2 
      3 /*
      4  * Tests for the options '-lp' and '-nlp'.
      5  *
      6  * The option '-lp' lines up code surrounded by parentheses in continuation
      7  * lines. With '-lp', if a line has a left parenthesis that is not closed on
      8  * that line, continuation lines are lined up to start at the character
      9  * position just after the left parenthesis.
     10  *
     11  * The option '-nlp' indents continuation lines with the continuation
     12  * indentation; see '-ci'.
     13  */
     14 
     15 //indent input
     16 void
     17 example(void)
     18 {
     19 	p1 = first_procedure(second_procedure(p2, p3),
     20 	    third_procedure(p4, p5));
     21 
     22 	p1 = first_procedure(second_procedure(p2,
     23 	    p3),
     24 	    third_procedure(p4,
     25 	        p5));
     26 
     27 	p1 = first_procedure(
     28 	 second_procedure(p2, p3),
     29 	 third_procedure(p4, p5));
     30 }
     31 //indent end
     32 
     33 //indent run -lp
     34 void
     35 example(void)
     36 {
     37 	p1 = first_procedure(second_procedure(p2, p3),
     38 			     third_procedure(p4, p5));
     39 
     40 	p1 = first_procedure(second_procedure(p2,
     41 					      p3),
     42 			     third_procedure(p4,
     43 					     p5));
     44 
     45 	p1 = first_procedure(
     46 			     second_procedure(p2, p3),
     47 			     third_procedure(p4, p5));
     48 }
     49 //indent end
     50 
     51 //indent run -nlp
     52 void
     53 example(void)
     54 {
     55 	p1 = first_procedure(second_procedure(p2, p3),
     56 		third_procedure(p4, p5));
     57 
     58 	p1 = first_procedure(second_procedure(p2,
     59 			p3),
     60 		third_procedure(p4,
     61 			p5));
     62 
     63 	p1 = first_procedure(
     64 		second_procedure(p2, p3),
     65 		third_procedure(p4, p5));
     66 }
     67 //indent end
     68 
     69 /*
     70  * XXX: Combining the options '-nlp' and '-ci4' is counterproductive as the
     71  * indentation does not make the nesting level of the function calls visible.
     72  */
     73 //indent run -nlp -ci4
     74 void
     75 example(void)
     76 {
     77 	p1 = first_procedure(second_procedure(p2, p3),
     78 	    third_procedure(p4, p5));
     79 
     80 	p1 = first_procedure(second_procedure(p2,
     81 	    p3),
     82 	    third_procedure(p4,
     83 	    p5));
     84 
     85 	p1 = first_procedure(
     86 	    second_procedure(p2, p3),
     87 	    third_procedure(p4, p5));
     88 }
     89 //indent end
     90 
     91 
     92 //indent input
     93 {
     94 if (cond11a
     95 && cond11b
     96 && cond11c) {
     97 stmt11;
     98 } else if (cond12a
     99 && cond12b
    100 && cond12c) {
    101 stmt12;
    102 }
    103 }
    104 
    105 {
    106 if (cond21a
    107 && cond21b
    108 && cond21c)
    109 stmt21;
    110 else if (cond22a
    111 && cond22b
    112 && cond22c)
    113 stmt22;
    114 }
    115 //indent end
    116 
    117 //indent run -ci4 -nlp
    118 {
    119 	if (cond11a
    120 	    && cond11b
    121 	    && cond11c) {
    122 		stmt11;
    123 	} else if (cond12a
    124 // $ FIXME: Wrong indentation, should be 4 spaces only.
    125 		    && cond12b
    126 	    && cond12c) {
    127 		stmt12;
    128 	}
    129 }
    130 
    131 {
    132 	if (cond21a
    133 	    && cond21b
    134 	    && cond21c)
    135 		stmt21;
    136 	else if (cond22a
    137 // $ FIXME: Wrong indentation, should be 4 spaces only.
    138 		    && cond22b
    139 	    && cond22c)
    140 		stmt22;
    141 }
    142 //indent end
    143