Home | History | Annotate | Line # | Download | only in indent
opt_lp.c revision 1.4
      1 /* $NetBSD: opt_lp.c,v 1.4 2021/11/20 16:54:17 rillig Exp $ */
      2 /* $FreeBSD$ */
      3 
      4 /*
      5  * Tests for the options '-lp' and '-nlp'.
      6  *
      7  * The option '-lp' lines up code surrounded by parentheses in continuation
      8  * lines. With '-lp', if a line has a left parenthesis that is not closed on
      9  * that line, continuation lines are lined up to start at the character
     10  * position just after the left parenthesis.
     11  *
     12  * The option '-nlp' indents continuation lines with the continuation
     13  * indentation; see '-ci'.
     14  */
     15 
     16 #indent input
     17 void
     18 example(void)
     19 {
     20 	p1 = first_procedure(second_procedure(p2, p3),
     21 	    third_procedure(p4, p5));
     22 
     23 	p1 = first_procedure(second_procedure(p2,
     24 	    p3),
     25 	    third_procedure(p4,
     26 	        p5));
     27 
     28 	p1 = first_procedure(
     29 	 second_procedure(p2, p3),
     30 	 third_procedure(p4, p5));
     31 }
     32 #indent end
     33 
     34 #indent run -lp
     35 void
     36 example(void)
     37 {
     38 	p1 = first_procedure(second_procedure(p2, p3),
     39 			     third_procedure(p4, p5));
     40 
     41 	p1 = first_procedure(second_procedure(p2,
     42 					      p3),
     43 			     third_procedure(p4,
     44 					     p5));
     45 
     46 	p1 = first_procedure(
     47 			     second_procedure(p2, p3),
     48 			     third_procedure(p4, p5));
     49 }
     50 #indent end
     51 
     52 #indent run -nlp
     53 void
     54 example(void)
     55 {
     56 	p1 = first_procedure(second_procedure(p2, p3),
     57 		third_procedure(p4, p5));
     58 
     59 	p1 = first_procedure(second_procedure(p2,
     60 			p3),
     61 		third_procedure(p4,
     62 			p5));
     63 
     64 	p1 = first_procedure(
     65 		second_procedure(p2, p3),
     66 		third_procedure(p4, p5));
     67 }
     68 #indent end
     69 
     70 /*
     71  * XXX: Combining the options '-nlp' and '-ci4' is counterproductive as the
     72  * indentation does not make the nesting level of the function calls visible.
     73  */
     74 #indent run -nlp -ci4
     75 void
     76 example(void)
     77 {
     78 	p1 = first_procedure(second_procedure(p2, p3),
     79 	    third_procedure(p4, p5));
     80 
     81 	p1 = first_procedure(second_procedure(p2,
     82 	    p3),
     83 	    third_procedure(p4,
     84 	    p5));
     85 
     86 	p1 = first_procedure(
     87 	    second_procedure(p2, p3),
     88 	    third_procedure(p4, p5));
     89 }
     90 #indent end
     91