opt_c.c revision 1.2 1 /* $NetBSD: opt_c.c,v 1.2 2021/11/19 22:24:29 rillig Exp $ */
2 /* $FreeBSD$ */
3
4 /*
5 * Tests for the option '-c', which specifies the column in which the comments
6 * to the right of the code start.
7 */
8
9 #indent input
10 bool
11 is_prime(int n)
12 {
13 if (n <= 3)
14 return n >= 2; /* special case */
15 if (n % 2 == 0)
16 return false; /* even numbers */
17 return true;
18 }
19 #indent end
20
21 #indent run -c49
22 bool
23 is_prime(int n)
24 {
25 if (n <= 3)
26 return n >= 2; /* special case */
27 if (n % 2 == 0)
28 return false; /* even numbers */
29 return true;
30 }
31 #indent end
32
33 /*
34 * If the code is too wide to allow the comment in its preferred column, it is
35 * nevertheless indented with a single tab, to keep multiple comments
36 * vertically aligned.
37 */
38 #indent run -c9
39 bool
40 is_prime(int n)
41 {
42 if (n <= 3)
43 return n >= 2; /* special case */
44 if (n % 2 == 0)
45 return false; /* even numbers */
46 return true;
47 }
48 #indent end
49
50 /*
51 * Usually, comments are aligned at a tabstop, but indent can also align them
52 * at any other column.
53 */
54 #indent run -c37
55 bool
56 is_prime(int n)
57 {
58 if (n <= 3)
59 return n >= 2; /* special case */
60 if (n % 2 == 0)
61 return false; /* even numbers */
62 return true;
63 }
64 #indent end
65