xref: /netbsd-src/tests/usr.bin/indent/opt_pcs.c (revision 122b5006ee1bd67145794b4cde92f4fe4781a5ec)
1 /* $NetBSD: opt_pcs.c,v 1.8 2021/10/31 21:43:43 rillig Exp $ */
2 /* $FreeBSD$ */
3 
4 /*
5  * Tests for the options '-pcs' and '-npcs'.
6  *
7  * The option '-pcs' adds a space in a function call expression, between the
8  * function name and the opening parenthesis.
9  *
10  * The option '-npcs' removes any whitespace from a function call expression,
11  * between the function name and the opening parenthesis.
12  */
13 
14 #indent input
15 void
16 example(void)
17 {
18 	function_call();
19 	function_call (1);
20 	function_call   (1,2,3);
21 }
22 #indent end
23 
24 #indent run -pcs
25 void
26 example(void)
27 {
28 	function_call ();
29 	function_call (1);
30 	function_call (1, 2, 3);
31 }
32 #indent end
33 
34 #indent run -npcs
35 void
36 example(void)
37 {
38 	function_call();
39 	function_call(1);
40 	function_call(1, 2, 3);
41 }
42 #indent end
43 
44 
45 #indent input
46 void ( * signal ( void ( * handler ) ( int ) ) ) ( int ) ;
47 int var = (function)(arg);
48 #indent end
49 
50 #indent run -npsl -di0 -pcs
51 void (*signal(void (*handler) (int))) (int);
52 int var = (function) (arg);
53 #indent end
54 
55 #indent run -npsl -di0 -npcs
56 void (*signal(void (*handler)(int)))(int);
57 int var = (function)(arg);
58 #indent end
59 
60 /*
61  * The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
62  * these are not functions.
63  */
64 #indent input
65 int sizeof_type = sizeof   (int);
66 int sizeof_type = sizeof(int);
67 int sizeof_expr = sizeof   (0);
68 int sizeof_expr = sizeof(0);
69 int sizeof_expr = sizeof   0;
70 
71 int offset = offsetof(struct s, member);
72 int offset = offsetof   (struct s, member);
73 #indent end
74 
75 /* The option '-pcs' overrides '-nbs'. */
76 #indent run -pcs -di0 -nbs
77 int sizeof_type = sizeof (int);
78 int sizeof_type = sizeof (int);
79 int sizeof_expr = sizeof (0);
80 int sizeof_expr = sizeof (0);
81 int sizeof_expr = sizeof 0;
82 
83 int offset = offsetof (struct s, member);
84 int offset = offsetof (struct s, member);
85 #indent end
86 
87 /*
88  * If the option '-npcs' is given, '-bs' can still specialize it. This only
89  * applies to 'sizeof', but not 'offsetof'.
90  */
91 #indent run -npcs -di0 -bs
92 int sizeof_type = sizeof (int);
93 int sizeof_type = sizeof (int);
94 int sizeof_expr = sizeof (0);
95 int sizeof_expr = sizeof (0);
96 int sizeof_expr = sizeof 0;
97 
98 int offset = offsetof(struct s, member);
99 int offset = offsetof(struct s, member);
100 #indent end
101 
102 #indent run -npcs -di0
103 int sizeof_type = sizeof(int);
104 int sizeof_type = sizeof(int);
105 int sizeof_expr = sizeof(0);
106 int sizeof_expr = sizeof(0);
107 int sizeof_expr = sizeof 0;
108 
109 int offset = offsetof(struct s, member);
110 int offset = offsetof(struct s, member);
111 #indent end
112