opt_fc1.c revision 1.4 1 /* $NetBSD: opt_fc1.c,v 1.4 2021/10/18 07:11:31 rillig Exp $ */
2 /* $FreeBSD$ */
3
4 /*
5 * Tests for the options '-fc1' and '-nfc1'.
6 *
7 * The option '-fc1' formats comments in column 1.
8 *
9 * The option '-nfc1' prevents comments in column 1 as is.
10 */
11
12 #indent input
13 /*
14 * A comment
15 * in column 1.
16 *
17 *
18 *
19 */
20 #indent end
21
22 #indent run -fc1
23 /*
24 * A comment in column 1.
25 *
26 *
27 *
28 */
29 #indent end
30
31 #indent run-equals-input -nfc1
32
33
34 #indent input
35 /* $ Neither indentation nor surrounding spaces. */
36 /*narrow*/
37
38 /* $ Indented by a single space, single spaces around the text. */
39 /* space */
40
41 /* $ Indented by a single tab, single tabs around the text. */
42 /* tab */
43
44 /* $ The space between these comments gets removed. */
45 /* block1 */ /* block2 */
46
47 /* $ Both comment texts get surrounded by spaces. */
48 /*block1*//*block2*/
49 #indent end
50
51 #indent run -fc1
52 /* $ The comment text got surrounded by spaces. */
53 /* narrow */
54
55 /* $ The indentation got removed. */
56 /* space */
57
58 /* $ The indentation got removed, only the leading tab got replaced by a space. */
59 /* tab */
60
61 /* $ The space between these comments got removed. */
62 /* block1 *//* block2 */
63
64 /* $ Both comment texts got surrounded by spaces. */
65 /* block1 *//* block2 */
66 #indent end
67
68 #indent run -nfc1
69 /* $ No spaces got added around the comment text. */
70 /*narrow*/
71
72 /* $ The indentation of a single space was preserved. */
73 /* $ If the comment were moved to column 1, it would change from the area */
74 /* $ of 'comments that may be formatted' to the area of 'comments that must */
75 /* $ not be formatted. The indentation of a single space prevents this. */
76 /* space */
77
78 /* $ The indentation was changed from a single tab to a single space. */
79 /* tab */
80
81 /* $ The space between these two comments got removed. */
82 /* $ XXX: The option '-nfc1' says that comments in column 1 do not get */
83 /* $ formatted, but the comment 'block1' was moved from column 1 to 2. */
84 /* $ This is probably because there is a second comment in the same line. */
85 /* block1 *//* block2 */
86
87 /* $ It may seem strange at first that the left comment is not touched */
88 /* $ but the right comment gets spaces added. This difference is the */
89 /* $ exact purpose of the option '-nfc1', which says "do not touch comments */
90 /* $ that start in column 1. The first comment starts in column 1, the */
91 /* $ second comment doesn't. */
92 /* $ XXX: The option '-nfc1' says that comments in column 1 do not get */
93 /* $ formatted, but the comment 'block1' was moved from column 1 to 2. */
94 /* $ This is probably because there is a second comment in the same line. */
95 /*block1*//* block2 */
96 #indent end
97
98
99 #indent input
100 /*
101 * A multi-line comment that starts
102 * in column 1.
103 *//* followed by another multi-line comment
104 * that starts in column 4.
105 */
106 #indent end
107
108 #indent run -fc1
109 /*
110 * A multi-line comment that starts in column 1.
111 *
112 * followed by another multi-line comment that starts in column 4.
113 */
114 /* $ XXX: The two comments have been merged into a single comment. */
115 #indent end
116
117 #indent run -nfc1
118 /*
119 * A multi-line comment that starts
120 * in column 1.
121 *
122 * followed by another multi-line comment that starts in column 4.
123 */
124 /* $ XXX: The two comments have been merged into a single comment. */
125 #indent end
126
127
128 #indent input
129 /* comment */ int decl2; /* comment */
130 /* looooooooooooooooooooooooooooooooooooooooong first comment */ int decl2; /* second comment */
131 /* first comment */ int decl2; /* looooooooooooooooooooooooooooooooooooooooong second comment */
132 #indent end
133
134 #indent run -fc1
135 /* comment */ int decl2; /* comment */
136 /* looooooooooooooooooooooooooooooooooooooooong first comment */ int decl2; /* second comment */
137 /* first comment */ int decl2; /* looooooooooooooooooooooooooooooooooooooooong
138 * second comment */
139 #indent end
140
141 #indent run-equals-prev-output -nfc1
142