forked from NetHack/NetHack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp1.shr
More file actions
1783 lines (1783 loc) · 53.4 KB
/
cpp1.shr
File metadata and controls
1783 lines (1783 loc) · 53.4 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# makefile.txt
# readme.txt
# cpp.mem
# cpp.h
# cppdef.h
# cpp2.c
#
echo x - makefile.txt
sed 's/^X//' >makefile.txt << 'END-of-makefile.txt'
X#
X# The redefinition of strchr() and strrchr() are needed for
X# Ultrix-32, Unix 4.2 bsd (and maybe some other Unices).
X#
XBSDDEFINE = -Dstrchr=index -Dstrrchr=rindex
X#
X# On certain systems, such as Unix System III, you may need to define
X# $(LINTFLAGS) in the make command line to set system-specific lint flags.
X#
X# This Makefile assumes cpp will replace the "standard" preprocessor.
X# Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
X# LINEFIX is a sed script filter that reinserts #line -- used for testing
X# if LINE_PREFIX is set to "". Note that we must stand on our heads to
X# match the # and a line had better not begin with $. By the way, what
X# we really want is
X# LINEFIX = | sed "s/^#/#line/"
X#
XCPPDEFINE = -DLINE_PREFIX=\"\"
XLINEFIX = | sed "s/^[^ !\"%-~]/&line/"
X#
X# Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
X# "as compatible as possible" with the standard Unix V7 or Ultrix
X# preprocessors. This is needed to rebuild 4.2bsd, for example, as
X# the preprocessor is used to modify assembler code, rather than C.
X# This is not recommended for current development. OLD_PREPROCESSOR
X# forces the following definitions:
X# OK_DOLLAR FALSE $ is not allowed in variables
X# OK_CONCAT FALSE # cannot concatenate tokens
X# COMMENT_INVISIBLE TRUE old-style comment concatenation
X# STRING_FORMAL TRUE old-style string expansion
X#
XOLDDEFINE = -DOLD_PREPROCESSOR=1
X#
X# DEFINES collects all -D arguments for cc and lint:
X# Change DEFINES = $(BSDDEFINE) $(CPPDEFINE) $(OLDDEFINE)
X# for an old-style preprocessor.
X#
X# DEFINES = $(BSDDEFINE) $(CPPDEFINE)
XDEFINES = $(CPPDEFINE)
X
XCFLAGS = -O $(DEFINES)
X
X#
X# ** compile cpp
X#
XSRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
XOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
Xcpp: $(OBJS)
X $(CC) $(CFLAGS) $(OBJS) -o cpp
X
X#
X# ** Test cpp by preprocessing itself, compiling the result,
X# ** repeating the process and diff'ing the result. Note: this
X# ** is not a good test of cpp, but a simple verification.
X# ** The diff's should not report any changes.
X# ** Note that a sed script may be executed for each compile
X#
Xtest:
X cpp cpp1.c $(LINEFIX) >old.tmp1.c
X cpp cpp2.c $(LINEFIX) >old.tmp2.c
X cpp cpp3.c $(LINEFIX) >old.tmp3.c
X cpp cpp4.c $(LINEFIX) >old.tmp4.c
X cpp cpp5.c $(LINEFIX) >old.tmp5.c
X cpp cpp6.c $(LINEFIX) >old.tmp6.c
X $(CC) $(CFLAGS) old.tmp[123456].c
X a.out cpp1.c >new.tmp1.c
X a.out cpp2.c >new.tmp2.c
X a.out cpp3.c >new.tmp3.c
X a.out cpp4.c >new.tmp4.c
X a.out cpp5.c >new.tmp5.c
X a.out cpp6.c >new.tmp6.c
X diff old.tmp1.c new.tmp1.c
X diff old.tmp2.c new.tmp2.c
X diff old.tmp3.c new.tmp3.c
X diff old.tmp4.c new.tmp4.c
X diff old.tmp5.c new.tmp5.c
X diff old.tmp6.c new.tmp6.c
X rm a.out old.tmp[123456].* new.tmp[123456].*
X
X#
X# A somewhat more extensive test is provided by the "clock"
X# program (which is not distributed). Substitute your favorite
X# macro-rich program here.
X#
Xclock: clock.c cpp
X cpp clock.c $(LINEFIX) >temp.cpp.c
X cc temp.cpp.c -lcurses -ltermcap -o clock
X rm temp.cpp.c
X
X#
X# ** Lint the code
X#
X
Xlint: $(SRCS)
X lint $(LINTFLAGS) $(DEFINES) $(SRCS)
X
X#
X# ** Remove unneeded files
X#
Xclean:
X rm -f $(OBJS) cpp
X
X#
X# ** Rebuild the archive files needed to distribute cpp
X# ** Uses the Decus C archive utility.
X#
X
Xarchc: archc.c
X $(CC) $(CFLAGS) archc.c -o archc
X
Xarchx: archx.c
X $(CC) $(CFLAGS) archx.c -o archx
X
Xarchive: archc
X archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
X cpp*.h >cpp1.arc
X archc cpp1.c cpp2.c cpp3.c >cpp2.arc
X archc cpp4.c cpp5.c cpp6.c >cpp3.arc
X
X#
X# Object module dependencies
X#
X
Xcpp1.o : cpp1.c cpp.h cppdef.h
X
Xcpp2.o : cpp2.c cpp.h cppdef.h
X
Xcpp3.o : cpp3.c cpp.h cppdef.h
X
Xcpp4.o : cpp4.c cpp.h cppdef.h
X
Xcpp5.o : cpp5.c cpp.h cppdef.h
X
Xcpp6.o : cpp6.c cpp.h cppdef.h
X
X
END-of-makefile.txt
echo x - readme.txt
sed 's/^X//' >readme.txt << 'END-of-readme.txt'
X
XDecus cpp is a public-domain implementation of the C preprocessor.
XIt runs on VMS native (Vax C), VMS compatibilty mode (Decus C),
XRSX-11M, RSTS/E, P/OS, and RT11, as well as on several varieties
Xof Unix, including Ultrix. Decus cpp attempts to implement features
Xin the Draft ANSI Standard for the C language. It should be noted,
Xhowever, that this standard is under active development: the current
Xdraft of the standard explicitly states that "readers are requested
Xnot to specify or claim conformance to this draft." Thus readers
Xand users of Decus cpp should not assume that it conforms to the
Xdraft standard, or that it will conform to the actual C language
Xstandard.
X
XThese notes describe how to extract the cpp source files, configure it
Xfor your needs, and mention a few design decisions that may be of interest
Xto maintainers.
X
X Installation
X
XBecause the primary development of cpp was not on Unix, it
Xis distributed using the Decus C archive program (quite similar
Xto the archiver published in Kernighan and Plauger's Software
XTools). To extract the files from the net.sources distribution,
Xsave this message as cpp1.arc and the other two distribution
Xfiles as cpp2.arc and cpp3.arc. Then, using your favorite editor,
Xlocate the archx.c program, just following the line beginning with
X"-h- archx.c" -- the format of the distribution is just:
X
X -h- readme.txt
X ... this file
X -h- cpp.mem
X ... description of cpp
X -h- archx.c
X ... archx.c program -- extracts archives
X -h- archc.c
X ... archc.c program -- creates archives
X
XCompile archx.c -- it shouldn't require any special editing.
XThen run it as follows:
X
X archx *.arc
X
XYou do not need to remove mail headers from the saved messages.
X
XYou should then read through cppdef.h to make sure the HOST and
XTARGET (and other implementation-specific) definitions are set
Xcorrectly for your machine, editing them as needed.
X
XYou may then copy makefile.txt to Makefile, editing it as needed
Xfor your particular system. On Unix, cpp should be compiled
Xby make without further difficulty. On other operating systems,
Xyou should compile the six source modules, linking them together.
XNote that, on Decus C based systems, you must extend the default
Xstack allocation. The Decus C build utility will create the
Xappropriate command file.
X
X Support Notes
X
XThe USENET distribution kit was designed to keep all submissions around
X50,000 bytes:
X
Xcpp1.arc:
X readme.txt This file
X cpp.mem Documentation page (see below)
X archx.c Archive extraction program
X archc.c Archive construction program
X cpp.rno Source for cpp.mem (see below)
X makefile.txt Unix makefile -- copy to Makefile
X cpp.h Main header file (structure def's and globals)
X cppdef.h Configuration file (host and target definitions)
X
Xcpp2.arc:
X cpp1.c Mainline code, documentation master sources
X cpp2.c most #control processing
X cpp3.c filename stuff and command line parsing
Xcpp3.arc:
X cpp4.c #define processor
X cpp5.c #if <expr> processor
X cpp6.c Support code (symbol table and I/O routines)
X
XCpp intentionally does not rely on the presence of a full-scale
Xmacro preprocessor, it does require the simple parameter substitution
Xpreprocessor capabilities of Unix V6 and Decus C. If your C
Xlanguage lacks full preprocessing, you should make sure "nomacargs"
Xis #define'd in cpp.h. (This is done automatically by the Decus C
Xcompiler.)
X
XThe documentation (manual page) for cpp is included as cpp.mem
Xand cpp.rno. Cpp.rno is in Dec Runoff format, built by a Decus C
Xutility (getrno) from original source which is embedded in cpp1.c.
XTo my knowledge, there is no equivalent program that creates
Xthe nroff source appropriate for Unix.
X
XI would be happy to receive fixes to any problems you encounter.
XAs I do not maintain distribution kit base-levels, bare-bones
Xdiff listings without sufficient context are not very useful.
XIt is unlikely that I can find time to help you with other
Xdifficulties.
X
X Acknowledgements
X
XI received a great deal of help from many people in debugging cpp.
XAlan Feuer and Sam Kendall used "state of the art" run-time code
Xcheckers to locate several errors. Ed Keiser found problems when
Xcpp was used on machines with different int and pointer sizes.
XDave Conroy helped with the initial debugging, while Arthur Olsen
Xand George Rosenberg found (and solved) several problems in the
Xfirst USENET release.
X
XMartin Minow
Xdecvax!minow
X
END-of-readme.txt
echo x - cpp.mem
sed 's/^X//' >cpp.mem << 'END-of-cpp.mem'
X
X
X
X
X 1.0 C Pre-Processor
X
X
X
X *******
X * cpp *
X *******
X
X
X
X NAME: cpp -- C Pre-Processor
X
X SYNOPSIS:
X
X cpp [-options] [infile [outfile]]
X
X DESCRIPTION:
X
X CPP reads a C source file, expands macros and include
X files, and writes an input file for the C compiler. If
X no file arguments are given, CPP reads from stdin and
X writes to stdout. If one file argument is given, it
X will define the input file, while two file arguments
X define both input and output files. The file name "-"
X is a synonym for stdin or stdout as appropriate.
X
X The following options are supported. Options may be
X given in either case.
X
X -C If set, source-file comments are written
X to the output file. This allows the
X output of CPP to be used as the input to
X a program, such as lint, that expects
X commands embedded in specially-formatted
X comments.
X
X -Dname=value Define the name as if the programmer
X wrote
X
X #define name value
X
X at the start of the first file. If
X "=value" is not given, a value of "1"
X will be used.
X
X On non-unix systems, all alphabetic text
X will be forced to upper-case.
X
X -E Always return "success" to the operating
X system, even if errors were detected.
X Note that some fatal errors, such as a
X missing #include file, will terminate
X CPP, returning "failure" even if the -E
X option is given.
X Page 2
X cpp C Pre-Processor
X
X
X -Idirectory Add this directory to the list of
X directories searched for #include "..."
X and #include <...> commands. Note that
X there is no space between the "-I" and
X the directory string. More than one -I
X command is permitted. On non-Unix
X systems "directory" is forced to
X upper-case.
X
X -N CPP normally predefines some symbols
X defining the target computer and
X operating system. If -N is specified,
X no symbols will be predefined. If -N -N
X is specified, the "always present"
X symbols, __LINE__, __FILE__, and
X __DATE__ are not defined.
X
X -Stext CPP normally assumes that the size of
X the target computer's basic variable
X types is the same as the size of these
X types of the host computer. (This can
X be overridden when CPP is compiled,
X however.) The -S option allows dynamic
X respecification of these values. "text"
X is a string of numbers, separated by
X commas, that specifies correct sizes.
X The sizes must be specified in the exact
X order:
X
X char short int long float double
X
X If you specify the option as "-S*text",
X pointers to these types will be
X specified. -S* takes one additional
X argument for pointer to function (e.g.
X int (*)())
X
X For example, to specify sizes
X appropriate for a PDP-11, you would
X write:
X
X c s i l f d func
X -S1,2,2,2,4,8,
X -S*2,2,2,2,2,2,2
X
X Note that all values must be specified.
X
X -Uname Undefine the name as if
X
X #undef name
X
X were given. On non-Unix systems, "name"
X will be forced to upper-case.
X Page 3
X cpp C Pre-Processor
X
X
X -Xnumber Enable debugging code. If no value is
X given, a value of 1 will be used. (For
X maintenence of CPP only.)
X
X
X PRE-DEFINED VARIABLES:
X
X When CPP begins processing, the following variables will
X have been defined (unless the -N option is specified):
X
X Target computer (as appropriate):
X
X pdp11, vax, M68000 m68000 m68k
X
X Target operating system (as appropriate):
X
X rsx, rt11, vms, unix
X
X Target compiler (as appropriate):
X
X decus, vax11c
X
X The implementor may add definitions to this list. The
X default definitions match the definition of the host
X computer, operating system, and C compiler.
X
X The following are always available unless undefined (or
X -N was specified twice):
X
X __FILE__ The input (or #include) file being
X compiled (as a quoted string).
X
X __LINE__ The line number being compiled.
X
X __DATE__ The date and time of compilation as a
X Unix ctime quoted string (the trailing
X newline is removed). Thus,
X
X printf("Bug at line %s,", __LINE__);
X printf(" source file %s", __FILE__);
X printf(" compiled on %s", __DATE__);
X
X
X DRAFT PROPOSED ANSI STANDARD CONSIDERATIONS:
X
X The current version of the Draft Proposed Standard
X explicitly states that "readers are requested not to
X specify or claim conformance to this draft." Readers and
X users of Decus CPP should not assume that Decus CPP
X conforms to the standard, or that it will conform to the
X actual C Language Standard.
X
X When CPP is itself compiled, many features of the Draft
X Proposed Standard that are incompatible with existing
X Page 4
X cpp C Pre-Processor
X
X
X preprocessors may be disabled. See the comments in
X CPP's source for details.
X
X The latest version of the Draft Proposed Standard (as
X reflected in Decus CPP) is dated November 12, 1984.
X
X Comments are removed from the input text. The comment
X is replaced by a single space character. The -C option
X preserves comments, writing them to the output file.
X
X The '$' character is considered to be a letter. This is
X a permitted extension.
X
X The following new features of C are processed by CPP:
X
X #elif expression (#else #if)
X '\xNNN' (Hexadecimal constant)
X '\a' (Ascii BELL)
X '\v' (Ascii Vertical Tab)
X #if defined NAME 1 if defined, 0 if not
X #if defined (NAME) 1 if defined, 0 if not
X #if sizeof (basic type)
X unary +
X 123U, 123LU Unsigned ints and longs.
X 12.3L Long double numbers
X token#token Token concatenation
X #include token Expands to filename
X
X The Draft Proposed Standard has extended C, adding a
X constant string concatenation operator, where
X
X "foo" "bar"
X
X is regarded as the single string "foobar". (This does
X not affect CPP's processing but does permit a limited
X form of macro argument substitution into strings as will
X be discussed.)
X
X The Standard Committee plans to add token concatenation
X to #define command lines. One suggested implementation
X is as follows: the sequence "Token1#Token2" is treated
X as if the programmer wrote "Token1Token2". This could
X be used as follows:
X
X #line 123
X #define ATLINE foo#__LINE__
X
X ATLINE would be defined as foo123.
X
X Note that "Token2" must either have the format of an
X identifier or be a string of digits. Thus, the string
X
X #define ATLINE foo#1x3
X Page 5
X cpp C Pre-Processor
X
X
X generates two tokens: "foo1" and "x3".
X
X If the tokens T1 and T2 are concatenated into T3, this
X implementation operates as follows:
X
X 1. Expand T1 if it is a macro.
X 2. Expand T2 if it is a macro.
X 3. Join the tokens, forming T3.
X 4. Expand T3 if it is a macro.
X
X A macro formal parameter will be substituted into a
X string or character constant if it is the only component
X of that constant:
X
X #define VECSIZE 123
X #define vprint(name, size) \
X printf("name" "[" "size" "] = {\n")
X ... vprint(vector, VECSIZE);
X
X expands (effectively) to
X
X vprint("vector[123] = {\n");
X
X Note that this will be useful if your C compiler
X supports the new string concatenation operation noted
X above. As implemented here, if you write
X
X #define string(arg) "arg"
X ... string("foo") ...
X
X This implementation generates "foo", rather than the
X strictly correct ""foo"" (which will probably generate
X an error message). This is, strictly speaking, an error
X in CPP and may be removed from future releases.
X
X ERROR MESSAGES:
X
X Many. CPP prints warning or error messages if you try
X to use multiple-byte character constants
X (non-transportable) if you #undef a symbol that was not
X defined, or if your program has potentially nested
X comments.
X
X AUTHOR:
X
X Martin Minow
X
X BUGS:
X
X The #if expression processor uses signed integers only.
X I.e, #if 0xFFFFu < 0 may be TRUE.
X
END-of-cpp.mem
echo x - cpp.h
sed 's/^X//' >cpp.h << 'END-of-cpp.h'
X
X/*
X * I n t e r n a l D e f i n i t i o n s f o r C P P
X *
X * In general, definitions in this file should not be changed.
X */
X
X#ifndef TRUE
X#define TRUE 1
X#define FALSE 0
X#endif
X#ifndef EOS
X/*
X * This is predefined in Decus C
X */
X#define EOS '\0' /* End of string */
X#endif
X#define EOF_CHAR 0 /* Returned by get() on eof */
X#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
X#define DEF_NOARGS (-1) /* #define foo vs #define foo() */
X
X/*
X * The following may need to change if the host system doesn't use ASCII.
X */
X#define DEF_MAGIC 0x1D /* Magic for #defines */
X#define TOK_SEP 0x1E /* Token concatenation delim. */
X#define COM_SEP 0x1F /* Magic comment separator */
X
X/*
X * Note -- in Ascii, the following will map macro formals onto DEL + the
X * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
X * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
X * value is reserved for string substitution.
X */
X
X#define MAC_PARM 0x7F /* Macro formals start here */
X#if PAR_MAC >= 33
X assertion fails -- PAR_MAC isn't less than 33
X#endif
X#define LASTPARM (PAR_MAC - 1)
X
X/*
X * Character type codes.
X */
X
X#define INV 0 /* Invalid, must be zero */
X#define OP_EOE INV /* End of expression */
X#define DIG 1 /* Digit */
X#define LET 2 /* Identifier start */
X#define FIRST_BINOP OP_ADD
X#define OP_ADD 3
X#define OP_SUB 4
X#define OP_MUL 5
X#define OP_DIV 6
X#define OP_MOD 7
X#define OP_ASL 8
X#define OP_ASR 9
X#define OP_AND 10 /* &, not && */
X#define OP_OR 11 /* |, not || */
X#define OP_XOR 12
X#define OP_EQ 13
X#define OP_NE 14
X#define OP_LT 15
X#define OP_LE 16
X#define OP_GE 17
X#define OP_GT 18
X#define OP_ANA 19 /* && */
X#define OP_ORO 20 /* || */
X#define OP_QUE 21 /* ? */
X#define OP_COL 22 /* : */
X#define OP_CMA 23 /* , (relevant?) */
X#define LAST_BINOP OP_CMA /* Last binary operand */
X/*
X * The following are unary.
X */
X#define FIRST_UNOP OP_PLU /* First Unary operand */
X#define OP_PLU 24 /* + (draft ANSI standard) */
X#define OP_NEG 25 /* - */
X#define OP_COM 26 /* ~ */
X#define OP_NOT 27 /* ! */
X#define LAST_UNOP OP_NOT
X#define OP_LPA 28 /* ( */
X#define OP_RPA 29 /* ) */
X#define OP_END 30 /* End of expression marker */
X#define OP_MAX (OP_END + 1) /* Number of operators */
X#define OP_FAIL (OP_END + 1) /* For error returns */
X
X/*
X * The following are for lexical scanning only.
X */
X
X#define QUO 65 /* Both flavors of quotation */
X#define DOT 66 /* . might start a number */
X#define SPA 67 /* Space and tab */
X#define BSH 68 /* Just a backslash */
X#define END 69 /* EOF */
X
X/*
X * These bits are set in ifstack[]
X */
X#define WAS_COMPILING 1 /* TRUE if compile set at entry */
X#define ELSE_SEEN 2 /* TRUE when #else processed */
X#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
X
X/*
X * Define bits for the basic types and their adjectives
X */
X
X#define T_CHAR 1
X#define T_INT 2
X#define T_FLOAT 4
X#define T_DOUBLE 8
X#define T_SHORT 16
X#define T_LONG 32
X#define T_SIGNED 64
X#define T_UNSIGNED 128
X#define T_PTR 256 /* Pointer */
X#define T_FPTR 512 /* Pointer to functions */
X
X/*
X * The DEFBUF structure stores information about #defined
X * macros. Note that the defbuf->repl information is always
X * in malloc storage.
X */
X
Xtypedef struct defbuf {
X struct defbuf *link; /* Next define in chain */
X char *repl; /* -> replacement */
X int hash; /* Symbol table hash */
X int nargs; /* For define(args) */
X char name[1]; /* #define name */
X} DEFBUF;
X
X/*
X * The FILEINFO structure stores information about open files
X * and macros being expanded.
X */
X
Xtypedef struct fileinfo {
X char *bptr; /* Buffer pointer */
X int line; /* for include or macro */
X FILE *fp; /* File if non-null */
X struct fileinfo *parent; /* Link to includer */
X char *filename; /* File/macro name */
X char *progname; /* From #line statement */
X unsigned int unrecur; /* For macro recursion */
X char buffer[1]; /* current input line */
X} FILEINFO;
X
X/*
X * The SIZES structure is used to store the values for #if sizeof
X */
X
Xtypedef struct sizes {
X short bits; /* If this bit is set, */
X short size; /* this is the datum size value */
X short psize; /* this is the pointer size */
X} SIZES;
X/*
X * nomacarg is a built-in #define on Decus C.
X */
X
X#ifdef nomacarg
X#define cput output /* cput concatenates tokens */
X#else
X#if COMMENT_INVISIBLE
X#define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
X#else
X#define cput(c) { if (c != TOK_SEP) putchar(c); }
X#endif
X#endif
X
X#ifndef nomacarg
X#define streq(s1, s2) (strcmp(s1, s2) == 0)
X#endif
X
X/*
X * Error codes. VMS uses system definitions.
X * Decus C codes are defined in stdio.h.
X * Others are cooked to order.
X */
X
X#if HOST == SYS_VMS
X#include <ssdef.h>
X#include <stsdef.h>
X#define IO_NORMAL (SS$_NORMAL | STS$M_INHIB_MSG)
X#define IO_ERROR SS$_ABORT
X#endif
X/*
X * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
X */
X#ifndef IO_NORMAL
X#define IO_NORMAL 0
X#endif
X#ifndef IO_ERROR
X#define IO_ERROR 1
X#endif
X
X/*
X * Externs
X */
X
Xextern int line; /* Current line number */
Xextern int wrongline; /* Force #line to cc pass 1 */
Xextern char type[]; /* Character classifier */
Xextern char token[IDMAX + 1]; /* Current input token */
Xextern int instring; /* TRUE if scanning string */
Xextern int inmacro; /* TRUE if scanning #define */
Xextern int errors; /* Error counter */
Xextern int recursion; /* Macro depth counter */
Xextern char ifstack[BLK_NEST]; /* #if information */
X#define compiling ifstack[0]
Xextern char *ifptr; /* -> current ifstack item */
Xextern char *incdir[NINCLUDE]; /* -i directories */
Xextern char **incend; /* -> active end of incdir */
Xextern int cflag; /* -C option (keep comments) */
Xextern int eflag; /* -E option (ignore errors) */
Xextern int nflag; /* -N option (no pre-defines) */
Xextern int rec_recover; /* unwind recursive macros */
Xextern char *preset[]; /* Standard predefined symbols */
Xextern char *magic[]; /* Magic predefined symbols */
Xextern FILEINFO *infile; /* Current input file */
Xextern char work[NWORK + 1]; /* #define scratch */
Xextern char *workp; /* Free space in work */
X#if DEBUG
Xextern int debug; /* Debug level */
X#endif
Xextern int keepcomments; /* Don't remove comments if set */
Xextern SIZES size_table[]; /* For #if sizeof sizes */
Xextern char *getmem(); /* Get memory or die. */
Xextern DEFBUF *lookid(); /* Look for a #define'd thing */
Xextern DEFBUF *defendel(); /* Symbol table enter/delete */
Xextern char *savestring(); /* Stuff string in malloc mem. */
Xextern char *strcpy();
Xextern char *strcat();
Xextern char *strrchr();
Xextern char *strchr();
Xextern long time();
X/* extern char *sprintf(); /* Lint needs this */
END-of-cpp.h
echo x - cppdef.h
sed 's/^X//' >cppdef.h << 'END-of-cppdef.h'
X/*
X * S y s t e m D e p e n d e n t
X * D e f i n i t i o n s f o r C P P
X *
X * Definitions in this file may be edited to configure CPP for particular
X * host operating systems and target configurations.
X *
X * NOTE: cpp assumes it is compiled by a compiler that supports macros
X * with arguments. If this is not the case (as for Decus C), #define
X * nomacarg -- and provide function equivalents for all macros.
X *
X * cpp also assumes the host and target implement the Ascii character set.
X * If this is not the case, you will have to do some editing here and there.
X */
X
X/*
X * This redundant definition of TRUE and FALSE works around
X * a limitation of Decus C.
X */
X#ifndef TRUE
X#define TRUE 1
X#define FALSE 0
X#endif
X
X/*
X * Define the HOST operating system. This is needed so that
X * cpp can use appropriate filename conventions.
X */
X#define SYS_UNKNOWN 0
X#define SYS_UNIX 1
X#define SYS_VMS 2
X#define SYS_RSX 3
X#define SYS_RT11 4
X#define SYS_LATTICE 5
X#define SYS_ONYX 6
X#define SYS_68000 7
X#define SYS_GCOS 8
X#define SYS_IBM 9
X#define SYS_OS 10
X#define SYS_TSS 11
X
X#ifndef HOST
X#ifdef unix
X#define HOST SYS_UNIX
X#else
X#ifdef vms
X#define HOST SYS_VMS
X#else
X#ifdef rsx
X#define HOST SYS_RSX
X#else
X#ifdef rt11
X#define HOST SYS_RT11
X#else
X#ifdef dmert
X#define HOST SYS_DMERT
X#else
X#ifdef gcos
X#define HOST SYS_GCOS
X#else
X#ifdef ibm
X#define HOST SYS_IBM
X#else
X#ifdef os
X#define HOST SYS_OS
X#else
X#ifdef tss
X#define HOST SYS_TSS
X#endif
X#endif
X#endif
X#endif
X#endif
X#endif
X#endif
X#endif
X#endif
X
X#ifndef HOST
X#define HOST SYS_UNKNOWN
X#endif
X
X/*
X * We assume that the target is the same as the host system
X */
X#ifndef TARGET
X#define TARGET HOST
X#endif
X
X/*
X * In order to predefine machine-dependent constants,
X * several strings are defined here:
X *
X * MACHINE defines the target cpu (by name)
X * SYSTEM defines the target operating system
X * COMPILER defines the target compiler
X *
X * The above may be #defined as "" if they are not wanted.
X * They should not be #defined as NULL.
X *
X * LINE_PREFIX defines the # output line prefix, if not "line"
X * This should be defined as "" if cpp is to replace
X * the "standard" C pre-processor.
X *
X * FILE_LOCAL marks functions which are referenced only in the
X * file they reside. Some C compilers allow these
X * to be marked "static" even though they are referenced
X * by "extern" statements elsewhere.
X *
X * OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character
X * in identifiers (default), or zero if $ is invalid.
X * Default is TRUE.
X *
X * OK_CONCAT Should be set TRUE if # may be used to concatenate
X * tokens in macros (per the Ansi Draft Standard) or
X * FALSE for old-style # processing (needed if cpp is
X * to process assembler source code).
X *
X * OK_DATE Predefines the compilation date if set TRUE.
X * Not permitted by the Nov. 12, 1984 Draft Standard.
X *
X * S_CHAR etc. Define the sizeof the basic TARGET machine word types.
X * By default, sizes are set to the values for the HOST
X * computer. If this is inappropriate, see the code in
X * cpp3.c for details on what to change. Also, if you
X * have a machine where sizeof (signed int) differs from
X * sizeof (unsigned int), you will have to edit code and
X * tables in cpp3.c (and extend the -S option definition.)
X *
X * CPP_LIBRARY May be defined if you have a site-specific include directory
X * which is to be searched *before* the operating-system
X * specific directories.
X */
X
X#if TARGET == SYS_LATTICE
X/*
X * We assume the operating system is pcdos for the IBM-PC.
X * We also assume the small model (just like the PDP-11)
X */
X#define MACHINE "i8086"
X#define SYSTEM "pcdos"
X#endif
X
X#if TARGET == SYS_ONYX
X#define MACHINE "z8000"
X#define SYSTEM "unix"
X#endif
X
X#if TARGET == SYS_VMS
X#define MACHINE "vax"
X#define SYSTEM "vms"
X#define COMPILER "vax11c"
X#endif
X
X#if TARGET == SYS_RSX
X#define MACHINE "pdp11"
X#define SYSTEM "rsx"
X#define COMPILER "decus"
X#endif
X
X#if TARGET == SYS_RT11
X#define MACHINE "pdp11"
X#define SYSTEM "rt11"
X#define COMPILER "decus"
X#endif
X
X#if TARGET == SYS_68000
X/*
X * All three machine designators have been seen in various systems.
X * Warning -- compilers differ as to sizeof (int). cpp3 assumes that
X * sizeof (int) == 2
X */
X#define MACHINE "M68000", "m68000", "m68k"
X#define SYSTEM "unix"
X#endif
X
X#if TARGET == SYS_UNIX
X#define SYSTEM "unix"
X#ifdef pdp11
X#define MACHINE "pdp11"
X#endif
X#ifdef vax
X#define MACHINE "vax"
X#endif
X#ifdef u370
X#define MACHINE "u370"
X#endif
X#ifdef interdata
X#define MACHINE "interdata"
X#endif
X#ifdef u3b
X#define MACHINE "u3b"
X#endif
X#ifdef u3b5
X#define MACHINE "u3b5"
X#endif
X#ifdef u3b2
X#define MACHINE "u3b2"
X#endif