xref: /netbsd-src/tests/usr.bin/indent/opt_fc1.c (revision 1304bdca7f596ac4a196f41b9a6123fa0178f60e)
1 /* $NetBSD: opt_fc1.c,v 1.11 2023/05/14 17:53:38 rillig Exp $ */
2 
3 /*
4  * Tests for the options '-fc1' and '-nfc1'.
5  *
6  * The option '-fc1' formats comments in column 1.
7  *
8  * The option '-nfc1' preserves the original formatting of comments that start
9  * in column 1.
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 	/*	indented tab	*/
43 
44 /* $ The second comment is moved to a separate line. */
45 /* col1 space-padded */ /* space-padded */
46 
47 /* $ Both comment texts get surrounded by spaces. */
48 /*col1 no-padding*//*no-padding*/
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. */
59 /*	indented tab	*/
60 
61 /* $ Each comment got its separate line. */
62 /* col1 space-padded */
63 /* space-padded */
64 
65 /* $ Both comment texts got surrounded by spaces. */
66 /* col1 no-padding */
67 /* no-padding */
68 //indent end
69 
70 //indent run -nfc1
71 /* $ No spaces got added around the comment text. */
72 /*narrow*/
73 
74 /* $ The indentation of a single space was preserved. */
75 /* $ If the comment were moved to column 1, it would change from the area */
76 /* $ of 'comments that may be formatted' to the area of 'comments that must */
77 /* $ not be formatted. The indentation of a single space prevents this. */
78  /* space */
79 
80 /* $ The indentation was changed from a single tab to a single space. */
81  /*	indented tab	*/
82 
83 /* $ The second comment moved to a separate line. */
84 /* col1 space-padded */
85  /* space-padded */
86 
87 /* $ The 'col1' comment starts in column 1 and is thus not modified. */
88 /* $ The second comment started further to the right and thus was modified */
89 /* $ by moving it to a separate line, but not to column 1. */
90 /*col1 no-padding*/
91  /* no-padding */
92 //indent end
93 
94 
95 /*
96  * Since 2019-04-04 and before pr_comment.c 1.123 from 2021-11-25, the
97  * function analyze_comment wrongly joined the two comments.
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 /*
113  * followed by another multi-line comment that starts in column 4.
114  */
115 //indent end
116 
117 //indent run -nfc1
118 /*
119  * A multi-line comment that starts
120  * in column 1.
121  */
122  /*
123   * followed by another multi-line comment that starts in column 4.
124   */
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