-
Notifications
You must be signed in to change notification settings - Fork 160
/
trigraph.c
41 lines (31 loc) · 992 Bytes
/
trigraph.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
# trigraphs
Absolutelly obscure feature for very old systems which do not support certain
characters or because of keyboards which don't support them easily
It is so obscure that gcc:
- turns them off by default without the `-trigraphs` flag
- emits a warning if you use those in that case
Is the first substitution made to source, even before the preprocessor.
They are commented out here so that compilers like
gcc won't annoy us with warnings.
*/
#include "common.h"
int main(void) {
assert('??=' == '#');
assert('??(' == '[');
/* TODO literal backslash? */
assert('\??/' == '\\');
assert('??)' == ']');
assert('??'' == '^');
assert('??<' == '{');
assert('??!' == '|');
assert('??>' == '}');
assert('??-' == '~');
/*
To avoid trigraphs on string literals:
- use `\?`. It exists for that purpose.
- use string concatenation
*/
assert("\?\?" == "?" "?");
return EXIT_SUCCESS;
}