opt_di.c revision 1.3 1 /* $NetBSD: opt_di.c,v 1.3 2021/10/24 19:24:22 rillig Exp $ */
2 /* $FreeBSD$ */
3
4 /*
5 * Test the option '-di', which specifies the indentation of the variable
6 * declarator.
7 */
8
9 #indent input
10 int space;
11 int tab;
12 int tab16;
13
14 struct long_name long_name;
15 #indent end
16
17 #indent run -di8
18 int space;
19 int tab;
20 int tab16;
21
22 struct long_name long_name;
23 #indent end
24
25
26 /*
27 * The declarator can be a simple variable name. It can also be prefixed by
28 * asterisks, for pointer variables. These asterisks are placed to the left of
29 * the indentation line, so that the variable names are aligned.
30 *
31 * There can be multiple declarators in a single declaration, separated by
32 * commas. Only the first of them is aligned to the indentation given by
33 * '-di', the others are separated with a single space.
34 */
35 #indent input
36 int var;
37 int *ptr, *****ptr;
38 #indent end
39
40 #indent run -di12
41 int var;
42 int *ptr, *****ptr;
43 #indent end
44
45
46 /*
47 * Test the various values for indenting.
48 */
49 #indent input
50 int decl ;
51 #indent end
52
53 /*
54 * An indentation of 0 columns uses a single space between the declaration
55 * specifiers (in this case 'int') and the declarator.
56 */
57 #indent run -di0
58 int decl;
59 #indent end
60
61 /*
62 * An indentation of 7 columns uses spaces for indentation since in the
63 * default configuration, the next tab stop would be at indentation 8.
64 */
65 #indent run -di7
66 int decl;
67 #indent end
68
69 /* The indentation consists of a single tab. */
70 #indent run -di8
71 int decl;
72 #indent end
73
74 /* The indentation consists of a tab and a space. */
75 #indent run -di9
76 int decl;
77 #indent end
78
79 #indent run -di16
80 int decl;
81 #indent end
82
83
84 /*
85 * Ensure that all whitespace is normalized to be indented by 8 columns,
86 * which in the default configuration amounts to a single tab.
87 */
88
89 #indent input
90 int space;
91 int tab;
92 int tab16;
93 struct long_name long_name;
94 #indent end
95
96 #indent run -di8
97 int space;
98 int tab;
99 int tab16;
100 struct long_name long_name;
101 #indent end
102
103
104 #indent input
105 struct {
106 int member;
107 } var = {
108 3,
109 };
110 #indent end
111
112 /* FIXME: The variable name is indented by 6 spaces, should be 1. */
113 #indent run -di0
114 struct {
115 int member;
116 } var = {
117 3,
118 };
119 #indent end
120
121 #indent run
122 struct {
123 int member;
124 } var = {
125 3,
126 };
127 #indent end
128