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