summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/opt_pcs.c
blob: 80eb438314c5e94c64f12f2aba6110886a3d561f (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
/* $NetBSD: opt_pcs.c,v 1.18 2023/06/16 23:07:52 rillig Exp $ */

/*
 * Tests for the options '-pcs' and '-npcs'.
 *
 * The option '-pcs' adds a space in a function call expression, between the
 * function name and the opening parenthesis.
 *
 * The option '-npcs' removes any whitespace from a function call expression,
 * between the function name and the opening parenthesis.
 */

//indent input
void
example(void)
{
	function_call();
	function_call (1);
	function_call   (1,2,3);
}
//indent end

//indent run -pcs
void
example(void)
{
	function_call ();
	function_call (1);
	function_call (1, 2, 3);
}
//indent end

//indent run -npcs
void
example(void)
{
	function_call();
	function_call(1);
	function_call(1, 2, 3);
}
//indent end


//indent input
void ( * signal ( void ( * handler ) ( int ) ) ) ( int ) ;
int var = (function)(arg);
//indent end

//indent run -di0 -pcs
void (*signal (void (*handler) (int))) (int);
// $ This may be a function call or a cast, depending on the context.
int var = (function) (arg);
//indent end

//indent run -di0 -npcs
void (*signal(void (*handler)(int)))(int);
int var = (function)(arg);
//indent end


/*
 * The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
 * these are not functions.
 */
//indent input
int sizeof_type = sizeof   (int);
int sizeof_type = sizeof(int);
int sizeof_expr = sizeof   (0);
int sizeof_expr = sizeof(0);
int sizeof_expr = sizeof   0;

int offset = offsetof(struct s, member);
int offset = offsetof   (struct s, member);
//indent end

/* The option '-pcs' overrides '-nbs'. */
//indent run -pcs -di0 -nbs
int sizeof_type = sizeof (int);
int sizeof_type = sizeof (int);
int sizeof_expr = sizeof (0);
int sizeof_expr = sizeof (0);
int sizeof_expr = sizeof 0;

int offset = offsetof (struct s, member);
int offset = offsetof (struct s, member);
//indent end

/*
 * If the option '-npcs' is given, '-bs' can still specialize it. This only
 * applies to 'sizeof', but not 'offsetof'.
 */
//indent run -npcs -di0 -bs
int sizeof_type = sizeof (int);
int sizeof_type = sizeof (int);
int sizeof_expr = sizeof (0);
int sizeof_expr = sizeof (0);
int sizeof_expr = sizeof 0;

int offset = offsetof(struct s, member);
int offset = offsetof(struct s, member);
//indent end

//indent run -npcs -di0
int sizeof_type = sizeof(int);
int sizeof_type = sizeof(int);
int sizeof_expr = sizeof(0);
int sizeof_expr = sizeof(0);
int sizeof_expr = sizeof 0;

int offset = offsetof(struct s, member);
int offset = offsetof(struct s, member);
//indent end


//indent input
int unary = +call();
int postfix = step++();
int binary = 1 + call();
//indent end

//indent run-equals-input -npcs -di0

//indent run -pcs -di0
int unary = +call ();
int postfix = step++ ();
int binary = 1 + call ();
//indent end