1 1.2 rillig /* $NetBSD: edge_cases.c,v 1.2 2023/05/22 23:01:27 rillig Exp $ */ 2 1.1 rillig 3 1.1 rillig /* 4 1.1 rillig * Tests for edge cases in the C programming language that indent does not 5 1.1 rillig * support or in which cases indent behaves strangely. 6 1.1 rillig */ 7 1.1 rillig 8 1.1 rillig /* 9 1.1 rillig * Digraphs are replacements for the characters '[', '{' and '#', which are 10 1.2 rillig * missing in some exotic restricted source character sets. They are not used 11 1.2 rillig * in practice, therefore indent doesn't need to support them. 12 1.1 rillig * 13 1.1 rillig * See C99 6.4.6 14 1.1 rillig */ 15 1.1 rillig //indent input 16 1.1 rillig void 17 1.1 rillig digraphs(void) 18 1.1 rillig { 19 1.1 rillig /* same as 'array[subscript]' */ 20 1.1 rillig number = array<:subscript:>; 21 1.1 rillig 22 1.1 rillig /* same as '(int){ initializer }' */ 23 1.1 rillig number = (int)<% initializer %>; 24 1.1 rillig } 25 1.1 rillig //indent end 26 1.1 rillig 27 1.1 rillig //indent run 28 1.1 rillig void 29 1.1 rillig digraphs(void) 30 1.1 rillig { 31 1.1 rillig /* same as 'array[subscript]' */ 32 1.2 rillig // $ Indent interprets everything before the second ':' as a label name, 33 1.2 rillig // $ therefore the statement is indented that far to the left. 34 1.2 rillig // $ 35 1.2 rillig // $ The space between 'array' and '<' comes from the binary operator '<'. 36 1.1 rillig number = array <:subscript:>; 37 1.1 rillig 38 1.1 rillig /* same as '(int){ initializer }' */ 39 1.2 rillig // $ The opening '<' and '%' are interpreted as unary operators. 40 1.2 rillig // $ The closing '%' and '>' are interpreted as a binary and unary operator. 41 1.1 rillig number = (int)<%initializer % >; 42 1.1 rillig } 43 1.1 rillig //indent end 44 1.1 rillig 45 1.1 rillig /* TODO: test trigraphs, which are as unusual as digraphs */ 46 1.1 rillig /* TODO: test digraphs and trigraphs in string literals, just for fun */ 47