summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/opt_bap.c
blob: 577d2b5ba8931fd851a384a885364e9daa6de7d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* $NetBSD: opt_bap.c,v 1.11 2023/06/23 20:44:51 rillig Exp $ */

/*
 * Tests for the options '-bap' and '-nbap' ("blank line after procedure
 * body").
 *
 * The option '-bap' forces a blank line after every function body.
 *
 * The option '-nbap' keeps everything as is.
 */

//indent input
static void one_liner(void){}
static void several_lines(void)
{
	action();
}
int main(void){}
int global_variable;

void already_has_blank_line_below(void)
{
}

void has_several_blank_lines_below(void)
{
}



int		the_end;
//indent end

//indent run -bap
static void
one_liner(void)
{
}

static void
several_lines(void)
{
	action();
}

int
main(void)
{
}

int		global_variable;

void
already_has_blank_line_below(void)
{
}

void
has_several_blank_lines_below(void)
{
}



int		the_end;
//indent end

//indent run -nbap
static void
one_liner(void)
{
}
static void
several_lines(void)
{
	action();
}
int
main(void)
{
}
int		global_variable;

void
already_has_blank_line_below(void)
{
}

void
has_several_blank_lines_below(void)
{
}



int		the_end;
//indent end


/*
 * Don't insert a blank line between the end of a function body and an '#endif'
 * line, as both are closing elements.
 */
//indent input
#if 0
void
example(void)
{
}
#endif
//indent end

//indent run-equals-input -bap


/*
 * A preprocessing line after the end of a function body does not force a blank
 * line, as these lines are from a different syntactic layer.
 */
//indent input
#if 0
void
f(void)
{
}
#else
#endif
//indent end

//indent run-equals-input -bacc -bap


/*
 * Do not add a blank line between the end of a function body and an '#undef',
 * as this is a common way to undefine a function-local macro.
 */
//indent input
#define replace
{
}
#undef replace
//indent end

//indent run-equals-input -bap

//indent run-equals-input -bap -bacc