1 # This is a shell archive. Save it in a file, remove anything before
2 # this line, and then unpack it by entering "sh file". Note, it may
3 # create directories; files and directories will be owned by you and
4 # have default permissions.
6 # This archive contains:
16 sed 's/^X//' >makefile.txt << 'END-of-makefile.txt'
18 X# The redefinition of strchr() and strrchr() are needed for
19 X# Ultrix-32, Unix 4.2 bsd (and maybe some other Unices).
21 XBSDDEFINE = -Dstrchr=index -Dstrrchr=rindex
23 X# On certain systems, such as Unix System III, you may need to define
24 X# $(LINTFLAGS) in the make command line to set system-specific lint flags.
26 X# This Makefile assumes cpp will replace the "standard" preprocessor.
27 X# Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
28 X# LINEFIX is a sed script filter that reinserts #line -- used for testing
29 X# if LINE_PREFIX is set to "". Note that we must stand on our heads to
30 X# match the # and a line had better not begin with $. By the way, what
32 X# LINEFIX = | sed "s/^#/#line/"
34 XCPPDEFINE = -DLINE_PREFIX=\"\"
35 XLINEFIX = | sed "s/^[^ !\"%-~]/&line/"
37 X# Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
38 X# "as compatible as possible" with the standard Unix V7 or Ultrix
39 X# preprocessors. This is needed to rebuild 4.2bsd, for example, as
40 X# the preprocessor is used to modify assembler code, rather than C.
41 X# This is not recommended for current development. OLD_PREPROCESSOR
42 X# forces the following definitions:
43 X# OK_DOLLAR FALSE $ is not allowed in variables
44 X# OK_CONCAT FALSE # cannot concatenate tokens
45 X# COMMENT_INVISIBLE TRUE old-style comment concatenation
46 X# STRING_FORMAL TRUE old-style string expansion
48 XOLDDEFINE = -DOLD_PREPROCESSOR=1
50 X# DEFINES collects all -D arguments for cc and lint:
51 X# Change DEFINES = $(BSDDEFINE) $(CPPDEFINE) $(OLDDEFINE)
52 X# for an old-style preprocessor.
54 X# DEFINES = $(BSDDEFINE) $(CPPDEFINE)
55 XDEFINES = $(CPPDEFINE)
57 XCFLAGS = -O $(DEFINES)
62 XSRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
63 XOBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
65 X $(CC) $(CFLAGS) $(OBJS) -o cpp
68 X# ** Test cpp by preprocessing itself, compiling the result,
69 X# ** repeating the process and diff'ing the result. Note: this
70 X# ** is not a good test of cpp, but a simple verification.
71 X# ** The diff's should not report any changes.
72 X# ** Note that a sed script may be executed for each compile
75 X cpp cpp1.c $(LINEFIX) >old.tmp1.c
76 X cpp cpp2.c $(LINEFIX) >old.tmp2.c
77 X cpp cpp3.c $(LINEFIX) >old.tmp3.c
78 X cpp cpp4.c $(LINEFIX) >old.tmp4.c
79 X cpp cpp5.c $(LINEFIX) >old.tmp5.c
80 X cpp cpp6.c $(LINEFIX) >old.tmp6.c
81 X $(CC) $(CFLAGS) old.tmp[123456].c
82 X a.out cpp1.c >new.tmp1.c
83 X a.out cpp2.c >new.tmp2.c
84 X a.out cpp3.c >new.tmp3.c
85 X a.out cpp4.c >new.tmp4.c
86 X a.out cpp5.c >new.tmp5.c
87 X a.out cpp6.c >new.tmp6.c
88 X diff old.tmp1.c new.tmp1.c
89 X diff old.tmp2.c new.tmp2.c
90 X diff old.tmp3.c new.tmp3.c
91 X diff old.tmp4.c new.tmp4.c
92 X diff old.tmp5.c new.tmp5.c
93 X diff old.tmp6.c new.tmp6.c
94 X rm a.out old.tmp[123456].* new.tmp[123456].*
97 X# A somewhat more extensive test is provided by the "clock"
98 X# program (which is not distributed). Substitute your favorite
99 X# macro-rich program here.
102 X cpp clock.c $(LINEFIX) >temp.cpp.c
103 X cc temp.cpp.c -lcurses -ltermcap -o clock
111 X lint $(LINTFLAGS) $(DEFINES) $(SRCS)
114 X# ** Remove unneeded files
120 X# ** Rebuild the archive files needed to distribute cpp
121 X# ** Uses the Decus C archive utility.
125 X $(CC) $(CFLAGS) archc.c -o archc
128 X $(CC) $(CFLAGS) archx.c -o archx
131 X archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
133 X archc cpp1.c cpp2.c cpp3.c >cpp2.arc
134 X archc cpp4.c cpp5.c cpp6.c >cpp3.arc
137 X# Object module dependencies
140 Xcpp1.o : cpp1.c cpp.h cppdef.h
142 Xcpp2.o : cpp2.c cpp.h cppdef.h
144 Xcpp3.o : cpp3.c cpp.h cppdef.h
146 Xcpp4.o : cpp4.c cpp.h cppdef.h
148 Xcpp5.o : cpp5.c cpp.h cppdef.h
150 Xcpp6.o : cpp6.c cpp.h cppdef.h
155 sed 's/^X//' >readme.txt << 'END-of-readme.txt'
157 XDecus cpp is a public-domain implementation of the C preprocessor.
158 XIt runs on VMS native (Vax C), VMS compatibilty mode (Decus C),
159 XRSX-11M, RSTS/E, P/OS, and RT11, as well as on several varieties
160 Xof Unix, including Ultrix. Decus cpp attempts to implement features
161 Xin the Draft ANSI Standard for the C language. It should be noted,
162 Xhowever, that this standard is under active development: the current
163 Xdraft of the standard explicitly states that "readers are requested
164 Xnot to specify or claim conformance to this draft." Thus readers
165 Xand users of Decus cpp should not assume that it conforms to the
166 Xdraft standard, or that it will conform to the actual C language
169 XThese notes describe how to extract the cpp source files, configure it
170 Xfor your needs, and mention a few design decisions that may be of interest
175 XBecause the primary development of cpp was not on Unix, it
176 Xis distributed using the Decus C archive program (quite similar
177 Xto the archiver published in Kernighan and Plauger's Software
178 XTools). To extract the files from the net.sources distribution,
179 Xsave this message as cpp1.arc and the other two distribution
180 Xfiles as cpp2.arc and cpp3.arc. Then, using your favorite editor,
181 Xlocate the archx.c program, just following the line beginning with
182 X"-h- archx.c" -- the format of the distribution is just:
187 X ... description of cpp
189 X ... archx.c program -- extracts archives
191 X ... archc.c program -- creates archives
193 XCompile archx.c -- it shouldn't require any special editing.
194 XThen run it as follows:
198 XYou do not need to remove mail headers from the saved messages.
200 XYou should then read through cppdef.h to make sure the HOST and
201 XTARGET (and other implementation-specific) definitions are set
202 Xcorrectly for your machine, editing them as needed.
204 XYou may then copy makefile.txt to Makefile, editing it as needed
205 Xfor your particular system. On Unix, cpp should be compiled
206 Xby make without further difficulty. On other operating systems,
207 Xyou should compile the six source modules, linking them together.
208 XNote that, on Decus C based systems, you must extend the default
209 Xstack allocation. The Decus C build utility will create the
210 Xappropriate command file.
214 XThe USENET distribution kit was designed to keep all submissions around
218 X readme.txt This file
219 X cpp.mem Documentation page (see below)
220 X archx.c Archive extraction program
221 X archc.c Archive construction program
222 X cpp.rno Source for cpp.mem (see below)
223 X makefile.txt Unix makefile -- copy to Makefile
224 X cpp.h Main header file (structure def's and globals)
225 X cppdef.h Configuration file (host and target definitions)
228 X cpp1.c Mainline code, documentation master sources
229 X cpp2.c most #control processing
230 X cpp3.c filename stuff and command line parsing
232 X cpp4.c #define processor
233 X cpp5.c #if <expr> processor
234 X cpp6.c Support code (symbol table and I/O routines)
236 XCpp intentionally does not rely on the presence of a full-scale
237 Xmacro preprocessor, it does require the simple parameter substitution
238 Xpreprocessor capabilities of Unix V6 and Decus C. If your C
239 Xlanguage lacks full preprocessing, you should make sure "nomacargs"
240 Xis #define'd in cpp.h. (This is done automatically by the Decus C
243 XThe documentation (manual page) for cpp is included as cpp.mem
244 Xand cpp.rno. Cpp.rno is in Dec Runoff format, built by a Decus C
245 Xutility (getrno) from original source which is embedded in cpp1.c.
246 XTo my knowledge, there is no equivalent program that creates
247 Xthe nroff source appropriate for Unix.
249 XI would be happy to receive fixes to any problems you encounter.
250 XAs I do not maintain distribution kit base-levels, bare-bones
251 Xdiff listings without sufficient context are not very useful.
252 XIt is unlikely that I can find time to help you with other
257 XI received a great deal of help from many people in debugging cpp.
258 XAlan Feuer and Sam Kendall used "state of the art" run-time code
259 Xcheckers to locate several errors. Ed Keiser found problems when
260 Xcpp was used on machines with different int and pointer sizes.
261 XDave Conroy helped with the initial debugging, while Arthur Olsen
262 Xand George Rosenberg found (and solved) several problems in the
263 Xfirst USENET release.
270 sed 's/^X//' >cpp.mem << 'END-of-cpp.mem'
275 X 1.0 C Pre-Processor
285 X NAME: cpp -- C Pre-Processor
289 X cpp [-options] [infile [outfile]]
293 X CPP reads a C source file, expands macros and include
294 X files, and writes an input file for the C compiler. If
295 X no file arguments are given, CPP reads from stdin and
296 X writes to stdout. If one file argument is given, it
297 X will define the input file, while two file arguments
298 X define both input and output files. The file name "-"
299 X is a synonym for stdin or stdout as appropriate.
301 X The following options are supported. Options may be
302 X given in either case.
304 X -C If set, source-file comments are written
305 X to the output file. This allows the
306 X output of CPP to be used as the input to
307 X a program, such as lint, that expects
308 X commands embedded in specially-formatted
311 X -Dname=value Define the name as if the programmer
316 X at the start of the first file. If
317 X "=value" is not given, a value of "1"
320 X On non-unix systems, all alphabetic text
321 X will be forced to upper-case.
323 X -E Always return "success" to the operating
324 X system, even if errors were detected.
325 X Note that some fatal errors, such as a
326 X missing #include file, will terminate
327 X CPP, returning "failure" even if the -E
330 X cpp C Pre-Processor
333 X -Idirectory Add this directory to the list of
334 X directories searched for #include "..."
335 X and #include <...> commands. Note that
336 X there is no space between the "-I" and
337 X the directory string. More than one -I
338 X command is permitted. On non-Unix
339 X systems "directory" is forced to
342 X -N CPP normally predefines some symbols
343 X defining the target computer and
344 X operating system. If -N is specified,
345 X no symbols will be predefined. If -N -N
346 X is specified, the "always present"
347 X symbols, __LINE__, __FILE__, and
348 X __DATE__ are not defined.
350 X -Stext CPP normally assumes that the size of
351 X the target computer's basic variable
352 X types is the same as the size of these
353 X types of the host computer. (This can
354 X be overridden when CPP is compiled,
355 X however.) The -S option allows dynamic
356 X respecification of these values. "text"
357 X is a string of numbers, separated by
358 X commas, that specifies correct sizes.
359 X The sizes must be specified in the exact
362 X char short int long float double
364 X If you specify the option as "-S*text",
365 X pointers to these types will be
366 X specified. -S* takes one additional
367 X argument for pointer to function (e.g.
370 X For example, to specify sizes
371 X appropriate for a PDP-11, you would
378 X Note that all values must be specified.
380 X -Uname Undefine the name as if
384 X were given. On non-Unix systems, "name"
385 X will be forced to upper-case.
387 X cpp C Pre-Processor
390 X -Xnumber Enable debugging code. If no value is
391 X given, a value of 1 will be used. (For
392 X maintenence of CPP only.)
395 X PRE-DEFINED VARIABLES:
397 X When CPP begins processing, the following variables will
398 X have been defined (unless the -N option is specified):
400 X Target computer (as appropriate):
402 X pdp11, vax, M68000 m68000 m68k
404 X Target operating system (as appropriate):
406 X rsx, rt11, vms, unix
408 X Target compiler (as appropriate):
412 X The implementor may add definitions to this list. The
413 X default definitions match the definition of the host
414 X computer, operating system, and C compiler.
416 X The following are always available unless undefined (or
417 X -N was specified twice):
419 X __FILE__ The input (or #include) file being
420 X compiled (as a quoted string).
422 X __LINE__ The line number being compiled.
424 X __DATE__ The date and time of compilation as a
425 X Unix ctime quoted string (the trailing
426 X newline is removed). Thus,
428 X printf("Bug at line %s,", __LINE__);
429 X printf(" source file %s", __FILE__);
430 X printf(" compiled on %s", __DATE__);
433 X DRAFT PROPOSED ANSI STANDARD CONSIDERATIONS:
435 X The current version of the Draft Proposed Standard
436 X explicitly states that "readers are requested not to
437 X specify or claim conformance to this draft." Readers and
438 X users of Decus CPP should not assume that Decus CPP
439 X conforms to the standard, or that it will conform to the
440 X actual C Language Standard.
442 X When CPP is itself compiled, many features of the Draft
443 X Proposed Standard that are incompatible with existing
445 X cpp C Pre-Processor
448 X preprocessors may be disabled. See the comments in
449 X CPP's source for details.
451 X The latest version of the Draft Proposed Standard (as
452 X reflected in Decus CPP) is dated November 12, 1984.
454 X Comments are removed from the input text. The comment
455 X is replaced by a single space character. The -C option
456 X preserves comments, writing them to the output file.
458 X The '$' character is considered to be a letter. This is
459 X a permitted extension.
461 X The following new features of C are processed by CPP:
463 X #elif expression (#else #if)
464 X '\xNNN' (Hexadecimal constant)
466 X '\v' (Ascii Vertical Tab)
467 X #if defined NAME 1 if defined, 0 if not
468 X #if defined (NAME) 1 if defined, 0 if not
469 X #if sizeof (basic type)
471 X 123U, 123LU Unsigned ints and longs.
472 X 12.3L Long double numbers
473 X token#token Token concatenation
474 X #include token Expands to filename
476 X The Draft Proposed Standard has extended C, adding a
477 X constant string concatenation operator, where
481 X is regarded as the single string "foobar". (This does
482 X not affect CPP's processing but does permit a limited
483 X form of macro argument substitution into strings as will
486 X The Standard Committee plans to add token concatenation
487 X to #define command lines. One suggested implementation
488 X is as follows: the sequence "Token1#Token2" is treated
489 X as if the programmer wrote "Token1Token2". This could
490 X be used as follows:
493 X #define ATLINE foo#__LINE__
495 X ATLINE would be defined as foo123.
497 X Note that "Token2" must either have the format of an
498 X identifier or be a string of digits. Thus, the string
500 X #define ATLINE foo#1x3
502 X cpp C Pre-Processor
505 X generates two tokens: "foo1" and "x3".
507 X If the tokens T1 and T2 are concatenated into T3, this
508 X implementation operates as follows:
510 X 1. Expand T1 if it is a macro.
511 X 2. Expand T2 if it is a macro.
512 X 3. Join the tokens, forming T3.
513 X 4. Expand T3 if it is a macro.
515 X A macro formal parameter will be substituted into a
516 X string or character constant if it is the only component
519 X #define VECSIZE 123
520 X #define vprint(name, size) \
521 X printf("name" "[" "size" "] = {\n")
522 X ... vprint(vector, VECSIZE);
524 X expands (effectively) to
526 X vprint("vector[123] = {\n");
528 X Note that this will be useful if your C compiler
529 X supports the new string concatenation operation noted
530 X above. As implemented here, if you write
532 X #define string(arg) "arg"
533 X ... string("foo") ...
535 X This implementation generates "foo", rather than the
536 X strictly correct ""foo"" (which will probably generate
537 X an error message). This is, strictly speaking, an error
538 X in CPP and may be removed from future releases.
542 X Many. CPP prints warning or error messages if you try
543 X to use multiple-byte character constants
544 X (non-transportable) if you #undef a symbol that was not
545 X defined, or if your program has potentially nested
554 X The #if expression processor uses signed integers only.
555 X I.e, #if 0xFFFFu < 0 may be TRUE.
559 sed 's/^X//' >cpp.h << 'END-of-cpp.h'
562 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
564 X * In general, definitions in this file should not be changed.
573 X * This is predefined in Decus C
575 X#define EOS '\0' /* End of string */
577 X#define EOF_CHAR 0 /* Returned by get() on eof */
578 X#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
579 X#define DEF_NOARGS (-1) /* #define foo vs #define foo() */
582 X * The following may need to change if the host system doesn't use ASCII.
584 X#define DEF_MAGIC 0x1D /* Magic for #defines */
585 X#define TOK_SEP 0x1E /* Token concatenation delim. */
586 X#define COM_SEP 0x1F /* Magic comment separator */
589 X * Note -- in Ascii, the following will map macro formals onto DEL + the
590 X * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
591 X * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
592 X * value is reserved for string substitution.
595 X#define MAC_PARM 0x7F /* Macro formals start here */
597 X assertion fails -- PAR_MAC isn't less than 33
599 X#define LASTPARM (PAR_MAC - 1)
602 X * Character type codes.
605 X#define INV 0 /* Invalid, must be zero */
606 X#define OP_EOE INV /* End of expression */
607 X#define DIG 1 /* Digit */
608 X#define LET 2 /* Identifier start */
609 X#define FIRST_BINOP OP_ADD
617 X#define OP_AND 10 /* &, not && */
618 X#define OP_OR 11 /* |, not || */
626 X#define OP_ANA 19 /* && */
627 X#define OP_ORO 20 /* || */
628 X#define OP_QUE 21 /* ? */
629 X#define OP_COL 22 /* : */
630 X#define OP_CMA 23 /* , (relevant?) */
631 X#define LAST_BINOP OP_CMA /* Last binary operand */
633 X * The following are unary.
635 X#define FIRST_UNOP OP_PLU /* First Unary operand */
636 X#define OP_PLU 24 /* + (draft ANSI standard) */
637 X#define OP_NEG 25 /* - */
638 X#define OP_COM 26 /* ~ */
639 X#define OP_NOT 27 /* ! */
640 X#define LAST_UNOP OP_NOT
641 X#define OP_LPA 28 /* ( */
642 X#define OP_RPA 29 /* ) */
643 X#define OP_END 30 /* End of expression marker */
644 X#define OP_MAX (OP_END + 1) /* Number of operators */
645 X#define OP_FAIL (OP_END + 1) /* For error returns */
648 X * The following are for lexical scanning only.
651 X#define QUO 65 /* Both flavors of quotation */
652 X#define DOT 66 /* . might start a number */
653 X#define SPA 67 /* Space and tab */
654 X#define BSH 68 /* Just a backslash */
655 X#define END 69 /* EOF */
658 X * These bits are set in ifstack[]
660 X#define WAS_COMPILING 1 /* TRUE if compile set at entry */
661 X#define ELSE_SEEN 2 /* TRUE when #else processed */
662 X#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
665 X * Define bits for the basic types and their adjectives
675 X#define T_UNSIGNED 128
676 X#define T_PTR 256 /* Pointer */
677 X#define T_FPTR 512 /* Pointer to functions */
680 X * The DEFBUF structure stores information about #defined
681 X * macros. Note that the defbuf->repl information is always
682 X * in malloc storage.
685 Xtypedef struct defbuf {
686 X struct defbuf *link; /* Next define in chain */
687 X char *repl; /* -> replacement */
688 X int hash; /* Symbol table hash */
689 X int nargs; /* For define(args) */
690 X char name[1]; /* #define name */
694 X * The FILEINFO structure stores information about open files
695 X * and macros being expanded.
698 Xtypedef struct fileinfo {
699 X char *bptr; /* Buffer pointer */
700 X int line; /* for include or macro */
701 X FILE *fp; /* File if non-null */
702 X struct fileinfo *parent; /* Link to includer */
703 X char *filename; /* File/macro name */
704 X char *progname; /* From #line statement */
705 X unsigned int unrecur; /* For macro recursion */
706 X char buffer[1]; /* current input line */
710 X * The SIZES structure is used to store the values for #if sizeof
713 Xtypedef struct sizes {
714 X short bits; /* If this bit is set, */
715 X short size; /* this is the datum size value */
716 X short psize; /* this is the pointer size */
719 X * nomacarg is a built-in #define on Decus C.
723 X#define cput output /* cput concatenates tokens */
725 X#if COMMENT_INVISIBLE
726 X#define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
728 X#define cput(c) { if (c != TOK_SEP) putchar(c); }
733 X#define streq(s1, s2) (strcmp(s1, s2) == 0)
737 X * Error codes. VMS uses system definitions.
738 X * Decus C codes are defined in stdio.h.
739 X * Others are cooked to order.
745 X#define IO_NORMAL (SS$_NORMAL | STS$M_INHIB_MSG)
746 X#define IO_ERROR SS$_ABORT
749 X * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
762 Xextern int line; /* Current line number */
763 Xextern int wrongline; /* Force #line to cc pass 1 */
764 Xextern char type[]; /* Character classifier */
765 Xextern char token[IDMAX + 1]; /* Current input token */
766 Xextern int instring; /* TRUE if scanning string */
767 Xextern int inmacro; /* TRUE if scanning #define */
768 Xextern int errors; /* Error counter */
769 Xextern int recursion; /* Macro depth counter */
770 Xextern char ifstack[BLK_NEST]; /* #if information */
771 X#define compiling ifstack[0]
772 Xextern char *ifptr; /* -> current ifstack item */
773 Xextern char *incdir[NINCLUDE]; /* -i directories */
774 Xextern char **incend; /* -> active end of incdir */
775 Xextern int cflag; /* -C option (keep comments) */
776 Xextern int eflag; /* -E option (ignore errors) */
777 Xextern int nflag; /* -N option (no pre-defines) */
778 Xextern int rec_recover; /* unwind recursive macros */
779 Xextern char *preset[]; /* Standard predefined symbols */
780 Xextern char *magic[]; /* Magic predefined symbols */
781 Xextern FILEINFO *infile; /* Current input file */
782 Xextern char work[NWORK + 1]; /* #define scratch */
783 Xextern char *workp; /* Free space in work */
785 Xextern int debug; /* Debug level */
787 Xextern int keepcomments; /* Don't remove comments if set */
788 Xextern SIZES size_table[]; /* For #if sizeof sizes */
789 Xextern char *getmem(); /* Get memory or die. */
790 Xextern DEFBUF *lookid(); /* Look for a #define'd thing */
791 Xextern DEFBUF *defendel(); /* Symbol table enter/delete */
792 Xextern char *savestring(); /* Stuff string in malloc mem. */
793 Xextern char *strcpy();
794 Xextern char *strcat();
795 Xextern char *strrchr();
796 Xextern char *strchr();
798 X/* extern char *sprintf(); /* Lint needs this */
801 sed 's/^X//' >cppdef.h << 'END-of-cppdef.h'
803 X * S y s t e m D e p e n d e n t
804 X * D e f i n i t i o n s f o r C P P
806 X * Definitions in this file may be edited to configure CPP for particular
807 X * host operating systems and target configurations.
809 X * NOTE: cpp assumes it is compiled by a compiler that supports macros
810 X * with arguments. If this is not the case (as for Decus C), #define
811 X * nomacarg -- and provide function equivalents for all macros.
813 X * cpp also assumes the host and target implement the Ascii character set.
814 X * If this is not the case, you will have to do some editing here and there.
818 X * This redundant definition of TRUE and FALSE works around
819 X * a limitation of Decus C.
827 X * Define the HOST operating system. This is needed so that
828 X * cpp can use appropriate filename conventions.
830 X#define SYS_UNKNOWN 0
835 X#define SYS_LATTICE 5
845 X#define HOST SYS_UNIX
848 X#define HOST SYS_VMS
851 X#define HOST SYS_RSX
854 X#define HOST SYS_RT11
857 X#define HOST SYS_DMERT
860 X#define HOST SYS_GCOS
863 X#define HOST SYS_IBM
869 X#define HOST SYS_TSS
881 X#define HOST SYS_UNKNOWN
885 X * We assume that the target is the same as the host system
892 X * In order to predefine machine-dependent constants,
893 X * several strings are defined here:
895 X * MACHINE defines the target cpu (by name)
896 X * SYSTEM defines the target operating system
897 X * COMPILER defines the target compiler
899 X * The above may be #defined as "" if they are not wanted.
900 X * They should not be #defined as NULL.
902 X * LINE_PREFIX defines the # output line prefix, if not "line"
903 X * This should be defined as "" if cpp is to replace
904 X * the "standard" C pre-processor.
906 X * FILE_LOCAL marks functions which are referenced only in the
907 X * file they reside. Some C compilers allow these
908 X * to be marked "static" even though they are referenced
909 X * by "extern" statements elsewhere.
911 X * OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character
912 X * in identifiers (default), or zero if $ is invalid.
915 X * OK_CONCAT Should be set TRUE if # may be used to concatenate
916 X * tokens in macros (per the Ansi Draft Standard) or
917 X * FALSE for old-style # processing (needed if cpp is
918 X * to process assembler source code).
920 X * OK_DATE Predefines the compilation date if set TRUE.
921 X * Not permitted by the Nov. 12, 1984 Draft Standard.
923 X * S_CHAR etc. Define the sizeof the basic TARGET machine word types.
924 X * By default, sizes are set to the values for the HOST
925 X * computer. If this is inappropriate, see the code in
926 X * cpp3.c for details on what to change. Also, if you
927 X * have a machine where sizeof (signed int) differs from
928 X * sizeof (unsigned int), you will have to edit code and
929 X * tables in cpp3.c (and extend the -S option definition.)
931 X * CPP_LIBRARY May be defined if you have a site-specific include directory
932 X * which is to be searched *before* the operating-system
933 X * specific directories.
936 X#if TARGET == SYS_LATTICE
938 X * We assume the operating system is pcdos for the IBM-PC.
939 X * We also assume the small model (just like the PDP-11)
941 X#define MACHINE "i8086"
942 X#define SYSTEM "pcdos"
945 X#if TARGET == SYS_ONYX
946 X#define MACHINE "z8000"
947 X#define SYSTEM "unix"
950 X#if TARGET == SYS_VMS
951 X#define MACHINE "vax"
952 X#define SYSTEM "vms"
953 X#define COMPILER "vax11c"
956 X#if TARGET == SYS_RSX
957 X#define MACHINE "pdp11"
958 X#define SYSTEM "rsx"
959 X#define COMPILER "decus"
962 X#if TARGET == SYS_RT11
963 X#define MACHINE "pdp11"
964 X#define SYSTEM "rt11"
965 X#define COMPILER "decus"
968 X#if TARGET == SYS_68000
970 X * All three machine designators have been seen in various systems.
971 X * Warning -- compilers differ as to sizeof (int). cpp3 assumes that
972 X * sizeof (int) == 2
974 X#define MACHINE "M68000", "m68000", "m68k"
975 X#define SYSTEM "unix"
978 X#if TARGET == SYS_UNIX
979 X#define SYSTEM "unix"
981 X#define MACHINE "pdp11"
984 X#define MACHINE "vax"
987 X#define MACHINE "u370"
990 X#define MACHINE "interdata"
993 X#define MACHINE "u3b"
996 X#define MACHINE "u3b5"
999 X#define MACHINE "u3b2"
1002 X#define MACHINE "u3b20d"
1012 X#define MSG_PREFIX "cpp: "
1015 X#ifndef LINE_PREFIX
1017 X#define LINE_PREFIX ""
1019 X#define LINE_PREFIX "line"
1024 X * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT,
1025 X * COMMENT_INVISIBLE, and STRING_FORMAL to values appropriate for
1026 X * an old-style preprocessor.
1029 X#ifndef OLD_PREPROCESSOR
1030 X#define OLD_PREPROCESSOR FALSE
1033 X#if OLD_PREPROCESSOR
1034 X#define OK_DOLLAR FALSE
1035 X#define OK_CONCAT FALSE
1036 X#define COMMENT_INVISIBLE TRUE
1037 X#define STRING_FORMAL TRUE
1041 X * RECURSION_LIMIT may be set to -1 to disable the macro recursion test.
1043 X#ifndef RECURSION_LIMIT
1044 X#define RECURSION_LIMIT 1000
1048 X * BITS_CHAR may be defined to set the number of bits per character.
1049 X * it is needed only for multi-byte character constants.
1052 X#define BITS_CHAR 8
1056 X * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
1057 X * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
1058 X * It is set FALSE on machines (such as the PDP-11 and Vax-11)
1059 X * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
1060 X * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
1063 X#define BIG_ENDIAN FALSE
1067 X * COMMENT_INVISIBLE may be defined to allow "old-style" comment
1068 X * processing, whereby the comment becomes a zero-length token
1069 X * delimiter. This permitted tokens to be concatenated in macro
1070 X * expansions. This was removed from the Draft Ansi Standard.
1072 X#ifndef COMMENT_INVISIBLE
1073 X#define COMMENT_INVISIBLE FALSE
1077 X * STRING_FORMAL may be defined to allow recognition of macro parameters
1078 X * anywhere in replacement strings. This was removed from the Draft Ansi
1079 X * Standard and a limited recognition capability added.
1081 X#ifndef STRING_FORMAL
1082 X#define STRING_FORMAL FALSE
1086 X * OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
1087 X * This is a permitted extension to the Ansi Standard and is required
1088 X * for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is
1089 X * used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR
1090 X * sets OK_DOLLAR FALSE for that reason.
1093 X#define OK_DOLLAR TRUE
1097 X * OK_CONCAT enables (one possible implementation of) token concatenation.
1098 X * If cpp is used to preprocess Unix assembler source, this should be
1099 X * set FALSE as the concatenation character, #, is used by the assembler.
1102 X#define OK_CONCAT TRUE
1106 X * OK_DATE may be enabled to predefine today's date as a string
1107 X * at the start of each compilation. This is apparently not permitted
1108 X * by the Draft Ansi Standard.
1111 X#define OK_DATE TRUE
1115 X * Some common definitions.
1119 X#define DEBUG FALSE
1123 X * The following definitions are used to allocate memory for
1124 X * work buffers. In general, they should not be modified
1125 X * by implementors.
1127 X * PAR_MAC The maximum number of #define parameters (31 per Standard)
1128 X * Note: we need another one for strings.
1129 X * IDMAX The longest identifier, 31 per Ansi Standard
1130 X * NBUFF Input buffer size
1131 X * NWORK Work buffer size -- the longest macro
1132 X * must fit here after expansion.
1133 X * NEXP The nesting depth of #if expressions
1134 X * NINCLUDE The number of directories that may be specified
1135 X * on a per-system basis, or by the -I option.
1136 X * BLK_NEST The number of nested #if's permitted.
1140 X#define PAR_MAC (31 + 1)
1145 X#define NPARMWORK (NWORK * 2)
1146 X#define BLK_NEST 32
1149 X * Some special constants. These may need to be changed if cpp
1150 X * is ported to a wierd machine.
1152 X * NOTE: if cpp is run on a non-ascii machine, ALERT and VT may
1153 X * need to be changed. They are used to implement the proposed
1154 X * ANSI standard C control characters '\a' and '\v' only.
1155 X * DEL is used to tag macro tokens to prevent #define foo foo
1156 X * from looping. Note that we don't try to prevent more elaborate
1157 X * #define loops from occurring.
1161 X#define ALERT '\007' /* '\a' is "Bell" */
1165 X#define VT '\013' /* Vertical Tab CTRL/K */
1171 X#define FILE_LOCAL static
1174 X#define FILE_LOCAL static
1176 X#define FILE_LOCAL /* Others are global */
1183 sed 's/^X//' >cpp2.c << 'END-of-cpp2.c'
1187 X * Process #control lines
1190 X * 13-Nov-84 MM Split from cpp1.c
1195 X#include "cppdef.h"
1197 X#if HOST == SYS_VMS
1199 X * Include the rms stuff. (We can't just include rms.h as it uses the
1200 X * VaxC-specific library include syntax that Decus CPP doesn't support.
1201 X * By including things by hand, we can CPP ourself.)
1206 X#include <rmsdef.h>
1210 X * Generate (by hand-inspection) a set of unique values for each control
1211 X * operator. Note that this is not guaranteed to work for non-Ascii
1212 X * machines. CPP won't compile if there are hash conflicts.
1215 X#define L_assert ('a' + ('s' << 1))
1216 X#define L_define ('d' + ('f' << 1))
1217 X#define L_elif ('e' + ('i' << 1))
1218 X#define L_else ('e' + ('s' << 1))
1219 X#define L_endif ('e' + ('d' << 1))
1220 X#define L_ident ('i' + ('e' << 1))
1221 X#define L_if ('i' + (EOS << 1))
1222 X#define L_ifdef ('i' + ('d' << 1))
1223 X#define L_ifndef ('i' + ('n' << 1))
1224 X#define L_include ('i' + ('c' << 1))
1225 X#define L_line ('l' + ('n' << 1))
1226 X#define L_nogood (EOS + (EOS << 1)) /* To catch #i */
1227 X#define L_pragma ('p' + ('a' << 1))
1228 X#define L_sccs ('s' + ('c' << 1))
1229 X#define L_undef ('u' + ('d' << 1))
1231 X#define L_debug ('d' + ('b' << 1)) /* #debug */
1232 X#define L_nodebug ('n' + ('d' << 1)) /* #nodebug */
1237 Xint counter; /* Pending newline counter */
1239 X * Process #control lines. Simple commands are processed inline,
1240 X * while complex commands have their own subroutines.
1242 X * The counter is used to force out a newline before #line, and
1243 X * #pragma commands. This prevents these commands from ending up at
1244 X * the end of the previous line if cpp is invoked with the -C option.
1248 X register char *tp;
1249 X register int hash;
1253 X if (c == '\n' || c == EOF_CHAR)
1254 X return (counter + 1);
1256 X scanid(c); /* Get #word to token[] */
1258 X unget(); /* Hack -- allow #123 as a */
1259 X strcpy(token, "line"); /* synonym for #line 123 */
1261 X hash = (token[1] == EOS) ? L_nogood : (token[0] + (token[2] << 1));
1263 X case L_assert: tp = "assert"; break;
1264 X case L_define: tp = "define"; break;
1265 X case L_elif: tp = "elif"; break;
1266 X case L_else: tp = "else"; break;
1267 X case L_endif: tp = "endif"; break;
1268 X case L_ident: tp = "ident"; break;
1269 X case L_if: tp = "if"; break;
1270 X case L_ifdef: tp = "ifdef"; break;
1271 X case L_ifndef: tp = "ifndef"; break;
1272 X case L_include: tp = "include"; break;
1273 X case L_line: tp = "line"; break;
1274 X case L_pragma: tp = "pragma"; break;
1275 X case L_sccs: tp = "sccs"; break;
1276 X case L_undef: tp = "undef"; break;
1278 X case L_debug: tp = "debug"; break;
1279 X case L_nodebug: tp = "nodebug"; break;
1281 X default: hash = L_nogood;
1282 X case L_nogood: tp = ""; break;
1284 X if (!streq(tp, token))
1287 X * hash is set to a unique value corresponding to the
1288 X * control keyword (or L_nogood if we think it's nonsense).
1290 X if (infile->fp == NULL)
1291 X cwarn("Control line \"%s\" within macro expansion", token);
1292 X if (!compiling) { /* Not compiling now */
1294 X case L_if: /* These can't turn */
1295 X case L_ifdef: /* compilation on, but */
1296 X case L_ifndef: /* we must nest #if's */
1297 X if (++ifptr >= &ifstack[BLK_NEST])
1299 X *ifptr = 0; /* !WAS_COMPILING */
1300 X case L_line: /* Many */
1302 X * Are pragma's always processed?
1306 X case L_pragma: /* options */
1307 X case L_include: /* are uninteresting */
1308 X case L_define: /* if we */
1309 X case L_undef: /* aren't */
1310 X case L_assert: /* compiling. */
1311 Xdump_line: skipnl(); /* Ignore rest of line */
1312 X return (counter + 1);
1316 X * Make sure that #line and #pragma are output on a fresh line.
1318 X if (counter > 0 && (hash == L_line || hash == L_pragma)) {
1325 X * Parse the line to update the line number and "progname"
1326 X * field and line number for the next input line.
1327 X * Set wrongline to force it out later.
1330 X workp = work; /* Save name in work */
1331 X while (c != '\n' && c != EOF_CHAR) {
1338 X * Split #line argument into <line-number> and <name>
1339 X * We subtract 1 as we want the number of the next line.
1341 X line = atoi(work) - 1; /* Reset line number */
1342 X for (tp = work; isdigit(*tp) || type[*tp] == SPA; tp++)
1343 X ; /* Skip over digits */
1344 X if (*tp != EOS) { /* Got a filename, so: */
1345 X if (*tp == '"' && (ep = strrchr(tp + 1, '"')) != NULL) {
1346 X tp++; /* Skip over left quote */
1347 X *ep = EOS; /* And ignore right one */
1349 X if (infile->progname != NULL) /* Give up the old name */
1350 X free(infile->progname); /* if it's allocated. */
1351 X infile->progname = savestring(tp);
1353 X wrongline = TRUE; /* Force output later */
1369 X if (ifptr == &ifstack[0])
1371 X else if ((*ifptr & ELSE_SEEN) != 0)
1372 X goto else_seen_err;
1373 X *ifptr |= ELSE_SEEN;
1374 X if ((*ifptr & WAS_COMPILING) != 0) {
1375 X if (compiling || (*ifptr & TRUE_SEEN) != 0)
1376 X compiling = FALSE;
1384 X if (ifptr == &ifstack[0])
1386 X else if ((*ifptr & ELSE_SEEN) != 0) {
1387 Xelse_seen_err: cerror("#%s may not follow #else", token);
1390 X if ((*ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING) {
1391 X compiling = FALSE; /* Done compiling stuff */
1392 X goto dump_line; /* Skip this clause */
1400 X if (++ifptr >= &ifstack[BLK_NEST])
1401 Xif_nest_err: cfatal("Too many nested #%s statements", token);
1402 X *ifptr = WAS_COMPILING;
1407 X if (ifptr == &ifstack[0]) {
1408 Xnest_err: cerror("#%s must be in an #if", token);
1411 X if (!compiling && (*ifptr & WAS_COMPILING) != 0)
1413 X compiling = ((*ifptr & WAS_COMPILING) != 0);
1419 X cerror("Preprocessor assertion failure", NULLST);
1429 X * #pragma is provided to pass "options" to later
1430 X * passes of the compiler. cpp doesn't have any yet.
1432 X printf("#pragma ");
1433 X while ((c = get()) != '\n' && c != EOF_CHAR)
1441 X dumpdef("debug set on");
1452 X * Undefined #control keyword.
1453 X * Note: the correct behavior may be to warn and
1454 X * pass the line to a subsequent compiler pass.
1455 X * This would allow #asm or similar extensions.
1457 X cerror("Illegal # command \"%s\"", token);
1460 X if (hash != L_include) {
1461 X#if OLD_PREPROCESSOR || !VERBOSE
1463 X * Ignore the rest of the #control line so you can write
1467 X goto dump_line; /* Take common exit */
1469 X if (skipws() != '\n') {
1470 X cwarn("Unexpected text in #control line ignored", NULLST);
1475 X return (counter + 1);
1482 X * Process an #if, #ifdef, or #ifndef. The latter two are straightforward,
1483 X * while #if needs a subroutine of its own to evaluate the expression.
1485 X * doif() is called only if compiling is TRUE. If false, compilation
1486 X * is always supressed, so we don't need to evaluate anything. This
1487 X * supresses unnecessary warnings.
1491 X register int found;
1493 X if ((c = skipws()) == '\n' || c == EOF_CHAR) {
1497 X if (hash == L_if) {
1499 X found = (eval() != 0); /* Evaluate expr, != 0 is TRUE */
1500 X hash = L_ifdef; /* #if is now like #ifdef */
1503 X if (type[c] != LET) /* Next non-blank isn't letter */
1504 X goto badif; /* ... is an error */
1505 X found = (lookid(c) != NULL); /* Look for it in symbol table */
1507 X if (found == (hash == L_ifdef)) {
1509 X *ifptr |= TRUE_SEEN;
1512 X compiling = FALSE;
1516 Xbadif: cerror("#if, #ifdef, or #ifndef without an argument", NULLST);
1517 X#if !OLD_PREPROCESSOR
1518 X skipnl(); /* Prevent an extra */
1519 X unget(); /* Error message */
1527 X * Process the #include control line.
1528 X * There are three variations:
1529 X * #include "file" search somewhere relative to the
1530 X * current source file, if not found,
1531 X * treat as #include <file>.
1532 X * #include <file> Search in an implementation-dependent
1534 X * #include token Expand the token, it must be one of
1535 X * "file" or <file>, process as such.
1537 X * Note: the November 12 draft forbids '>' in the #include <file> format.
1538 X * This restriction is unnecessary and not implemented.
1542 X register int delim;
1543 X#if HOST == SYS_VMS
1544 X char def_filename[NAM$C_MAXRSS + 1];
1547 X delim = macroid(skipws());
1548 X if (delim != '<' && delim != '"')
1553 X instring = TRUE; /* Accept all characters */
1554 X while ((c = get()) != '\n' && c != delim && c != EOF_CHAR)
1555 X save(c); /* Put it away. */
1558 X * The draft is unclear if the following should be done.
1561 X while (--workp >= work && (type[*workp] == SPA))
1562 X ; /* Trim blanks from filename */
1565 X * if (*workp != delim)
1568 X *(workp + 1) = EOS; /* Terminate filename */
1570 X#if HOST == SYS_VMS
1572 X * Assume the default .h filetype.
1574 X if (!vmsparse(work, ".H", def_filename)) {
1575 X perror(work); /* Oops. */
1578 X else if (openinclude(def_filename, (delim == '"')))
1581 X if (openinclude(work, (delim == '"')))
1585 X * No sense continuing if #include file isn't there.
1587 X cfatal("Cannot open include file \"%s\"", work);
1589 Xincerr: cerror("#include syntax error", NULLST);
1594 Xopeninclude(filename, searchlocal)
1595 Xchar *filename; /* Input file name */
1596 Xint searchlocal; /* TRUE if #include "file" */
1598 X * Actually open an include file. This routine is only called from
1599 X * doinclude() above, but was written as a separate subroutine for
1600 X * programmer convenience. It searches the list of directories
1601 X * and actually opens the file, linking it into the list of
1602 X * active files. Returns TRUE if the file was opened, FALSE
1603 X * if openinclude() fails. No error message is printed.
1606 X register char **incptr;
1607 X#if HOST == SYS_VMS
1608 X#if NWORK < (NAM$C_MAXRSS + 1)
1609 X << error, NWORK isn't greater than NAM$C_MAXRSS >>
1612 X char tmpname[NWORK]; /* Filename work area */
1614 X if (searchlocal) {
1616 X * Look in local directory first
1618 X#if HOST == SYS_UNIX
1620 X * Try to open filename relative to the directory of the current
1621 X * source file (as opposed to the current directory). (ARF, SCK).
1623 X if (filename[0] != '/'
1624 X && hasdirectory(infile->filename, tmpname))
1625 X strcat(tmpname, filename);
1627 X strcpy(tmpname, filename);
1630 X if (!hasdirectory(filename, tmpname)
1631 X && hasdirectory(infile->filename, tmpname))
1632 X strcat(tmpname, filename);
1634 X strcpy(tmpname, filename);
1637 X if (openfile(tmpname))
1641 X * Look in any directories specified by -I command line
1642 X * arguments, then in the builtin search list.
1644 X for (incptr = incdir; incptr < incend; incptr++) {
1645 X if (strlen(*incptr) + strlen(filename) >= (NWORK - 1))
1646 X cfatal("Filename work buffer overflow", NULLST);
1648 X#if HOST == SYS_UNIX
1649 X if (filename[0] == '/')
1650 X strcpy(tmpname, filename);
1652 X sprintf(tmpname, "%s/%s", *incptr, filename);
1655 X if (!hasdirectory(filename, tmpname))
1656 X sprintf(tmpname, "%s%s", *incptr, filename);
1658 X if (openfile(tmpname))
1666 Xhasdirectory(source, result)
1667 Xchar *source; /* Directory to examine */
1668 Xchar *result; /* Put directory stuff here */
1670 X * If a device or directory is found in the source filename string, the
1671 X * node/device/directory part of the string is copied to result and
1672 X * hasdirectory returns TRUE. Else, nothing is copied and it returns FALSE.
1675 X#if HOST == SYS_UNIX
1676 X register char *tp;
1678 X if ((tp = strrchr(source, '/')) == NULL)
1681 X strncpy(result, source, tp - source + 1);
1682 X result[tp - source + 1] = EOS;
1686 X#if HOST == SYS_VMS
1687 X if (vmsparse(source, NULLST, result)
1688 X && result[0] != EOS)
1695 X * Random DEC operating system (RSX, RT11, RSTS/E)
1697 X register char *tp;
1699 X if ((tp = strrchr(source, ']')) == NULL
1700 X && (tp = strrchr(source, ':')) == NULL)
1703 X strncpy(result, source, tp - source + 1);
1704 X result[tp - source + 1] = EOS;
1711 X#if HOST == SYS_VMS
1714 X * EXP_DEV is set if a device was specified, EXP_DIR if a directory
1715 X * is specified. (Both set indicate a file-logical, but EXP_DEV
1716 X * would be set by itself if you are reading, say, SYS$INPUT:)
1718 X#define DEVDIR (NAM$M_EXP_DEV | NAM$M_EXP_DIR)
1721 Xvmsparse(source, defstring, result)
1723 Xchar *defstring; /* non-NULL -> default string. */
1724 Xchar *result; /* Size is at least NAM$C_MAXRSS + 1 */
1726 X * Parse the source string, applying the default (properly, using
1727 X * the system parse routine), storing it in result.
1728 X * TRUE if it parsed, FALSE on error.
1730 X * If defstring is NULL, there are no defaults and result gets
1731 X * (just) the node::[directory] part of the string (possibly "")
1734 X struct FAB fab = cc$rms_fab; /* File access block */
1735 X struct NAM nam = cc$rms_nam; /* File name block */
1736 X char fullname[NAM$C_MAXRSS + 1];
1737 X register char *rp; /* Result pointer */
1739 X fab.fab$l_nam = &nam; /* fab -> nam */
1740 X fab.fab$l_fna = source; /* Source filename */
1741 X fab.fab$b_fns = strlen(source); /* Size of source */
1742 X fab.fab$l_dna = defstring; /* Default string */
1743 X if (defstring != NULLST)
1744 X fab.fab$b_dns = strlen(defstring); /* Size of default */
1745 X nam.nam$l_esa = fullname; /* Expanded filename */
1746 X nam.nam$b_ess = NAM$C_MAXRSS; /* Expanded name size */
1747 X if (sys$parse(&fab) == RMS$_NORMAL) { /* Parse away */
1748 X fullname[nam.nam$b_esl] = EOS; /* Terminate string */
1749 X result[0] = EOS; /* Just in case */
1752 X * Remove stuff added implicitly, accepting node names and
1753 X * dev:[directory] strings (but not process-permanent files).
1755 X if ((nam.nam$l_fnb & NAM$M_PPF) == 0) {
1756 X if ((nam.nam$l_fnb & NAM$M_NODE) != 0) {
1757 X strncpy(result, nam.nam$l_node, nam.nam$b_node);
1758 X rp += nam.nam$b_node;
1761 X if ((nam.nam$l_fnb & DEVDIR) == DEVDIR) {
1762 X strncpy(rp, nam.nam$l_dev, nam.nam$b_dev + nam.nam$b_dir);
1763 X rp += nam.nam$b_dev + nam.nam$b_dir;
1767 X if (defstring != NULLST) {
1768 X strncpy(rp, nam.nam$l_name, nam.nam$b_name + nam.nam$b_type);
1769 X rp += nam.nam$b_name + nam.nam$b_type;
1771 X if ((nam.nam$l_fnb & NAM$M_EXP_VER) != 0) {
1772 X strncpy(rp, nam.nam$l_ver, nam.nam$b_ver);
1773 X rp[nam.nam$b_ver] = EOS;