opt_bacc.c revision 1.3
1/* $NetBSD: opt_bacc.c,v 1.3 2021/10/18 07:11:31 rillig Exp $ */
2/* $FreeBSD$ */
3
4/*
5 * Test the options '-bacc' and '-nbacc'.
6 *
7 * The option '-bacc' forces a blank line around every conditional compilation
8 * block.  For example, in front of every #ifdef and after every #endif.
9 * Other blank lines surrounding such blocks are swallowed.
10 *
11 * The option '-nbacc' TODO.
12 */
13
14
15/* Example code without surrounding blank lines. */
16#indent input
17int		a;
18#if 0
19int		b;
20#endif
21int		c;
22#indent end
23
24/*
25 * XXX: As of 2021-10-05, the option -bacc has no effect on declarations since
26 * process_decl resets prefix_blankline_requested unconditionally.
27 */
28#indent run -bacc
29int		a;
30/* $ FIXME: expecting a blank line here */
31#if 0
32int		b;
33#endif
34/* $ FIXME: expecting a blank line here */
35int		c;
36#indent end
37
38/*
39 * With '-nbacc' the code is unchanged since there are no blank lines to
40 * remove.
41 */
42#indent run-equals-input -nbacc
43
44
45/* Example code containing blank lines. */
46#indent input
47int		space_a;
48
49#if 0
50
51int		space_b;
52
53#endif
54
55int		space_c;
56#indent end
57
58#indent run -bacc
59int		space_a;
60/* $ FIXME: expecting a blank line here */
61#if 0
62
63/* $ FIXME: expecting NO blank line here */
64int		space_b;
65#endif
66
67int		space_c;
68#indent end
69
70/* The option '-nbacc' does not remove anything. */
71#indent run-equals-input -nbacc
72
73/*
74 * Preprocessing directives can also occur in function bodies.
75 */
76#indent input
77const char *
78os_name(void)
79{
80#if defined(__NetBSD__) || defined(__FreeBSD__)
81	return "BSD";
82#else
83	return "unknown";
84#endif
85}
86#indent end
87
88#indent run -bacc
89/* $ XXX: The '*' should not be set apart from the rest of the return type. */
90const char     *
91os_name(void)
92{
93/* $ FIXME: expecting a blank line here. */
94#if defined(__NetBSD__) || defined(__FreeBSD__)
95/* $ FIXME: expecting NO blank line here. */
96
97	return "BSD";
98#else
99/* $ FIXME: expecting NO blank line here. */
100
101	return "unknown";
102#endif
103/* $ FIXME: expecting a blank line here. */
104}
105#indent end
106
107#indent run -nbacc
108const char     *
109os_name(void)
110{
111#if defined(__NetBSD__) || defined(__FreeBSD__)
112	return "BSD";
113#else
114	return "unknown";
115#endif
116}
117#indent end
118