opt_lpl.c revision 1.7
1/* $NetBSD: opt_lpl.c,v 1.7 2022/04/24 09:04:12 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
19void
20example(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
43void
44example(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/* $ XXX: There should be at least _some_ indentation for the */
50/* $ continuation lines. */
51	int		sum3 = 1 + 2 + 3 + 4 + 5 +
52	6 + 7 + 8 + 9 + 10 +
53	11 + 12 + 13 + 14 + 15 +
54	16 + 17 + 18 + 19 + 20 +
55	21;
56	int		sum4 = (1 + 2 + 3 + 4 + 5 +
57				6 + 7 + 8 + 9 + 10 +
58				11 + 12 + 13 + 14 + 15 +
59				16 + 17 + 18 + 19 + 20 +
60				21);
61
62	call_function(call_function(call_function(call_function(call_function(call_function())))));
63
64	call_function((call_function(call_function(call_function(call_function(call_function()))))));
65}
66//indent end
67
68//indent run-equals-prev-output -nlpl
69