xref: /netbsd-src/tests/usr.bin/indent/opt_fcb.c (revision 47306038c7d906b62edca1fd252c0e0d0772f5a0)
1 /* $NetBSD: opt_fcb.c,v 1.8 2022/04/24 09:04:12 rillig Exp $ */
2 
3 /*
4  * Tests for the options '-fcb' and '-nfcb'.
5  *
6  * The option '-fcb' formats block comments (ones that begin with '/' '*'
7  * '\n').
8  *
9  * The option '-nfcb' preserves block comments, like other box comments.
10  */
11 
12 /*
13  * The following comment starts with '/' '*' '\n'.
14  */
15 //indent input
16 /*
17  * Block
18  * comment
19  * with delimiters.
20  */
21 //indent end
22 
23 //indent run -fcb
24 /*
25  * Block comment with delimiters.
26  */
27 //indent end
28 
29 //indent run-equals-input -nfcb
30 
31 
32 /*
33  * The following comment does not count as a block comment since it has a word
34  * in its first line.
35  */
36 //indent input
37 /* Not
38  *
39  * a block
40  *      comment. */
41 //indent end
42 
43 //indent run -fcb
44 /*
45  * Not
46  *
47  * a block comment.
48  */
49 //indent end
50 
51 //indent run-equals-prev-output -nfcb
52 
53 
54 /*
55  * Block comments that start with '-' or another '*' are always preserved.
56  */
57 //indent input
58 /*-
59  * car         mat         men
60  *    efu   for   ted   com   t
61  *       lly         box       .
62  */
63 //indent end
64 
65 //indent run-equals-input -fcb
66 
67 //indent run-equals-input -nfcb
68 
69 
70 /*
71  * The option '-fcb' does not distinguish between comments at the top level
72  * and comments in functions.
73  */
74 //indent input
75 void
example(void)76 example(void)
77 {
78 	/* Not
79 	 *
80 	 * a block
81 	 *      comment */
82 }
83 //indent end
84 
85 //indent run -fcb
86 void
example(void)87 example(void)
88 {
89 	/*
90 	 * Not
91 	 *
92 	 * a block comment
93 	 */
94 }
95 //indent end
96 
97 //indent run-equals-prev-output -nfcb
98 
99 
100 //indent input
101 void
example(void)102 example(void)
103 {
104 	/*
105 	 * This is
106 	 *
107 	 * a block
108 	 *	comment.
109 	 */
110 }
111 //indent end
112 
113 //indent run -fcb
114 void
example(void)115 example(void)
116 {
117 	/*
118 	 * This is
119 	 *
120 	 * a block comment.
121 	 */
122 }
123 //indent end
124 
125 //indent run-equals-input -nfcb
126 
127 
128 //indent input
129 void
example(void)130 example(void)
131 {
132 	/*-
133 	 * car         mat         men
134 	 *    efu   for   ted   com   t
135 	 *       lly         box       .
136 	 */
137 }
138 //indent end
139 
140 //indent run-equals-input -fcb
141 
142 //indent run-equals-input -nfcb
143