opt_psl.c revision 1.8 1 1.8 rillig /* $NetBSD: opt_psl.c,v 1.8 2022/04/24 09:04:12 rillig Exp $ */
2 1.1 rillig
3 1.3 rillig /*
4 1.6 rillig * Tests for the options '-psl' and '-npsl' ("procedure definition in separate
5 1.6 rillig * line").
6 1.3 rillig *
7 1.3 rillig * The option '-psl' starts a new line for the function name in a function
8 1.3 rillig * definition.
9 1.3 rillig *
10 1.3 rillig * The option '-npsl' puts the function name in the same line as its return
11 1.3 rillig * type.
12 1.3 rillig */
13 1.3 rillig
14 1.3 rillig /* Single-line function declarations are not affected by these options. */
15 1.8 rillig //indent input
16 1.1 rillig void function_declaration(void);
17 1.8 rillig //indent end
18 1.3 rillig
19 1.8 rillig //indent run -psl
20 1.3 rillig void function_declaration(void);
21 1.8 rillig //indent end
22 1.3 rillig
23 1.8 rillig //indent run-equals-prev-output -npsl
24 1.3 rillig
25 1.5 rillig
26 1.3 rillig /*
27 1.3 rillig * Multi-line function declarations are affected by these options since indent
28 1.3 rillig * wrongly assumes they were function definitions, not declarations.
29 1.6 rillig *
30 1.6 rillig * Before 1990, when C90 added function prototypes, this case was rare since
31 1.6 rillig * function definitions consisted only of the return type (defaulting to
32 1.6 rillig * 'int'), the function name and the list of parameter names, without
33 1.6 rillig * parameter types or type qualifiers like 'const'.
34 1.3 rillig */
35 1.8 rillig //indent input
36 1.3 rillig void function_declaration(
37 1.3 rillig void);
38 1.8 rillig //indent end
39 1.1 rillig
40 1.8 rillig //indent run -psl
41 1.3 rillig void
42 1.3 rillig function_declaration(
43 1.3 rillig void);
44 1.8 rillig //indent end
45 1.3 rillig
46 1.3 rillig /*
47 1.3 rillig * In a function definition (which indent wrongly assumes here), in contrast
48 1.3 rillig * to a declaration, the function name is not indented to column 17.
49 1.3 rillig */
50 1.8 rillig //indent run -npsl
51 1.3 rillig void function_declaration(
52 1.3 rillig void);
53 1.8 rillig //indent end
54 1.3 rillig
55 1.5 rillig
56 1.3 rillig /*
57 1.3 rillig * In a function definition, in contrast to a declaration, the function name
58 1.3 rillig * is not indented to column 17 since the other function definitions are too
59 1.3 rillig * far away.
60 1.3 rillig */
61 1.8 rillig //indent input
62 1.1 rillig void function_definition(void) {}
63 1.8 rillig //indent end
64 1.1 rillig
65 1.8 rillig //indent run -psl
66 1.1 rillig void
67 1.1 rillig function_definition(void)
68 1.1 rillig {
69 1.1 rillig }
70 1.8 rillig //indent end
71 1.1 rillig
72 1.8 rillig //indent run -npsl
73 1.1 rillig void function_definition(void)
74 1.1 rillig {
75 1.1 rillig }
76 1.8 rillig //indent end
77