1 /* $NetBSD: opt_bl_br.c,v 1.6 2022/04/24 09:04:12 rillig Exp $ */ 2 3 //indent input 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 } 12 //indent end 13 14 /* 15 * XXX: The '} else' looks strange in this style since the '}' is not on a 16 * line of its own. 17 */ 18 //indent run -bl 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 } 35 //indent end 36 37 //indent run -br 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 } 51 //indent end 52 53 54 /* 55 * Test C99 comments after 'if (expr)', which are handled by search_stmt. 56 */ 57 //indent input 58 void function(void) 59 { 60 if (expr) // C99 comment 61 stmt(); 62 63 if (expr) // C99 comment 64 { 65 stmt(); 66 } 67 } 68 //indent end 69 70 //indent run 71 void 72 function(void) 73 { 74 if (expr) // C99 comment 75 stmt(); 76 77 if (expr) { // C99 comment 78 stmt(); 79 } 80 } 81 //indent end 82 83 84 /* 85 * Test multiple mixed comments after 'if (expr)'. 86 */ 87 //indent input 88 void 89 function(void) 90 { 91 if (expr) // C99 comment 1 92 // C99 comment 2 93 // C99 comment 3 94 stmt(); 95 } 96 //indent end 97 98 //indent run 99 void 100 function(void) 101 { 102 if (expr) // C99 comment 1 103 // C99 comment 2 104 // C99 comment 3 105 stmt(); 106 } 107 //indent end 108 109 110 /* 111 * The combination of the options '-br' and '-ei' (both active by default) 112 * remove extra newlines between the tokens '}', 'else' and 'if'. 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