1 /* $NetBSD: opt_dj.c,v 1.9 2023/06/26 12:21:18 rillig Exp $ */
2
3 /*
4 * Tests for the options '-dj' and '-ndj'.
5 *
6 * The option '-dj' left-justifies declarations of local variables.
7 *
8 * The option '-ndj' indents declarations the same as code.
9 */
10
11 /* For top-level declarations, '-dj' and '-ndj' produce the same output. */
12 //indent input
13 int i;
14 int *ip;
15 const char *ccp;
16 const void *****vppppp;
17 const void ******vpppppp;
18 const void ********vpppppppp;
19 //indent end
20
21 //indent run -dj
22 int i;
23 int *ip;
24 const char *ccp;
25 const void *****vppppp;
26 const void ******vpppppp;
27 const void ********vpppppppp;
28 //indent end
29
30 //indent run-equals-prev-output -ndj
31
32
33 //indent input
example(void)34 void example(void) {
35 int decl;
36 code();
37 }
38 //indent end
39
40 //indent run -dj
41 void
example(void)42 example(void)
43 {
44 int decl;
45 code();
46 }
47 //indent end
48
49 //indent run -ndj
50 void
example(void)51 example(void)
52 {
53 int decl;
54 code();
55 }
56 //indent end
57
58
59 /*
60 * The option '-dj' does not influence traditional function definitions.
61 */
62 //indent input
63 double
dbl_plus3(a,b,c)64 dbl_plus3(a, b, c)
65 double a, b, c;
66 {
67 return a + b + c;
68 }
69 //indent end
70
71 //indent run -dj
72 double
dbl_plus3(a,b,c)73 dbl_plus3(a, b, c)
74 double a, b, c;
75 {
76 return a + b + c;
77 }
78 //indent end
79
80
81 //indent input
82 struct a {
83 struct b {
84 struct c {
85 struct d1 {
86 int e;
87 } d1;
88 struct d2 {
89 int e;
90 } d2;
91 } c;
92 } b;
93 };
94 //indent end
95
96 //indent run -d0
97 struct a {
98 struct b {
99 struct c {
100 struct d1 {
101 int e;
102 } d1;
103 struct d2 {
104 int e;
105 } d2;
106 } c;
107 } b;
108 };
109 //indent end
110
111 //indent run-equals-prev-output -dj
112
113 //indent run-equals-input -di0
114
115
116 //indent input
117 {
118 {
119 struct a {
120 struct b {
121 struct c {
122 struct d1 {
123 int e;
124 } d1;
125 struct d2 {
126 int e;
127 } d2;
128 } c;
129 } b;
130 };
131 }
132 }
133 //indent end
134
135 //indent run -dj
136 {
137 {
138 struct a {
139 struct b {
140 struct c {
141 struct d1 {
142 int e;
143 } d1;
144 struct d2 {
145 int e;
146 } d2;
147 } c;
148 } b;
149 };
150 }
151 }
152 //indent end
153