opt_l.c revision 1.2 1 /* $NetBSD: opt_l.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */
2 /* $FreeBSD$ */
3
4 /*
5 * Tests for the option '-l', which specifies the maximum length of a line.
6 *
7 * As of 2021-11-20, indent assumes that each byte occupies a single column,
8 * it does not properly handle Unicode.
9 */
10
11 #indent input
12 /*
13 * With a line length of 38, this comment and the next one are broken.
14 */
15
16 /* The options -l and -lc produce the same output. */
17 #indent end
18
19 #indent run -l38
20 /*
21 * With a line length of 38, this
22 * comment and the next one are
23 * broken.
24 */
25
26 /*
27 * The options -l and -lc produce the
28 * same output.
29 */
30 #indent end
31 #indent run-equals-prev-output -lc38
32
33 #indent run-equals-input -l78
34 #indent run-equals-input -lc78
35
36
37 #indent input
38 int decl; /* comment comment comment comment */
39 #indent end
40
41 /*
42 * The option '-lc' only applies to block comments, not to comments to the
43 * right of code or declarations.
44 */
45 #indent run -di8 -c17 -lc32
46 int decl; /* comment comment comment comment */
47 #indent end
48
49 #indent run -di8 -c17 -l32
50 int decl; /* comment comment
51 * comment comment */
52 #indent end
53
54
55 /*
56 * FIXME: Even though the line length is limited with -l38,
57 * the overly long lines in the code are not broken.
58 */
59 #indent input
60 void
61 example(int a, int b, int c, const char *cp)
62 {
63 for (const char *p = cp; *p != '\0'; p++)
64 if (*p > a)
65 if (*p > b)
66 if (*p > c)
67 return;
68
69 function(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
70 }
71 #indent end
72
73 #indent run-equals-input -l38
74