opt_cdb.c revision 1.7
1/* $NetBSD: opt_cdb.c,v 1.7 2022/04/22 21:21:20 rillig Exp $ */
2
3/*
4 * Tests for the options '-cdb' and '-ncdb'.
5 *
6 * The option '-cdb' forces the comment delimiter '/' '*' and '*' '/' to be on
7 * a separate line. This only affects block comments, but not comments to the
8 * right of the code.
9 *
10 * The option '-ncdb' compresses multi-line comments to single-line comments,
11 * as far as possible.
12 */
13
14#indent input
15/* A single line without delimiters. */
16
17/* Multiple
18 * lines
19 * without delimiters. */
20
21/*
22 * A single line with delimiters.
23 */
24
25/*
26 * Multiple
27 * lines
28 * with delimiters.
29 */
30#indent end
31
32#indent run -cdb
33/* A single line without delimiters. */
34
35/*
36 * Multiple lines without delimiters.
37 */
38
39/*
40 * A single line with delimiters.
41 */
42
43/*
44 * Multiple lines with delimiters.
45 */
46#indent end
47
48#indent run -ncdb
49/* A single line without delimiters. */
50
51/* Multiple lines without delimiters. */
52
53/* A single line with delimiters. */
54
55/* Multiple lines with delimiters. */
56#indent end
57
58
59/*
60 * Code comments on global declarations.
61 */
62#indent input
63int global_single_without;	/* A single line without delimiters. */
64
65int global_multi_without;	/*
66				 * Multiple lines without delimiters.
67				 */
68
69int global_single_with;		/*
70				 * A single line with delimiters.
71				 */
72
73int global_single_with;		/*
74				 * Multiple
75				 * lines
76				 * with delimiters.
77				 */
78#indent end
79
80#indent run -di0 -cdb
81int global_single_without;	/* A single line without delimiters. */
82
83int global_multi_without;	/* Multiple lines without delimiters. */
84
85int global_single_with;		/* A single line with delimiters. */
86
87int global_single_with;		/* Multiple lines with delimiters. */
88#indent end
89
90#indent run-equals-prev-output -di0 -ncdb
91
92
93/*
94 * Block comments that are inside a function.
95 */
96#indent input
97void
98example(void)
99{
100	/* A single line without delimiters. */
101	int local_single_without;
102
103	/* Multiple
104	 * lines
105	 * without delimiters. */
106	int local_multi_without;
107
108	/*
109	 * A single line with delimiters.
110	 */
111	int local_single_with;
112
113	/*
114	 * Multiple
115	 * lines
116	 * with delimiters.
117	 */
118	int local_multi_with;
119}
120#indent end
121
122#indent run -di0 -cdb
123void
124example(void)
125{
126	/* A single line without delimiters. */
127	int local_single_without;
128
129	/*
130	 * Multiple lines without delimiters.
131	 */
132	int local_multi_without;
133
134	/*
135	 * A single line with delimiters.
136	 */
137	int local_single_with;
138
139	/*
140	 * Multiple lines with delimiters.
141	 */
142	int local_multi_with;
143}
144#indent end
145
146#indent run -di0 -ncdb
147void
148example(void)
149{
150	/* A single line without delimiters. */
151	int local_single_without;
152
153	/* Multiple lines without delimiters. */
154	int local_multi_without;
155
156	/* A single line with delimiters. */
157	int local_single_with;
158
159	/* Multiple lines with delimiters. */
160	int local_multi_with;
161}
162#indent end
163
164
165#indent input
166/*
167
168 */
169#indent end
170
171#indent run -cdb
172/*
173 *
174 */
175#indent end
176
177/* FIXME: Looks bad. */
178#indent run -ncdb
179/*
180 * */
181#indent end
182
183
184#indent input
185/*
186
187*/
188#indent end
189
190#indent run -cdb
191/*
192 *
193 */
194#indent end
195
196/* FIXME: Looks bad. */
197#indent run -ncdb
198/*
199 * */
200#indent end
201