summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/opt_c.c
blob: bccaa975db2174029854443cb7de8fc3210e601c (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
/* $NetBSD: opt_c.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */

/*
 * Tests for the option '-c', which specifies the column in which the comments
 * to the right of the code start.
 */

//indent input
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2; /* special case */
	if (n % 2 == 0)
		return false;				/* even numbers */
	return true;
}
//indent end

//indent run -c49
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2;			/* special case */
	if (n % 2 == 0)
		return false;			/* even numbers */
	return true;
}
//indent end

/*
 * If the code is too wide to allow the comment in its preferred column, it is
 * nevertheless indented with a single tab, to keep multiple comments
 * vertically aligned.
 */
//indent run -c9
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2;	/* special case */
	if (n % 2 == 0)
		return false;	/* even numbers */
	return true;
}
//indent end

/*
 * Usually, comments are aligned at a tabstop, but indent can also align them
 * at any other column.
 */
//indent run -c37
bool
is_prime(int n)
{
	if (n <= 3)
		return n >= 2;	    /* special case */
	if (n % 2 == 0)
		return false;	    /* even numbers */
	return true;
}
//indent end