1/* $NetBSD: opt_ce.c,v 1.7 2023/05/11 09:28:53 rillig Exp $ */ 2 3/* 4 * Tests for the options '-ce' and '-nce'. 5 * 6 * The option '-ce' places the 'else' on the same line as the preceding '}'. 7 * 8 * The option '-nce' places the 'else' on the next line. 9 * 10 * See also: 11 * opt_ei.c 12 */ 13 14//indent input 15void 16example(int n) 17{ 18 if (n > 99) { 19 print("large"); 20 } else if (n > 9) { 21 print("double-digit"); 22 } else if (n > 0) 23 print("positive"); 24 else { 25 print("negative"); 26 } 27} 28//indent end 29 30//indent run-equals-input -ce 31 32//indent run -nce 33void 34example(int n) 35{ 36 if (n > 99) { 37 print("large"); 38 } 39 else if (n > 9) { 40 print("double-digit"); 41 } 42 else if (n > 0) 43 print("positive"); 44 else { 45 print("negative"); 46 } 47} 48//indent end 49 50 51//indent input 52void 53example(int n) 54{ 55 if (n > 99) { print("large"); } 56 else if (n > 9) { print("double-digit"); } 57 else if (n > 0) print("positive"); 58 else { print("negative"); } 59} 60//indent end 61 62/* 63 * TODO: Remove the newline between '}' and 'else'. 64 */ 65//indent run -ce 66void 67example(int n) 68{ 69 if (n > 99) { 70 print("large"); 71 } 72 else if (n > 9) { 73 print("double-digit"); 74 } 75 else if (n > 0) 76 print("positive"); 77 else { 78 print("negative"); 79 } 80} 81//indent end 82 83//indent run-equals-prev-output -nce 84