1/* $NetBSD: opt_bc.c,v 1.13 2023/06/17 22:09:24 rillig Exp $ */
2
3/*
4 * Tests for the options '-bc' and '-nbc'.
5 *
6 * The option '-bc' forces a newline after each comma in a declaration.
7 *
8 * The option '-nbc' removes line breaks between declarators.  In most other
9 * places, indent preserves line breaks.
10 */
11
12//indent input
13int a,b,c;
14void function_declaration(int a,int b,int c);
15int m1,
16m2,
17m3;
18char plain, *pointer;
19//indent end
20
21//indent run -bc
22int		a,
23		b,
24		c;
25void		function_declaration(int a, int b, int c);
26int		m1,
27		m2,
28		m3;
29char		plain,
30	       *pointer;
31//indent end
32
33//indent run -nbc
34int		a, b, c;
35void		function_declaration(int a, int b, int c);
36int		m1, m2, m3;
37char		plain, *pointer;
38//indent end
39
40
41//indent input
42old_style_definition(a, b, c)
43double a,b,c;
44{
45    return a+b+c;
46}
47//indent end
48
49//indent run -bc
50old_style_definition(a, b, c)
51double		a,
52		b,
53		c;
54{
55	return a + b + c;
56}
57//indent end
58
59//indent run -nbc
60old_style_definition(a, b, c)
61double		a, b, c;
62{
63	return a + b + c;
64}
65//indent end
66
67
68/*
69 * Before indent.c 1.311 from 2023-06-02, indent formatted the two '#if'
70 * branches differently and merged the 'b, c' with the preceding preprocessing
71 * line.
72 */
73//indent input
74int a,
75#if 0
76b, c; int d;
77#else
78b, c; int d;
79#endif
80//indent end
81
82//indent run -bc
83int		a,
84#if 0
85		b,
86		c;
87int		d;
88#else
89		b,
90		c;
91int		d;
92#endif
93//indent end
94
95//indent run -nbc
96int		a,
97#if 0
98		b, c;
99int		d;
100#else
101		b, c;
102int		d;
103#endif
104//indent end
105
106
107/*
108 * Before 2023-06-10, a '(' at the top level started a function definition,
109 * leaving variable declaration mode.
110 */
111//indent input
112int a = 1, b = 2;
113int a = (1), b = 2;
114//indent end
115
116//indent run -bc
117int		a = 1,
118		b = 2;
119int		a = (1),
120		b = 2;
121//indent end
122
123
124//indent input
125int a,
126b,
127c;
128//indent end
129
130//indent run -nbc -di0
131int a, b, c;
132//indent end
133
134
135/*
136 * When declarations are too long to fit in a single line, they should not be
137 * joined.
138 */
139//indent input
140{
141	const struct paren_level *prev = state.prev_ps.paren.item,
142	    *curr = ps.paren.item;
143}
144//indent end
145
146//indent run
147// $ FIXME: The line becomes too long.
148{
149	const struct paren_level *prev = state.prev_ps.paren.item, *curr = ps.paren.item;
150}
151//indent end
152
153
154/*
155 * In struct or union declarations, the declarators are split onto separate
156 * lines, just like in ordinary declarations.
157 *
158 * In enum declarations and in initializers, no line breaks are added or
159 * removed.
160 */
161//indent input
162struct triple_struct {
163	int a, b, c;
164};
165union triple_union {
166	int a, b, c;
167};
168enum triple_enum {
169	triple_a, triple_b,
170
171	triple_c,
172};
173//indent end
174
175//indent run -bc
176struct triple_struct {
177	int		a,
178			b,
179			c;
180};
181union triple_union {
182	int		a,
183			b,
184			c;
185};
186enum triple_enum {
187	triple_a, triple_b,
188
189	triple_c,
190};
191//indent end
192
193//indent run -nbc
194struct triple_struct {
195	int		a, b, c;
196};
197union triple_union {
198	int		a, b, c;
199};
200enum triple_enum {
201	triple_a, triple_b,
202
203	triple_c,
204};
205//indent end
206