xref: /netbsd-src/tests/usr.bin/indent/edge_cases.c (revision aef5eb5f59cdfe8314f1b5f78ac04eb144e44010)
1 /* $NetBSD: edge_cases.c,v 1.1 2022/04/24 10:36:37 rillig Exp $ */
2 
3 /*
4  * Tests for edge cases in the C programming language that indent does not
5  * support or in which cases indent behaves strangely.
6  */
7 
8 /*
9  * Digraphs are replacements for the characters '[', '{' and '#', which are
10  * missing in some exotic restricted source character sets.
11  *
12  * See C99 6.4.6
13  */
14 //indent input
15 void
16 digraphs(void)
17 {
18 	/* same as 'array[subscript]' */
19 	number = array<:subscript:>;
20 
21 	/* same as '(int){ initializer }' */
22 	number = (int)<% initializer %>;
23 }
24 //indent end
25 
26 //indent run
27 void
28 digraphs(void)
29 {
30 	/* same as 'array[subscript]' */
31 // $ XXX: The indentation is completely wrong.
32 // $ XXX: The space between 'array' and '<' doesn't belong there.
33 number = array <:subscript:>;
34 
35 	/* same as '(int){ initializer }' */
36 // $ XXX: The space between '%' and '>' doesn't belong there.
37 	number = (int)<%initializer % >;
38 }
39 //indent end
40 
41 /* TODO: test trigraphs, which are as unusual as digraphs */
42 /* TODO: test digraphs and trigraphs in string literals, just for fun */
43