opt_eei.c revision 1.3
1/* $NetBSD: opt_eei.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
2/* $FreeBSD$ */
3
4/*
5 * Tests for the options '-eei' and '-neei'.
6 *
7 * The option '-eei' enables extra indentation on continuation lines of the
8 * expression part of 'if' and 'while' statements. These continuation lines
9 * are indented one extra level.
10 *
11 * The option '-neei' indents these conditions in the same way as all other
12 * continued statements.
13 */
14
15#indent input
16bool
17less(int a, int b)
18{
19	if (a <
20	    b)
21		return true;
22	if (a
23	    <
24	    b)
25		return true;
26}
27#indent end
28
29#indent run -eei
30bool
31less(int a, int b)
32{
33	if (a <
34			b)
35		return true;
36	if (a
37			<
38			b)
39		return true;
40}
41#indent end
42
43#indent run -neei
44bool
45less(int a, int b)
46{
47	if (a <
48	    b)
49		return true;
50	if (a
51	    <
52	    b)
53		return true;
54}
55#indent end
56
57/*
58 * When the indentation level is the same as the continuation indentation, the
59 * indentation does not show the structure of the code.
60 */
61#indent run -neei -i4
62bool
63less(int a, int b)
64{
65    if (a <
66	b)
67	return true;
68    if (a
69	<
70	b)
71	return true;
72}
73#indent end
74
75/*
76 * Adding the extra level of indentation is useful when the standard
77 * indentation is the same as the indentation of statement continuations. In
78 * such a case, the continued condition would have the same indentation as the
79 * following statement, which would be confusing.
80 */
81#indent run -eei -i4
82bool
83less(int a, int b)
84{
85    if (a <
86	    b)
87	return true;
88    if (a
89	    <
90	    b)
91	return true;
92}
93#indent end
94