opt_lpl.c revision 1.5
1/* $NetBSD: opt_lpl.c,v 1.5 2021/11/20 16:54:17 rillig Exp $ */ 2/* $FreeBSD$ */ 3 4/* 5 * Tests for the options '-lpl' and '-nlpl'. 6 * 7 * The option '-lpl' lines up code surrounded by parentheses in continuation 8 * lines, even if it would extend past the right margin. 9 * 10 * The option '-nlpl' moves continuation lines that would stick over the right 11 * margin to the left, to keep them within the margin, as long as that does 12 * not require placing them to the left of the prevailing indentation level. 13 * 14 * These switches have no effect if '-nlp' is selected. 15 */ 16 17/* $ TODO: Add code that differs between -lpl and -nlpl. */ 18 19#indent input 20void 21example(void) 22{ 23 int sum1 = 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21; 24 int sum2 = (1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21); 25 26 int sum3 = 1+2+3+4+5+ 27 6+7+8+9+10+ 28 11+12+13+14+15+ 29 16+17+18+19+20+ 30 21; 31 int sum4 = (1+2+3+4+5+ 32 6+7+8+9+10+ 33 11+12+13+14+15+ 34 16+17+18+19+20+ 35 21); 36 37 call_function(call_function(call_function(call_function(call_function(call_function()))))); 38 39 call_function((call_function(call_function(call_function(call_function(call_function())))))); 40} 41#indent end 42 43#indent run -lpl 44void 45example(void) 46{ 47 int sum1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21; 48 int sum2 = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21); 49 50/* $ XXX: There should be at least _some_ indentation for the */ 51/* $ continuation lines. */ 52 int sum3 = 1 + 2 + 3 + 4 + 5 + 53 6 + 7 + 8 + 9 + 10 + 54 11 + 12 + 13 + 14 + 15 + 55 16 + 17 + 18 + 19 + 20 + 56 21; 57 int sum4 = (1 + 2 + 3 + 4 + 5 + 58 6 + 7 + 8 + 9 + 10 + 59 11 + 12 + 13 + 14 + 15 + 60 16 + 17 + 18 + 19 + 20 + 61 21); 62 63 call_function(call_function(call_function(call_function(call_function(call_function()))))); 64 65 call_function((call_function(call_function(call_function(call_function(call_function())))))); 66} 67#indent end 68 69#indent run-equals-prev-output -nlpl 70