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