opt_dj.c revision 1.8
1/* $NetBSD: opt_dj.c,v 1.8 2023/06/05 15:02:54 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
13int i;
14int *ip;
15const char *ccp;
16const void *****vppppp;
17const void ******vpppppp;
18const void ********vpppppppp;
19//indent end
20
21//indent run -dj
22int		i;
23int	       *ip;
24const char     *ccp;
25const void *****vppppp;
26const void ******vpppppp;
27const void ********vpppppppp;
28//indent end
29
30//indent run-equals-prev-output -ndj
31
32
33//indent input
34void example(void) {
35	int decl;
36	code();
37}
38//indent end
39
40//indent run -dj
41void
42example(void)
43{
44int		decl;
45	code();
46}
47//indent end
48
49//indent run -ndj
50void
51example(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
63double
64dbl_plus3(a, b, c)
65double a, b, c;
66{
67	return a + b + c;
68}
69//indent end
70
71//indent run -dj
72double
73dbl_plus3(a, b, c)
74	double		a, b, c;
75{
76	return a + b + c;
77}
78//indent end
79
80
81//indent input
82struct 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
97struct 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-input -di0
112
113//indent run-equals-prev-output -dj
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	{
138struct 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