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