opt_v.c revision 1.12
1/* $NetBSD: opt_v.c,v 1.12 2023/05/12 10:53:33 rillig Exp $ */
2
3/*
4 * Tests for the options '-v' and '-nv'.
5 *
6 * The option '-v' enables verbose mode. It outputs some information about
7 * what's going on under the hood, especially when lines are broken.
8 *
9 * The option '-nv' disables verbose mode. Only errors and warnings are output
10 * in this mode, but no progress messages.
11 */
12
13/*
14 * XXX: It's rather strange that -v writes to stdout, even in filter mode.
15 * This output belongs on stderr instead.
16 */
17
18//indent input
19/*
20 * A block comment.
21 */
22void
23example(void)
24{
25	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
26}
27
28/* $ The below comment is neither counted nor formatted. */
29#define macro1 /* prefix */ suffix
30
31/* $ The below comment is formatted and counted. */
32#define macro2 prefix /* suffix */
33//indent end
34
35//indent run -v
36/*
37 * A block comment.
38 */
39void
40example(void)
41{
42	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
43}
44
45#define macro1 /* prefix */ suffix
46
47#define macro2 prefix /* suffix */
48//indent end
49
50
51//indent input
52void
53example(void)
54{
55	int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21;
56	int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21);
57}
58//indent end
59
60//indent run -nv
61void
62example(void)
63{
64/* $ XXX: The following lines are too long and should thus be broken. */
65/* $ XXX: If they are broken, -nv does NOT output 'Line broken'. */
66	int		sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21;
67	int		sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21);
68}
69//indent end
70
71
72/*
73 * Before 2023-05-12, indent wrote some wrong statistics to stdout, in which
74 * the line numbers were counted wrong.
75 */
76//indent input
77#if 0
78int line = 1;
79int line = 2;
80int line = 3;
81#else
82int line = 5;
83#endif
84//indent end
85
86//indent run-equals-input -v -di0
87