xref: /netbsd-src/tests/usr.bin/indent/opt_lpl.c (revision f6ead5d9af63af69d21f824743545a69030e217f)
1 /* $NetBSD: opt_lpl.c,v 1.8 2023/06/10 08:17:04 rillig Exp $ */
2 
3 /*
4  * Tests for the options '-lpl' and '-nlpl'.
5  *
6  * The option '-lpl' lines up code surrounded by parentheses in continuation
7  * lines, even if it would extend past the right margin.
8  *
9  * The option '-nlpl' moves continuation lines that would stick over the right
10  * margin to the left, to keep them within the margin, as long as that does
11  * not require placing them to the left of the prevailing indentation level.
12  *
13  * These switches have no effect if '-nlp' is selected.
14  */
15 
16 /* $ TODO: Add code that differs between -lpl and -nlpl. */
17 
18 //indent input
19 void
example(void)20 example(void)
21 {
22 	int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21;
23 	int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21);
24 
25 	int sum3 = 1+2+3+4+5+
26 		6+7+8+9+10+
27 		11+12+13+14+15+
28 		16+17+18+19+20+
29 		21;
30 	int sum4 = (1+2+3+4+5+
31 		6+7+8+9+10+
32 		11+12+13+14+15+
33 		16+17+18+19+20+
34 		21);
35 
36 	call_function(call_function(call_function(call_function(call_function(call_function())))));
37 
38 	call_function((call_function(call_function(call_function(call_function(call_function()))))));
39 }
40 //indent end
41 
42 //indent run -lpl
43 void
example(void)44 example(void)
45 {
46 	int		sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
47 	int		sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
48 
49 	int		sum3 = 1 + 2 + 3 + 4 + 5 +
50 		6 + 7 + 8 + 9 + 10 +
51 		11 + 12 + 13 + 14 + 15 +
52 		16 + 17 + 18 + 19 + 20 +
53 		21;
54 	int		sum4 = (1 + 2 + 3 + 4 + 5 +
55 				6 + 7 + 8 + 9 + 10 +
56 				11 + 12 + 13 + 14 + 15 +
57 				16 + 17 + 18 + 19 + 20 +
58 				21);
59 
60 	call_function(call_function(call_function(call_function(call_function(call_function())))));
61 
62 	call_function((call_function(call_function(call_function(call_function(call_function()))))));
63 }
64 //indent end
65 
66 //indent run-equals-prev-output -nlpl
67