Annotation of src/tests/usr.bin/indent/opt_bl_br.c, Revision 1.6
1.6 ! rillig 1: /* $NetBSD: opt_bl_br.c,v 1.5 2022/04/22 21:21:20 rillig Exp $ */
1.1 rillig 2:
1.6 ! rillig 3: //indent input
1.1 rillig 4: void
5: example(int n)
6: {
7: if (n > 99) { print("large"); }
8: else if (n > 9) { print("double-digit"); }
9: else if (n > 0) print("positive");
10: else { print("negative"); }
11: }
1.6 ! rillig 12: //indent end
1.1 rillig 13:
1.3 rillig 14: /*
1.4 rillig 15: * XXX: The '} else' looks strange in this style since the '}' is not on a
16: * line of its own.
1.3 rillig 17: */
1.6 ! rillig 18: //indent run -bl
1.1 rillig 19: void
20: example(int n)
21: {
22: if (n > 99)
23: {
24: print("large");
25: } else if (n > 9)
26: {
27: print("double-digit");
28: } else if (n > 0)
29: print("positive");
30: else
31: {
32: print("negative");
33: }
34: }
1.6 ! rillig 35: //indent end
1.1 rillig 36:
1.6 ! rillig 37: //indent run -br
1.1 rillig 38: void
39: example(int n)
40: {
41: if (n > 99) {
42: print("large");
43: } else if (n > 9) {
44: print("double-digit");
45: } else if (n > 0)
46: print("positive");
47: else {
48: print("negative");
49: }
50: }
1.6 ! rillig 51: //indent end
1.2 rillig 52:
53:
54: /*
1.3 rillig 55: * Test C99 comments after 'if (expr)', which are handled by search_stmt.
1.2 rillig 56: */
1.6 ! rillig 57: //indent input
1.2 rillig 58: void function(void)
59: {
60: if (expr) // C99 comment
61: stmt();
62:
63: if (expr) // C99 comment
64: {
65: stmt();
66: }
67: }
1.6 ! rillig 68: //indent end
1.2 rillig 69:
1.6 ! rillig 70: //indent run
1.2 rillig 71: void
72: function(void)
73: {
74: if (expr) // C99 comment
75: stmt();
76:
77: if (expr) { // C99 comment
78: stmt();
79: }
80: }
1.6 ! rillig 81: //indent end
1.2 rillig 82:
83:
84: /*
85: * Test multiple mixed comments after 'if (expr)'.
86: */
1.6 ! rillig 87: //indent input
1.2 rillig 88: void
89: function(void)
90: {
91: if (expr) // C99 comment 1
92: // C99 comment 2
93: // C99 comment 3
94: stmt();
95: }
1.6 ! rillig 96: //indent end
1.2 rillig 97:
1.6 ! rillig 98: //indent run
1.2 rillig 99: void
100: function(void)
101: {
102: if (expr) // C99 comment 1
103: // C99 comment 2
104: // C99 comment 3
105: stmt();
106: }
1.6 ! rillig 107: //indent end
1.3 rillig 108:
109:
110: /*
1.4 rillig 111: * The combination of the options '-br' and '-ei' (both active by default)
112: * remove extra newlines between the tokens '}', 'else' and 'if'.
1.3 rillig 113: */
1.6 ! rillig 114: //indent input
1.3 rillig 115: void
116: function(void)
117: {
118: if (cond)
119: {
120: stmt();
121: }
122: else
123: if (cond)
124: {
125: stmt();
126: }
127: }
1.6 ! rillig 128: //indent end
1.3 rillig 129:
1.6 ! rillig 130: //indent run -br
1.3 rillig 131: void
132: function(void)
133: {
134: if (cond) {
135: stmt();
136: } else if (cond) {
137: stmt();
138: }
139: }
1.6 ! rillig 140: //indent end
CVSweb <webmaster@jp.NetBSD.org>