1 /* $NetBSD: opt_cli.c,v 1.7 2023/06/10 17:35:41 rillig Exp $ */ 2 3 /* 4 * Tests for the option '-cli' ("case label indentation"), which sets the 5 * amount of indentation of a 'case' relative to the surrounding 'switch', 6 * measured in indentation levels. 7 * 8 * See also: 9 * lsym_case_label.c 10 */ 11 12 //indent input 13 void classify(int n)14classify(int n) 15 { 16 switch (n) { 17 case 0: print("zero"); break; 18 case 1: print("one"); break; 19 case 2: case 3: print("prime"); break; 20 case 4: print("square"); break; 21 default: print("large"); break; 22 } 23 } 24 //indent end 25 26 //indent run -cli0.5 27 void classify(int n)28classify(int n) 29 { 30 switch (n) { 31 case 0: 32 print("zero"); 33 break; 34 case 1: 35 print("one"); 36 break; 37 case 2: 38 case 3: 39 print("prime"); 40 break; 41 case 4: 42 print("square"); 43 break; 44 default: 45 print("large"); 46 break; 47 } 48 } 49 //indent end 50 51 //indent run -cli1.5 52 void classify(int n)53classify(int n) 54 { 55 switch (n) { 56 case 0: 57 print("zero"); 58 break; 59 case 1: 60 print("one"); 61 break; 62 case 2: 63 case 3: 64 print("prime"); 65 break; 66 case 4: 67 print("square"); 68 break; 69 default: 70 print("large"); 71 break; 72 } 73 } 74 //indent end 75 76 //indent run -cli3.25 77 void classify(int n)78classify(int n) 79 { 80 switch (n) { 81 case 0: 82 print("zero"); 83 break; 84 case 1: 85 print("one"); 86 break; 87 case 2: 88 case 3: 89 print("prime"); 90 break; 91 case 4: 92 print("square"); 93 break; 94 default: 95 print("large"); 96 break; 97 } 98 } 99 //indent end 100 101 102 /* 103 * Test the combination of left-aligned braces and a deep case indentation. 104 * 105 * When the 'case' labels are that deeply indented, the distance between the 106 * braces and the 'case' is between 1 and 2 indentation levels. 107 */ 108 //indent input 109 { 110 switch (expr) 111 { 112 case 1: 113 } 114 } 115 //indent end 116 117 //indent run -br -cli3.25 118 { 119 switch (expr) { 120 case 1: 121 } 122 } 123 //indent end 124 125 //indent run -bl -cli3.25 126 { 127 switch (expr) 128 { 129 case 1: 130 } 131 } 132 //indent end 133 134 //indent run -bl -cli2.75 135 { 136 switch (expr) 137 { 138 case 1: 139 } 140 } 141 //indent end 142 143 //indent run -bl -cli1.25 144 { 145 switch (expr) 146 { 147 case 1: 148 } 149 } 150 //indent end 151