summaryrefslogtreecommitdiff
path: root/tests/usr.bin/indent/opt_cli.c
blob: b254549ba5dbed1d09cdaacf07d5d66ef17ca12b (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
64
65
66
67
68
69
70
71
72
73
74
75
/* $NetBSD: opt_cli.c,v 1.3 2021/11/28 16:05:59 rillig Exp $ */
/* $FreeBSD$ */

/*
 * Tests for the option '-cli' ("case label indentation"), which sets the
 * amount of indentation of a 'case' relative to the surrounding 'switch',
 * measured in indentation levels.
 *
 * See also:
 *	lsym_case_label.c
 */

#indent input
void
classify(int n)
{
	switch (n) {
	case 0: print("zero"); break;
	case 1: print("one"); break;
	case 2: case 3: print("prime"); break;
	case 4: print("square"); break;
	default: print("large"); break;
	}
}
#indent end

#indent run -cli0.5
void
classify(int n)
{
	switch (n) {
	    case 0:
		print("zero");
		break;
	    case 1:
		print("one");
		break;
	    case 2:
	    case 3:
		print("prime");
		break;
	    case 4:
		print("square");
		break;
	    default:
		print("large");
		break;
	}
}
#indent end

#indent run -cli1.5
void
classify(int n)
{
	switch (n) {
		    case 0:
			print("zero");
			break;
		    case 1:
			print("one");
			break;
		    case 2:
		    case 3:
			print("prime");
			break;
		    case 4:
			print("square");
			break;
		    default:
			print("large");
			break;
	}
}
#indent end