| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
file = __FILE__; |
| 8 |
line = __LINE__; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#define x 3 |
| 15 |
#define f(a) f(x * (a)) |
| 16 |
#undef x |
| 17 |
#define x 2 |
| 18 |
#define g f |
| 19 |
#define z z[0] |
| 20 |
#define h g(~ |
| 21 |
#define m(a) a(w) |
| 22 |
#define w 0,1 |
| 23 |
#define t(a) a |
| 24 |
|
| 25 |
t(t(g)(0) + t)(1); |
| 26 |
f(f(z)); |
| 27 |
f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); |
| 28 |
g(x+(3,4)-w) | h 5) & m |
| 29 |
(f)^m(m); |
| 30 |
|
| 31 |
"Result should be:"; |
| 32 |
"f(2 * (0)) + t(1);"; |
| 33 |
"f(2 * (f(2 * (z[0]))));"; |
| 34 |
"f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);"; |
| 35 |
"f(2 * (2+(3,4)-0,1)) | f(2 * (~5)) & f(2 * (0,1))^m(0,1);"; |
| 36 |
|
| 37 |
|
| 38 |
#undef t |
| 39 |
#undef w |
| 40 |
#undef m |
| 41 |
#undef h |
| 42 |
#undef z |
| 43 |
#undef g |
| 44 |
#undef f |
| 45 |
#undef x |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#define OBJ_LIKE (1-1) |
| 54 |
#define OBJ_LIKE1 (1-1) |
| 55 |
#define FTN_LIKE(a) ( a ) |
| 56 |
#define FTN_LIKE( a )( \ |
| 57 |
a |
| 58 |
) |
| 59 |
|
| 60 |
|
| 61 |
#define OBJ_LIKE (0) |
| 62 |
#define OBJ_LIKE (1 - 1) |
| 63 |
#define FTN_LIKE(b) ( a ) |
| 64 |
#define FTN_LIKE(b) ( b ) |
| 65 |
|
| 66 |
|
| 67 |
#undef OBJ_LIKE |
| 68 |
#undef FTN_LIKE |
| 69 |
#undef OBJ_LIKE1 |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
#define str(s) # s |
| 76 |
#define xstr(s) str(s) |
| 77 |
#define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ |
| 78 |
x ## s, x ## t) |
| 79 |
#define INCFILE(n) vers ## n |
| 80 |
#define glue(a, b) a ## b |
| 81 |
#define xglue(a, b) glue(a, b) |
| 82 |
#define HIGHLOW "hello" |
| 83 |
#define LOW LOW ", world" |
| 84 |
|
| 85 |
debug(1, 2); |
| 86 |
fputs(str(strncmp("abc\0d", "abc", '\4') |
| 87 |
== 0) str(: @\n), s); |
| 88 |
#include xstr(INCFILE(2).h) |
| 89 |
glue(HIGH, LOW); >>> should be: "hello" |
| 90 |
xglue(HIGH, LOW); >>> should be: "hello" ", world" |
| 91 |
|
| 92 |
|
| 93 |
"should be:"; |
| 94 |
'printf("x" "1" "= %d, x" "2" "= %s", x1, x2);' |
| 95 |
'fputs("strncmp(\"abc\\0d\", \"abc\", '\\4') == 0" ": @\n", s);' |
| 96 |
'#include "vers2.h" (after macro replacement, before file access)' |
| 97 |
'"hello";' |
| 98 |
'"hello" ", world";' |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
#undef INCFILE |
| 105 |
#define INCFILE vers2.h |
| 106 |
|
| 107 |
"should not expand macros on the following two lines"; |
| 108 |
#include "INCFILE" |
| 109 |
#include <INCFILE> |
| 110 |
|
| 111 |
#undef INCFILE |
| 112 |
#define INCFILE "vers2.h" |
| 113 |
"should expand macros on the following line"; |
| 114 |
#include INCFILE |
| 115 |
|
| 116 |
|