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