Commit | Line | Data |
---|---|---|
959f3c4c JH |
1 | ?RCS: $Id: cpp_stuff.U,v 3.0.1.1 1994/10/29 16:08:24 ram Exp $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi | |
4 | ?RCS: | |
5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, | |
6 | ?RCS: as specified in the README file that comes with the distribution. | |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root | |
9 | ?RCS: of the source tree for dist 3.0. | |
10 | ?RCS: | |
11 | ?RCS: $Log: cpp_stuff.U,v $ | |
12 | ?RCS: Revision 3.0.1.1 1994/10/29 16:08:24 ram | |
13 | ?RCS: patch36: now uses cppstdin instead of plain cpp for consistency (ADO) | |
14 | ?RCS: patch36: remove temporary files when done | |
15 | ?RCS: | |
16 | ?RCS: Revision 3.0 1993/08/18 12:05:36 ram | |
17 | ?RCS: Baseline for dist 3.0 netwide release. | |
18 | ?RCS: | |
19 | ?MAKE:cpp_stuff: cat contains cppstdin cppflags cppminus rm | |
20 | ?MAKE: -pick add $@ %< | |
21 | ?S:cpp_stuff: | |
22 | ?S: This variable contains an identification of the catenation mechanism | |
23 | ?S: used by the C preprocessor. | |
24 | ?S:. | |
25 | ?C:CAT2: | |
26 | ?C: This macro catenates 2 tokens together. | |
27 | ?C:. | |
28 | ?C:CAT3: | |
29 | ?C: This macro catenates 3 tokens together. | |
30 | ?C:. | |
31 | ?C:CAT4: | |
32 | ?C: This macro catenates 4 tokens together. | |
33 | ?C:. | |
34 | ?C:CAT5: | |
35 | ?C: This macro catenates 5 tokens together. | |
36 | ?C:. | |
37 | ?C:STRINGIFY: | |
38 | ?C: This macro surrounds its token with double quotes. | |
39 | ?C:. | |
40 | ?C:SCAT2: | |
41 | ?C: This macro catenates 2 tokens together and stringifies the result. | |
42 | ?C: It might not exist, so #ifdef it in your code! | |
43 | ?C:. | |
44 | ?C:SCAT3: | |
45 | ?C: This macro catenates 3 tokens together and stringifies the result. | |
46 | ?C: It might not exist, so #ifdef it in your code! | |
47 | ?C:. | |
48 | ?C:SCAT4: | |
49 | ?C: This macro catenates 4 tokens together and stringifies the result. | |
50 | ?C: It might not exist, so #ifdef it in your code! | |
51 | ?C:. | |
52 | ?C:SCAT5: | |
53 | ?C: This macro catenates 5 tokens together and stringifies the result. | |
54 | ?C: It might not exist, so #ifdef it in your code! | |
55 | ?C:. | |
56 | ?X: Dist pl70 included the following, but AIX's xlc compiler | |
57 | ?X: (which is ANSI-ish and has cpp_stuff == 42)) rejects | |
58 | ?X: The SQuoTe/EQuoTe stuff because the string literals are on | |
59 | ?X: separate lines. Sigh. | |
60 | ?X: Andy Dougherty 24 Feb 1998 | |
61 | ?X: ?H:?%<:#if $cpp_stuff == 1 | |
62 | ?X: ?H:?CAT2:#define CAT2(a,b)a/**/b | |
63 | ?X: ?H:?CAT3:#define CAT3(a,b,c)a/**/b/**/c | |
64 | ?X: ?H:?CAT4:#define CAT4(a,b,c,d)a/**/b/**/c/**/d | |
65 | ?X: ?H:?CAT5:#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e | |
66 | ?X: ?H:?STRINGIFY:#define STRINGIFY(a)"a" | |
67 | ?X: ?H:?%<:#define SQuoTe(a)"a | |
68 | ?X: ?H:?%<:#define EQuoTe(a)a" | |
69 | ?X: ?H:?SCAT2:#define SCAT2(a,b)EQuoTe(SQuoTe(a)b) | |
70 | ?X: ?H:?SCAT3:#define SCAT3(a,b,c)EQuoTe(SQuoTe(a)b/**/c) | |
71 | ?X: ?H:?SCAT4:#define SCAT4(a,b,c,d)EQuoTe(SQuoTe(a)b/**/c/**/d) | |
72 | ?X: ?H:?SCAT5:#define SCAT5(a,b,c,d,e)EQuoTe(SQuoTe(a)b/**/c/**/d/**/e) | |
73 | ?X: ?H:?%<:#endif | |
74 | ?H:?%<:#if $cpp_stuff == 1 | |
75 | ?H:?CAT2:#define CAT2(a,b)a/**/b | |
76 | ?H:?CAT3#define CAT3(a,b,c)a/**/b/**/c | |
77 | ?H:?CAT4:#define CAT4(a,b,c,d)a/**/b/**/c/**/d | |
78 | ?H:?CAT5:#define CAT5(a,b,c,d,e)a/**/b/**/c/**/d/**/e | |
79 | ?H:?STRINGIFY:#define STRINGIFY(a)"a" | |
80 | ?H:?%<: /* If you can get stringification with catify, tell me how! */ | |
81 | ?H:?%<:#endif | |
82 | ?H:?%<:#if $cpp_stuff == 42 | |
83 | ?H:?CAT2:#define CAT2(a,b)a ## b | |
84 | ?H:?CAT3:#define CAT3(a,b,c)a ## b ## c | |
85 | ?H:?CAT4:#define CAT4(a,b,c,d)a ## b ## c ## d | |
86 | ?H:?CAT5:#define CAT5(a,b,c,d,e)a ## b ## c ## d ## e | |
87 | ?H:?%<:#define StGiFy(a)# a | |
88 | ?H:?STRINGIFY:#define STRINGIFY(a)StGiFy(a) | |
89 | ?H:?SCAT2:#define SCAT2(a,b)StGiFy(a) StGiFy(b) | |
90 | ?H:?SCAT3:#define SCAT3(a,b,c)StGiFy(a) StGiFy(b) StGiFy(c) | |
91 | ?H:?SCAT4:#define SCAT4(a,b,c,d)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) | |
92 | ?H:?SCAT5:#define SCAT5(a,b,c,d,e)StGiFy(a) StGiFy(b) StGiFy(c) StGiFy(d) StGiFy(e) | |
93 | ?H:?%<:#endif | |
94 | ?H:?%<:#if $cpp_stuff != 1 && $cpp_stuff != 42 | |
95 | ?H:?%<:#include "Bletch: How does this C preprocessor catenate tokens?" | |
96 | ?H:?%<:#endif | |
97 | ?H:. | |
98 | ?W:%<:CAT2 CAT3 CAT4 CAT5 STRINGIFY SCAT2 SCAT3 SCAT4 SCAT5 | |
99 | ?LINT:known StGiFy | |
100 | : how do we catenate cpp tokens here? | |
101 | echo " " | |
102 | echo "Checking to see how your cpp does stuff like catenate tokens..." >&4 | |
103 | $cat >cpp_stuff.c <<'EOCP' | |
104 | #define RCAT(a,b)a/**/b | |
105 | #define ACAT(a,b)a ## b | |
106 | RCAT(Rei,ser) | |
107 | ACAT(Cir,cus) | |
108 | EOCP | |
109 | $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1 | |
110 | if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then | |
111 | echo "Oh! Smells like ANSI's been here." >&4 | |
112 | echo "We can catify or stringify, separately or together!" | |
113 | cpp_stuff=42 | |
114 | elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then | |
115 | echo "Ah, yes! The good old days!" >&4 | |
116 | echo "However, in the good old days we don't know how to stringify and" | |
117 | echo "catify at the same time." | |
118 | cpp_stuff=1 | |
119 | else | |
120 | $cat >&4 <<EOM | |
121 | Hmm, I don't seem to be able to catenate tokens with your cpp. You're going | |
122 | to have to edit the values of CAT[2-5] in config.h... | |
123 | EOM | |
124 | ?X: It would be nice to have configure remind us at the end that some manual | |
125 | ?X: intervention is needed -- FIXME | |
126 | cpp_stuff="/* Help! How do we handle cpp_stuff? */*/" | |
127 | fi | |
128 | $rm -f cpp_stuff.* | |
129 |