home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume1 / cpp / part1 next >
Encoding:
Internet Message Format  |  1986-11-30  |  57.5 KB

  1. From: decvax!minow
  2. Date: Tue, 8 Jan 85 00:05:20 est
  3. Subject: cpp1.arc
  4.  
  5. -h- readme.txt    Mon Jan  7 23:59:27 1985    readme.txt
  6.  
  7. Decus cpp is a public-domain implementation of the C preprocessor.
  8. It runs on VMS native (Vax C), VMS compatibilty mode (Decus C),
  9. RSX-11M, RSTS/E, P/OS, and RT11, as well as on several varieties
  10. of Unix, including Ultrix.  Decus cpp attempts to implement features
  11. in the Draft ANSI Standard for the C language.  It should be noted,
  12. however, that this standard is under active development:  the current
  13. draft of the standard explicitly states that "readers are requested
  14. not to specify or claim conformance to this draft."  Thus readers
  15. and users of Decus cpp should not assume that it conforms to the
  16. draft standard, or that it will conform to the actual C language
  17. standard.
  18.  
  19. These notes describe how to extract the cpp source files, configure it
  20. for your needs, and mention a few design decisions that may be of interest
  21. to maintainers.
  22.  
  23.             Installation
  24.  
  25. Because the primary development of cpp was not on Unix, it
  26. is distributed using the Decus C archive program (quite similar
  27. to the archiver published in Kernighan and Plauger's Software
  28. Tools).  To extract the files from the net.sources distribution,
  29. save this message as cpp1.arc and the other two distribution
  30. files as cpp2.arc and cpp3.arc.  Then, using your favorite editor,
  31. locate the archx.c program, just following the line beginning with
  32. "-h- archx.c" -- the format of the distribution is just:
  33.  
  34.     -h- readme.txt
  35.       ... this file
  36.     -h- cpp.mem
  37.       ... description of cpp
  38.     -h- archx.c
  39.       ... archx.c program -- extracts archives
  40.     -h- archc.c
  41.       ... archc.c program -- creates archives
  42.  
  43. Compile archx.c -- it shouldn't require any special editing.
  44. Then run it as follows:
  45.  
  46.     archx *.arc
  47.  
  48. You do not need to remove mail headers from the saved messages.
  49.  
  50. You should then read through cppdef.h to make sure the HOST and
  51. TARGET (and other implementation-specific) definitions are set
  52. correctly for your machine, editing them as needed.
  53.  
  54. You may then copy makefile.txt to Makefile, editing it as needed
  55. for your particular system.  On Unix, cpp should be compiled
  56. by make without further difficulty.  On other operating systems,
  57. you should compile the six source modules, linking them together.
  58. Note that, on Decus C based systems, you must extend the default
  59. stack allocation.  The Decus C build utility will create the
  60. appropriate command file.
  61.  
  62.             Support Notes
  63.  
  64. The USENET distribution kit was designed to keep all submissions around
  65. 50,000 bytes:
  66.  
  67. cpp1.arc:
  68.     readme.txt    This file
  69.     cpp.mem        Documentation page (see below)
  70.     archx.c        Archive extraction program
  71.     archc.c        Archive construction program
  72.     cpp.rno        Source for cpp.mem (see below)
  73.     makefile.txt    Unix makefile -- copy to Makefile
  74.     cpp.h        Main header file (structure def's and globals)
  75.     cppdef.h    Configuration file (host and target definitions)
  76.  
  77. cpp2.arc:
  78.     cpp1.c        Mainline code, documentation master sources
  79.     cpp2.c        most #control processing
  80.     cpp3.c        filename stuff and command line parsing
  81. cpp3.arc:
  82.     cpp4.c        #define processor
  83.     cpp5.c        #if <expr> processor
  84.     cpp6.c        Support code (symbol table and I/O routines)
  85.     
  86. Cpp intentionally does not rely on the presence of a full-scale
  87. macro preprocessor, it does require the simple parameter substitution
  88. preprocessor capabilities of Unix V6 and Decus C.  If your C
  89. language lacks full preprocessing, you should make sure "nomacargs"
  90. is #define'd in cpp.h.  (This is done automatically by the Decus C
  91. compiler.)
  92.  
  93. The documentation (manual page) for cpp is included as cpp.mem
  94. and cpp.rno.  Cpp.rno is in Dec Runoff format, built by a Decus C
  95. utility (getrno) from original source which is embedded in cpp1.c.
  96. To my knowledge, there is no equivalent program that creates
  97. the nroff source appropriate for Unix.
  98.  
  99. I would be happy to receive fixes to any problems you encounter.
  100. As I do not maintain distribution kit base-levels, bare-bones
  101. diff listings without sufficient context are not very useful.
  102. It is unlikely that I can find time to help you with other
  103. difficulties.
  104.  
  105.             Acknowledgements
  106.  
  107. I received a great deal of help from many people in debugging cpp.
  108. Alan Feuer and Sam Kendall used "state of the art" run-time code
  109. checkers to locate several errors.  Ed Keiser found problems when
  110. cpp was used on machines with different int and pointer sizes.
  111. Dave Conroy helped with the initial debugging, while Arthur Olsen
  112. and George Rosenberg found (and solved) several problems in the
  113. first USENET release.
  114.  
  115. Martin Minow
  116. decvax!minow
  117.  
  118. -h- cpp.mem    Mon Jan  7 23:59:27 1985    cpp.mem
  119.  
  120.  
  121.  
  122.  
  123.         1.0  C Pre-Processor
  124.  
  125.  
  126.  
  127.                                     *******
  128.                                     * cpp *
  129.                                     *******
  130.  
  131.  
  132.  
  133.         NAME:   cpp -- C Pre-Processor
  134.  
  135.         SYNOPSIS:
  136.  
  137.                 cpp [-options] [infile [outfile]]
  138.  
  139.         DESCRIPTION:
  140.  
  141.                 CPP reads a C source file, expands  macros  and  include
  142.                 files,  and writes an input file for the C compiler.  If
  143.                 no file arguments are given, CPP reads  from  stdin  and
  144.                 writes  to  stdout.   If  one file argument is given, it
  145.                 will define the input file,  while  two  file  arguments
  146.                 define  both  input and output files.  The file name "-"
  147.                 is a synonym for stdin or stdout as appropriate.
  148.  
  149.                 The following options are  supported.   Options  may  be
  150.                 given in either case.
  151.  
  152.                 -C              If set, source-file comments are written
  153.                                 to  the  output  file.   This allows the
  154.                                 output of CPP to be used as the input to
  155.                                 a  program,  such  as lint, that expects
  156.                                 commands embedded in specially-formatted
  157.                                 comments.
  158.  
  159.                 -Dname=value    Define the name  as  if  the  programmer
  160.                                 wrote
  161.  
  162.                                     #define name value
  163.  
  164.                                 at the start  of  the  first  file.   If
  165.                                 "=value"  is  not  given, a value of "1"
  166.                                 will be used.
  167.  
  168.                                 On non-unix systems, all alphabetic text
  169.                                 will be forced to upper-case.
  170.  
  171.                 -E              Always return "success" to the operating
  172.                                 system,  even  if  errors were detected.
  173.                                 Note that some fatal errors, such  as  a
  174.                                 missing  #include  file,  will terminate
  175.                                 CPP, returning "failure" even if the  -E
  176.                                 option is given.
  177.                                                                           Page 2
  178.         cpp     C Pre-Processor
  179.  
  180.  
  181.                 -Idirectory     Add  this  directory  to  the  list   of
  182.                                 directories  searched for #include "..."
  183.                                 and #include <...> commands.  Note  that
  184.                                 there  is  no space between the "-I" and
  185.                                 the directory string.  More than one  -I
  186.                                 command   is   permitted.   On  non-Unix
  187.                                 systems   "directory"   is   forced   to
  188.                                 upper-case.
  189.  
  190.                 -N              CPP  normally  predefines  some  symbols
  191.                                 defining   the   target   computer   and
  192.                                 operating system.  If -N  is  specified,
  193.                                 no symbols will be predefined.  If -N -N
  194.                                 is  specified,  the   "always   present"
  195.                                 symbols,    __LINE__,    __FILE__,   and
  196.                                 __DATE__ are not defined.
  197.  
  198.                 -Stext          CPP normally assumes that  the  size  of
  199.                                 the  target  computer's  basic  variable
  200.                                 types is the same as the size  of  these
  201.                                 types  of  the host computer.  (This can
  202.                                 be  overridden  when  CPP  is  compiled,
  203.                                 however.)  The  -S option allows dynamic
  204.                                 respecification of these values.  "text"
  205.                                 is  a  string  of  numbers, separated by
  206.                                 commas, that  specifies  correct  sizes.
  207.                                 The sizes must be specified in the exact
  208.                                 order:
  209.  
  210.                                     char short int long float double
  211.  
  212.                                 If you specify the option as  "-S*text",
  213.                                 pointers   to   these   types   will  be
  214.                                 specified.   -S*  takes  one  additional
  215.                                 argument  for  pointer to function (e.g.
  216.                                 int (*)())
  217.  
  218.                                 For   example,    to    specify    sizes
  219.                                 appropriate  for  a  PDP-11,  you  would
  220.                                 write:
  221.  
  222.                                        c s i l f d func
  223.                                      -S1,2,2,2,4,8,
  224.                                     -S*2,2,2,2,2,2,2
  225.  
  226.                                 Note that all values must be specified.
  227.  
  228.                 -Uname          Undefine the name as if
  229.  
  230.                                     #undef name
  231.  
  232.                                 were given.  On non-Unix systems, "name"
  233.                                 will be forced to upper-case.
  234.                                                                           Page 3
  235.         cpp     C Pre-Processor
  236.  
  237.  
  238.                 -Xnumber        Enable debugging code.  If no  value  is
  239.                                 given,  a value of 1 will be used.  (For
  240.                                 maintenence of CPP only.)
  241.  
  242.  
  243.         PRE-DEFINED VARIABLES:
  244.  
  245.                 When CPP begins processing, the following variables will
  246.                 have been defined (unless the -N option is specified):
  247.  
  248.                 Target computer (as appropriate):
  249.  
  250.                     pdp11, vax, M68000 m68000 m68k
  251.  
  252.                 Target operating system (as appropriate):
  253.  
  254.                     rsx, rt11, vms, unix
  255.  
  256.                 Target compiler (as appropriate):
  257.  
  258.                     decus, vax11c
  259.  
  260.                 The implementor may add definitions to this  list.   The
  261.                 default  definitions  match  the  definition of the host
  262.                 computer, operating system, and C compiler.
  263.  
  264.                 The following are always available unless undefined  (or
  265.                 -N was specified twice):
  266.  
  267.                     __FILE__    The  input  (or  #include)  file   being
  268.                                 compiled (as a quoted string).
  269.  
  270.                     __LINE__    The line number being compiled.
  271.  
  272.                     __DATE__    The date and time of  compilation  as  a
  273.                                 Unix  ctime  quoted string (the trailing
  274.                                 newline is removed).  Thus,
  275.  
  276.                                     printf("Bug at line %s,", __LINE__);
  277.                                     printf(" source file %s", __FILE__);
  278.                                     printf(" compiled on %s", __DATE__);
  279.  
  280.  
  281.         DRAFT PROPOSED ANSI STANDARD CONSIDERATIONS:
  282.  
  283.                 The current  version  of  the  Draft  Proposed  Standard
  284.                 explicitly  states  that  "readers  are requested not to
  285.                 specify or claim conformance to this draft." Readers and
  286.                 users  of  Decus  CPP  should  not assume that Decus CPP
  287.                 conforms to the standard, or that it will conform to the
  288.                 actual C Language Standard.
  289.  
  290.                 When CPP is itself compiled, many features of the  Draft
  291.                 Proposed  Standard  that  are incompatible with existing
  292.                                                                           Page 4
  293.         cpp     C Pre-Processor
  294.  
  295.  
  296.                 preprocessors may be  disabled.   See  the  comments  in
  297.                 CPP's source for details.
  298.  
  299.                 The latest version of the Draft  Proposed  Standard  (as
  300.                 reflected in Decus CPP) is dated November 12, 1984.
  301.  
  302.                 Comments are removed from the input text.   The  comment
  303.                 is  replaced by a single space character.  The -C option
  304.                 preserves comments, writing them to the output file.
  305.  
  306.                 The '$' character is considered to be a letter.  This is
  307.                 a permitted extension.
  308.  
  309.                 The following new features of C are processed by CPP:
  310.  
  311.                     #elif expression (#else #if)
  312.                     '\xNNN' (Hexadecimal constant)
  313.                     '\a' (Ascii BELL)
  314.                     '\v' (Ascii Vertical Tab)
  315.                     #if defined NAME 1 if defined, 0 if not
  316.                     #if defined (NAME) 1 if defined, 0 if not
  317.                     #if sizeof (basic type)
  318.                     unary +
  319.                     123U, 123LU Unsigned ints and longs.
  320.                     12.3L Long double numbers
  321.                     token#token Token concatenation
  322.                     #include token Expands to filename
  323.  
  324.                 The Draft Proposed Standard has  extended  C,  adding  a
  325.                 constant string concatenation operator, where
  326.  
  327.                     "foo" "bar"
  328.  
  329.                 is regarded as the single string "foobar".   (This  does
  330.                 not  affect  CPP's  processing but does permit a limited
  331.                 form of macro argument substitution into strings as will
  332.                 be discussed.)
  333.  
  334.                 The Standard Committee plans to add token  concatenation
  335.                 to  #define command lines.  One suggested implementation
  336.                 is as follows:  the sequence "Token1#Token2" is  treated
  337.                 as  if  the programmer wrote "Token1Token2".  This could
  338.                 be used as follows:
  339.  
  340.                     #line 123
  341.                     #define ATLINE foo#__LINE__
  342.  
  343.                 ATLINE would be defined as foo123.
  344.  
  345.                 Note that "Token2" must either have  the  format  of  an
  346.                 identifier or be a string of digits.  Thus, the string
  347.  
  348.                     #define ATLINE foo#1x3
  349.                                                                           Page 5
  350.         cpp     C Pre-Processor
  351.  
  352.  
  353.                 generates two tokens:  "foo1" and "x3".
  354.  
  355.                 If the tokens T1 and T2 are concatenated into  T3,  this
  356.                 implementation operates as follows:
  357.  
  358.                   1. Expand T1 if it is a macro.
  359.                   2. Expand T2 if it is a macro.
  360.                   3. Join the tokens, forming T3.
  361.                   4. Expand T3 if it is a macro.
  362.  
  363.                 A macro formal parameter  will  be  substituted  into  a
  364.                 string or character constant if it is the only component
  365.                 of that constant:
  366.  
  367.                     #define VECSIZE 123
  368.                     #define vprint(name, size) \
  369.                       printf("name" "[" "size" "] = {\n")
  370.                       ... vprint(vector, VECSIZE);
  371.  
  372.                 expands (effectively) to
  373.  
  374.                       vprint("vector[123] = {\n");
  375.  
  376.                 Note that  this  will  be  useful  if  your  C  compiler
  377.                 supports  the  new  string concatenation operation noted
  378.                 above.  As implemented here, if you write
  379.  
  380.                     #define string(arg) "arg"
  381.                       ... string("foo") ...
  382.  
  383.                 This implementation generates  "foo",  rather  than  the
  384.                 strictly  correct  ""foo"" (which will probably generate
  385.                 an error message).  This is, strictly speaking, an error
  386.                 in CPP and may be removed from future releases.
  387.  
  388.         ERROR MESSAGES:
  389.  
  390.                 Many.  CPP prints warning or error messages if  you  try
  391.                 to     use     multiple-byte     character     constants
  392.                 (non-transportable) if you #undef a symbol that was  not
  393.                 defined,  or  if  your  program  has  potentially nested
  394.                 comments.
  395.  
  396.         AUTHOR:
  397.  
  398.                 Martin Minow
  399.  
  400.         BUGS:
  401.  
  402.                 The #if expression processor uses signed integers  only.
  403.                 I.e, #if 0xFFFFu < 0 may be TRUE.
  404.  
  405. -h- archx.c    Mon Jan  7 23:59:27 1985    archx.c
  406. /*
  407.  *            A R C H X
  408.  *
  409.  * Archive extraction
  410.  *
  411.  */
  412.  
  413. /*)BUILD    $(TKBOPTIONS) = {
  414.             TASK    = ...ARX
  415.         }
  416. */
  417.  
  418. #ifdef    DOCUMENTATION
  419.  
  420. title    archx    text file archiver extraction
  421. index        text file archiver extraction
  422.  
  423. synopsis
  424.     arch archive_files
  425.  
  426. description
  427.  
  428.     Archx manages archives (libraries) of source files, allowing
  429.     a large number of small files to be stored without using
  430.     excessive system resources.  Archx extracts all files from
  431.     an archive.
  432.  
  433.     If no archive_name file is given, the standard input is read.
  434.     Archive header records are echoed to the standard output.
  435.  
  436. archive file format
  437.  
  438.     Archive files are standard text files.  Each archive element is
  439.     preceeded by a line of the format:
  440.     .s.nf
  441.     -h-    file.name    date    true_name
  442.     .s.f
  443.     Note that there is no line or byte count.  To prevent problems,
  444.     a '-' at the beginning of a record within a user file or embedded
  445.     archive will be "quoted" by doubling it.  The date and true filename
  446.     fields are ignored.  On some operating systems, file.name is
  447.     forced to lowercase.
  448.  
  449.     If the first non-blank line of an input file does not
  450.     begin with "-h", the text will be appended to "archx.tmp"
  451.     This is needed if archives are distributed by mail
  452.     and arrive with initial routing and subject information.
  453.  
  454. diagnostics
  455.  
  456.     Diagnostic messages should be self-explanatory
  457.  
  458. author
  459.  
  460.     Martin Minow
  461.  
  462. bugs
  463.  
  464. #endif
  465.  
  466. #include    <stdio.h>
  467. #include    <ctype.h>
  468. #define EOS        0
  469. #define    FALSE        0
  470. #define    TRUE        1
  471. #ifdef    vms
  472. #include    <ssdef.h>
  473. extern int    errno;
  474. #define    IO_ERROR    errno
  475. #define    IO_NORMAL    SS$_NORMAL
  476. #endif
  477. #ifndef    IO_NORMAL
  478. #define    IO_NORMAL    0
  479. #endif
  480. #ifndef    IO_ERROR
  481. #define    IO_ERROR    1
  482. #endif
  483.  
  484. /*
  485.  * The following status codes are returned by gethdr()
  486.  */
  487. #define DONE    0
  488. #define    GOTCHA    1
  489. #define    NOGOOD    2
  490.  
  491. char        text[513];        /* Working text line        */
  492. char        name[81];        /* Current archive member name    */
  493. char        filename[81];        /* Working file name        */
  494. char        arfilename[81];        /* Archive file name        */
  495. char        fullname[81];        /* Output for argetname()    */
  496. int        verbose        = TRUE;    /* TRUE for verbosity        */
  497. int        first_archive;        /* For mail header skipping    */
  498.  
  499. main(argc, argv)
  500. int        argc;            /* Arg count            */
  501. char        *argv[];        /* Arg vector            */
  502. {
  503.     register int        i;    /* Random counter        */
  504.     int            status;    /* Exit status            */
  505.  
  506. #ifdef    vms
  507.     argc = getredirection(argc, argv);
  508. #endif
  509.     status = IO_NORMAL;
  510.     if (argc == 1)
  511.         process();
  512.     else {
  513.         for (i = 1; i < argc; i++) {
  514.         if (freopen(argv[i], "r", stdin) != NULL)
  515.             process();
  516.         else {
  517.             perror(argv[i]);
  518.             status = IO_ERROR;
  519.         }
  520.         }
  521.     }
  522.     exit(status);
  523. }
  524.  
  525. process()
  526. /*
  527.  * Process archive open on stdin
  528.  */
  529. {
  530.     register char        *fn;    /* File name pointer        */
  531.     register FILE        *outfd;
  532.     register int        i;
  533.  
  534.     text[0] = EOS;
  535.     while ((i = gethdr()) != DONE) {
  536.         switch (i) {
  537.         case GOTCHA:
  538.         if ((outfd = fopen(name, "w")) == NULL) {
  539.             perror(name);
  540.             fprintf(stderr, "Can't create \"%s\"\n", name);
  541.             arskip();
  542.             continue;
  543.         }
  544.         break;
  545.  
  546.         case NOGOOD:
  547.         fprintf(stderr, "Missing -h-, writing to archx.tmp\n");
  548.         fprintf(stderr, "Current text line: %s", text);
  549.         strcpy(name, "archx.tmp");
  550.         if ((outfd = fopen(name, "a")) == NULL) {
  551.             perror(name);
  552.             fprintf(stderr, "Cannot append to %s\n", name);
  553.             arskip();
  554.             continue;
  555.         }
  556.         break;
  557.         }
  558.         arexport(outfd);
  559.         fclose(outfd);
  560.     }
  561. }
  562.  
  563. int
  564. gethdr()
  565. /*
  566.  * If text is null, read a record, returning to signal input state:
  567.  *    DONE    Eof read
  568.  *    NOGOOD    -h- wasn't first non-blank line.  Line is in text[]
  569.  *    GOTCHA    -h- found, parsed into name.
  570.  */
  571. {
  572.     register char    *tp;
  573.     register char    *np;
  574.  
  575. again:    if (text[0] == EOS
  576.      && fgets(text, sizeof text, stdin) == NULL)
  577.         return (DONE);
  578.     if (text[0] == '\n' && text[1] == EOS) {
  579.         text[0] = EOS;
  580.         goto again;
  581.     }
  582.     if (text[0] != '-'
  583.      || text[1] != 'h'
  584.      || text[2] != '-')
  585.         return (NOGOOD);
  586.     for (tp = &text[3]; isspace(*tp); tp++)
  587.         ;
  588.     for (np = name; !isspace(*tp); *np++ = *tp++)
  589.         ;
  590.     *np = EOS;
  591.     return (GOTCHA);
  592. }
  593.  
  594. arskip()
  595. /*
  596.  * Skip to next header
  597.  */
  598. {
  599.     while (fgets(text, sizeof text, stdin) != NULL) {
  600.         if (text[0] == '-' && text[1] != '-')
  601.         return;
  602.     }
  603.     text[0] = EOS;                /* EOF signal        */
  604. }
  605.  
  606. arexport(outfd)
  607. register FILE    *outfd;
  608. /*
  609.  * Read secret archive format, writing archived data to outfd.
  610.  * Clean out extraneous <cr>,<lf>'s
  611.  */
  612. {
  613.     register char    *tp;
  614.     unsigned int    nrecords;
  615.  
  616.     printf("Creating \"%s\", ", name);
  617.     nrecords = 0;
  618.     while (fgets(text, sizeof text, stdin) != NULL) {
  619.         tp = &text[strlen(text)];
  620.         if (tp > &text[1] && *--tp == '\n' && *--tp == '\r') {
  621.         *tp++ = '\n';
  622.         *tp = EOS;
  623.         }
  624.         if (text[0] == '-') {
  625.         if (text[1] != '-')
  626.             goto gotcha;
  627.         fputs(text+1, outfd);
  628.         }
  629.         else {
  630.         fputs(text, outfd);
  631.         }
  632.         nrecords++;
  633.     }
  634.     text[0] = EOS;
  635. gotcha:    printf("%u records\n", nrecords);
  636.     if (ferror(stdin) || ferror(outfd))
  637.         printf("Creation of \"%s\" completed with error\n", name);
  638. }
  639.  
  640. /*
  641.  * getredirection() is intended to aid in porting C programs
  642.  * to VMS (Vax-11 C) which does not support '>' and '<'
  643.  * I/O redirection.  With suitable modification, it may
  644.  * useful for other portability problems as well.
  645.  */
  646.  
  647. #ifdef    vms
  648. static int
  649. getredirection(argc, argv)
  650. int        argc;
  651. char        **argv;
  652. /*
  653.  * Process vms redirection arg's.  Exit if any error is seen.
  654.  * If getredirection() processes an argument, it is erased
  655.  * from the vector.  getredirection() returns a new argc value.
  656.  *
  657.  * Warning: do not try to simplify the code for vms.  The code
  658.  * presupposes that getredirection() is called before any data is
  659.  * read from stdin or written to stdout.
  660.  *
  661.  * Normal usage is as follows:
  662.  *
  663.  *    main(argc, argv)
  664.  *    int        argc;
  665.  *    char        *argv[];
  666.  *    {
  667.  *        argc = getredirection(argc, argv);
  668.  *    }
  669.  */
  670. {
  671.     register char        *ap;    /* Argument pointer    */
  672.     int            i;    /* argv[] index        */
  673.     int            j;    /* Output index        */
  674.     int            file;    /* File_descriptor     */
  675.     extern int        errno;    /* Last vms i/o error     */
  676.  
  677.     for (j = i = 1; i < argc; i++) {   /* Do all arguments    */
  678.         switch (*(ap = argv[i])) {
  679.         case '<':            /* <file        */
  680.         if (freopen(++ap, "r", stdin) == NULL) {
  681.             perror(ap);        /* Can't find file    */
  682.             exit(errno);    /* Is a fatal error    */
  683.         }
  684.  
  685.         case '>':            /* >file or >>file    */
  686.         if (*++ap == '>') {    /* >>file        */
  687.             /*
  688.              * If the file exists, and is writable by us,
  689.              * call freopen to append to the file (using the
  690.              * file's current attributes).  Otherwise, create
  691.              * a new file with "vanilla" attributes as if
  692.              * the argument was given as ">filename".
  693.              * access(name, 2) is TRUE if we can write on
  694.              * the specified file.
  695.              */
  696.             if (access(++ap, 2) == 0) {
  697.             if (freopen(ap, "a", stdout) != NULL)
  698.                 break;    /* Exit case statement    */
  699.             perror(ap);    /* Error, can't append    */
  700.             exit(errno);    /* After access test    */
  701.             }            /* If file accessable    */
  702.         }
  703.         /*
  704.          * On vms, we want to create the file using "standard"
  705.          * record attributes.  create(...) creates the file
  706.          * using the caller's default protection mask and
  707.          * "variable length, implied carriage return"
  708.          * attributes. dup2() associates the file with stdout.
  709.          */
  710.         if ((file = creat(ap, 0, "rat=cr", "rfm=var")) == -1
  711.          || dup2(file, fileno(stdout)) == -1) {
  712.             perror(ap);        /* Can't create file    */
  713.             exit(errno);    /* is a fatal error    */
  714.         }            /* If '>' creation    */
  715.         break;            /* Exit case test    */
  716.  
  717.         default:
  718.         argv[j++] = ap;        /* Not a redirector    */
  719.         break;            /* Exit case test    */
  720.         }
  721.     }                /* For all arguments    */
  722.     return (j);
  723. }
  724. #endif
  725.  
  726. -h- archc.c    Mon Jan  7 23:59:27 1985    archc.c
  727. /*
  728.  *            A R C H I V E
  729.  *
  730.  * Create an archive
  731.  *
  732.  */
  733.  
  734. /*)BUILD    $(TKBOPTIONS) = {
  735.             TASK    = ...ARC
  736.         }
  737. */
  738.  
  739. #ifdef    DOCUMENTATION
  740.  
  741. title    archc    text file archive creation
  742. index        text file archive creation
  743.  
  744. synopsis
  745.  
  746.     archc file[s] >archive
  747.  
  748. description
  749.  
  750.     Archc manages archives (libraries) of source files, allowing
  751.     a large number of small files to be stored without using
  752.     excessive system resources.  It copies the set of named
  753.     files to standard output in archive format.
  754.  
  755.     The archx program will recreate the files from an archive.
  756.  
  757.     Note: there are no checks against the same file appearing
  758.     twice in an archive.
  759.  
  760. archive file format
  761.  
  762.     Archive files are standard text files.  Each archive element is
  763.     preceeded by a line of the format:
  764.     .s.nf
  765.     -h-    file.name    date    true_path_name
  766.     .s.f
  767.     Note that there is no line or byte count.  To prevent problems,
  768.     a '-' at the beginning of a record within a user file or embedded
  769.     archive will be "quoted" by doubling it.  The date and true filename
  770.     fields are ignored.  On Dec operating systems, file.name is
  771.     forced to lowercase.
  772.  
  773. diagnostics
  774.  
  775.     Diagnostic messages should be self-explanatory
  776.  
  777. author
  778.  
  779.     Martin Minow
  780.  
  781. #endif
  782.  
  783. #include    <stdio.h>
  784. #include    <ctype.h>
  785. #define EOS        0
  786. #define    FALSE        0
  787. #define    TRUE        1
  788.  
  789. char        text[513];        /* Working text            */
  790. char        name[81];        /* Current archive member name    */
  791. char        pathname[81];        /* Output for argetname()    */
  792. char        *timetext;        /* Time of day text        */
  793. int        verbose        = TRUE; /* TRUE for verbosity        */
  794. FILE        *infd;            /* Input file            */
  795.  
  796. main(argc, argv)
  797. int        argc;            /* Arg count            */
  798. char        *argv[];        /* Arg vector            */
  799. {
  800.     register int        i;    /* Random counter        */
  801.     register char        *fn;    /* File name pointer        */
  802.     register char        *argp;    /* Arg pointer            */
  803.     int            nfiles;
  804.     extern char        *ctime();
  805.     extern long        time();
  806.     long            timval;
  807.  
  808.     time(&timval);
  809.     timetext = ctime(&timval);
  810.     timetext[24] = EOS;
  811.     argc = getredirection(argc, argv);
  812.     if (argc <= 1)
  813.         fprintf(stderr, "No files to archive?\n");
  814. #ifdef    unix
  815.     for (i = 1; i < argc; i++) {
  816.         if ((infd = fopen(argv[i], "r")) == NULL)
  817.         perror(argv[i]);
  818.         else {
  819.         strcpy(pathname, argv[i]);
  820.         import();
  821.         fclose(infd);
  822.         }
  823.     }
  824. #else
  825.     for (i = 1; i < argc; i++) {
  826.         if ((infd = fwild(argv[i], "r")) == NULL)
  827.         perror(argv[i]);
  828.         else {
  829.         for (nfiles = 0; fnext(infd) != NULL; nfiles++) {
  830.             fgetname(infd, pathname);
  831.             import();
  832.         }
  833.         fclose(infd);
  834.         if (nfiles == 0)
  835.             fprintf(stderr, "No files match \"%s\"\n", argv[i]);
  836.         }
  837.     }
  838. #endif
  839. }
  840.  
  841. import()
  842. /*
  843.  * Add the file open on infd (with file name in pathname) to
  844.  * the archive.
  845.  */
  846. {
  847.     unsigned int    nrecords;
  848.  
  849.     fixname();
  850.     nrecords = 0;
  851.     printf("-h- %s\t%s\t%s\n", name, timetext, pathname);
  852.     while (fgets(text, sizeof text, infd) != NULL) {
  853.         if (text[0] == '-')
  854.         putchar('-');                /* Quote    */
  855.         fputs(text, stdout);
  856.         nrecords++;
  857.     }
  858.     if (ferror(infd)) {
  859.         perror(name);
  860.         fprintf(stderr, "Error when importing a file\n");
  861.     }
  862.     if (verbose) {
  863.         fprintf(stderr, "%u records read from %s\n",
  864.         nrecords, pathname);
  865.     }
  866. }
  867.  
  868. fixname()
  869. /*
  870.  * Get file name (in pathname), stripping off device:[directory]
  871.  * and ;version.  The archive name ("file.ext") is written to name[].
  872.  * On a dec operating system, name is forced to lowercase.
  873.  */
  874. {
  875.     register char    *tp;
  876.     register char    *ip;
  877.     char        bracket;
  878.     extern char    *strrchr();
  879.  
  880. #ifdef    unix
  881.     /*
  882.      * name is after all directory information
  883.      */
  884.     if ((tp = strrchr(pathname, '/')) != NULL)
  885.         tp++;
  886.     else
  887.         tp = pathname;
  888.     strcpy(name, tp);
  889. #else
  890.     strcpy(name, pathname);
  891.     if ((tp = strrchr(name, ';')) != NULL)
  892.         *tp = EOS;
  893.     while ((tp = strchr(name, ':')) != NULL)
  894.         strcpy(name, tp + 1);
  895.     switch (name[0]) {
  896.     case '[':    bracket = ']';
  897.             break;
  898.     case '<':    bracket = '>';
  899.             break;
  900.     case '(':    bracket = ')';
  901.             break;
  902.     default:    bracket = EOS;
  903.             break;
  904.     }
  905.     if (bracket != EOS) {
  906.         if ((tp = strchr(name, bracket)) == NULL) {
  907.         fprintf(stderr, "? Illegal file name \"%s\"\n",
  908.             pathname);
  909.         }
  910.         else {
  911.         strcpy(name, tp + 1);
  912.         }
  913.     }
  914.     for (tp = name; *tp != EOS; tp++) {
  915.         if (isupper(*tp))
  916.         *tp = tolower(*tp);
  917.     }
  918. #endif
  919. }
  920.  
  921. #ifdef    unix
  922. char *
  923. strrchr(stng, chr)
  924. register char    *stng;
  925. register char    chr;
  926. /*
  927.  * Return rightmost instance of chr in stng.
  928.  * This has the wrong name on some Unix systems.
  929.  */
  930. {
  931.     register char    *result;
  932.  
  933.     result = NULL;
  934.  
  935.     do {
  936.         if (*stng == chr)
  937.         result = stng;
  938.     } while (*stng++ != EOS);
  939.     return (result);
  940. }
  941. #endif
  942.  
  943. /*
  944.  * getredirection() is intended to aid in porting C programs
  945.  * to VMS (Vax-11 C) which does not support '>' and '<'
  946.  * I/O redirection.  With suitable modification, it may
  947.  * useful for other portability problems as well.
  948.  */
  949.  
  950. static int
  951. getredirection(argc, argv)
  952. int        argc;
  953. char        **argv;
  954. /*
  955.  * Process vms redirection arg's.  Exit if any error is seen.
  956.  * If getredirection() processes an argument, it is erased
  957.  * from the vector.  getredirection() returns a new argc value.
  958.  *
  959.  * Warning: do not try to simplify the code for vms.  The code
  960.  * presupposes that getredirection() is called before any data is
  961.  * read from stdin or written to stdout.
  962.  *
  963.  * Normal usage is as follows:
  964.  *
  965.  *    main(argc, argv)
  966.  *    int        argc;
  967.  *    char        *argv[];
  968.  *    {
  969.  *        argc = getredirection(argc, argv);
  970.  *    }
  971.  */
  972. {
  973. #ifdef    vms
  974.     register char        *ap;    /* Argument pointer    */
  975.     int            i;    /* argv[] index        */
  976.     int            j;    /* Output index        */
  977.     int            file;    /* File_descriptor     */
  978.     extern int        errno;    /* Last vms i/o error     */
  979.  
  980.     for (j = i = 1; i < argc; i++) {   /* Do all arguments    */
  981.         switch (*(ap = argv[i])) {
  982.         case '<':            /* <file        */
  983.         if (freopen(++ap, "r", stdin) == NULL) {
  984.             perror(ap);        /* Can't find file    */
  985.             exit(errno);    /* Is a fatal error    */
  986.         }
  987.  
  988.         case '>':            /* >file or >>file    */
  989.         if (*++ap == '>') {    /* >>file        */
  990.             /*
  991.              * If the file exists, and is writable by us,
  992.              * call freopen to append to the file (using the
  993.              * file's current attributes).  Otherwise, create
  994.              * a new file with "vanilla" attributes as if
  995.              * the argument was given as ">filename".
  996.              * access(name, 2) is TRUE if we can write on
  997.              * the specified file.
  998.              */
  999.             if (access(++ap, 2) == 0) {
  1000.             if (freopen(ap, "a", stdout) != NULL)
  1001.                 break;    /* Exit case statement    */
  1002.             perror(ap);    /* Error, can't append    */
  1003.             exit(errno);    /* After access test    */
  1004.             }            /* If file accessable    */
  1005.         }
  1006.         /*
  1007.          * On vms, we want to create the file using "standard"
  1008.          * record attributes.  create(...) creates the file
  1009.          * using the caller's default protection mask and
  1010.          * "variable length, implied carriage return"
  1011.          * attributes. dup2() associates the file with stdout.
  1012.          */
  1013.         if ((file = creat(ap, 0, "rat=cr", "rfm=var")) == -1
  1014.          || dup2(file, fileno(stdout)) == -1) {
  1015.             perror(ap);        /* Can't create file    */
  1016.             exit(errno);    /* is a fatal error    */
  1017.         }            /* If '>' creation    */
  1018.         break;            /* Exit case test    */
  1019.  
  1020.         default:
  1021.         argv[j++] = ap;        /* Not a redirector    */
  1022.         break;            /* Exit case test    */
  1023.         }
  1024.     }                /* For all arguments    */
  1025.     return (j);
  1026. #else
  1027.     /*
  1028.      * Note: argv[] is referenced to fool the Decus C
  1029.      * syntax analyser, supressing an unneeded warning
  1030.      * message.
  1031.      */
  1032.     return (argv[0], argc);        /* Just return as seen    */
  1033. #endif
  1034. }
  1035.  
  1036. -h- cpp.rno    Mon Jan  7 23:59:27 1985    cpp.rno
  1037. .lm 8.rm 72.nhy
  1038.  
  1039. .no autosubtitle .style headers 3,0,0
  1040. .pg.uc.ps 58,80.lm 8.rm 72
  1041. .hd
  1042. .hd mixed
  1043. .head mixed
  1044.  
  1045. .st ########cpp#####C Pre-Processor
  1046. .pg
  1047. .hl 1 ^&C Pre-Processor\&
  1048. .s 2
  1049. .c ;*******
  1050. .c ;* cpp *
  1051. .c ;*******
  1052. .s 2
  1053. .lm +8
  1054. .s.i -8;NAME:    cpp -- C Pre-Processor
  1055. .s.f
  1056. .i -8;SYNOPSIS:
  1057. .s.nf
  1058. cpp [-options] [infile [outfile]]
  1059. .s.f
  1060. .i -8;DESCRIPTION:
  1061. .s
  1062. CPP reads a C source file, expands macros and include
  1063. files, and writes an input file for the C compiler.
  1064. If no file arguments are given, CPP reads from stdin
  1065. and writes to stdout.  If one file argument is given,
  1066. it will define the input file, while two file arguments
  1067. define both input and output files.  The file name "-"
  1068. is a synonym for stdin or stdout as appropriate.
  1069. .s
  1070. The following options are supported.  Options may
  1071. be given in either case.
  1072. .lm +16
  1073. .p -16
  1074. --C        If set, source-file comments are written
  1075. to the output file.  This allows the output of CPP to be
  1076. used as the input to a program, such as lint, that expects
  1077. commands embedded in specially-formatted comments.
  1078. .p -16
  1079. --Dname=value    Define the name as if the programmer wrote
  1080. .s
  1081. .nf
  1082.     _#define name value
  1083. .s
  1084. .fill
  1085. at the start of the first file.  If "=value" is not
  1086. given, a value of "1" will be used.
  1087. .s
  1088. On non-unix systems, all alphabetic text will be forced
  1089. to upper-case.
  1090. .p -16
  1091. --E        Always return "success" to the operating
  1092. system, even if errors were detected.  Note that some fatal
  1093. errors, such as a missing _#include file, will terminate
  1094. CPP, returning "failure" even if the -E option is given.
  1095. .p -16
  1096. --Idirectory    Add this directory to the list of
  1097. directories searched for _#include "..." and _#include <...>
  1098. commands.  Note that there is no space between the
  1099. "-I" and the directory string.  More than one -I command
  1100. is permitted.  On non-Unix systems "directory" is forced
  1101. to upper-case.
  1102. .p -16
  1103. --N        CPP normally predefines some symbols defining
  1104. the target computer and operating system.  If -N is specified,
  1105. no symbols will be predefined.  If -N -N is specified, the
  1106. "always present" symbols, ____LINE____, ____FILE____, and ____DATE____
  1107. are not defined.
  1108. .p -16
  1109. --Stext        CPP normally assumes that the size of
  1110. the target computer's basic variable types is the same as the size
  1111. of these types of the host computer.  (This can be overridden
  1112. when CPP is compiled, however.)  The -S option allows dynamic
  1113. respecification of these values.  "text" is a string of
  1114. numbers, separated by commas, that specifies correct sizes.
  1115. The sizes must be specified in the exact order:
  1116. .s
  1117. .nf
  1118.     char short int long float double
  1119. .s
  1120. .fill
  1121. If you specify the option as "-S*text", pointers to these
  1122. types will be specified.  -S* takes one additional argument
  1123. for pointer to function (e.g. int (*)())
  1124. .s
  1125. For example, to specify sizes appropriate for a PDP-11,
  1126. you would write:
  1127. .s
  1128. .nf
  1129.        c s i l f d func
  1130.      -S1,2,2,2,4,8,
  1131.     -S*2,2,2,2,2,2,2
  1132. .s
  1133. .fill
  1134. Note that all values must be specified.
  1135. .p -16
  1136. --Uname        Undefine the name as if
  1137. .s
  1138. .nf
  1139.     _#undef name
  1140. .s
  1141. .fill
  1142. were given.  On non-Unix systems, "name" will be forced to
  1143. upper-case.
  1144. .p -16
  1145. --Xnumber    Enable debugging code.  If no value is
  1146. given, a value of 1 will be used.  (For maintenence of
  1147. CPP only.)
  1148. .s.lm -16
  1149. .s
  1150. .i -8;PRE-DEFINED VARIABLES:
  1151. .s
  1152. When CPP begins processing, the following variables will
  1153. have been defined (unless the -N option is specified):
  1154. .s
  1155. Target computer (as appropriate):
  1156. .s
  1157. .nf
  1158.     pdp11, vax, M68000 m68000 m68k
  1159. .fill
  1160. .s
  1161. Target operating system (as appropriate):
  1162. .s
  1163. .nf
  1164.     rsx, rt11, vms, unix
  1165. .fill
  1166. .s
  1167. Target compiler (as appropriate):
  1168. .s
  1169. .nf
  1170.     decus, vax11c
  1171. .fill
  1172. .s
  1173. The implementor may add definitions to this list.
  1174. The default definitions match the definition of the
  1175. host computer, operating system, and C compiler.
  1176. .s
  1177. The following are always available unless undefined (or
  1178. --N was specified twice):
  1179. .lm +16
  1180. .p -12
  1181. ____FILE____    The input (or _#include) file being compiled
  1182. (as a quoted string).
  1183. .p -12
  1184. ____LINE____    The line number being compiled.
  1185. .p -12
  1186. ____DATE____    The date and time of compilation as
  1187. a Unix ctime quoted string (the trailing newline is removed).
  1188. Thus,
  1189. .s
  1190. .nf
  1191.     printf("Bug at line _%s,", ____LINE____);
  1192.     printf(" source file _%s", ____FILE____);
  1193.     printf(" compiled on _%s", ____DATE____);
  1194. .fill
  1195. .s.lm -16
  1196. .s
  1197. .i -8;DRAFT PROPOSED ANSI STANDARD CONSIDERATIONS:
  1198. .s
  1199. The current version of the Draft Proposed Standard
  1200. explicitly states that "readers are requested not to specify
  1201. or claim conformance to this draft."  Readers and users
  1202. of Decus CPP should not assume that Decus CPP conforms
  1203. to the standard, or that it will conform to the actual
  1204. C Language Standard.
  1205. .s
  1206. When CPP is itself compiled, many features of the Draft
  1207. Proposed Standard that are incompatible with existing
  1208. preprocessors may be disabled.  See the comments in CPP's
  1209. source for details.
  1210. .s
  1211. The latest version of the Draft Proposed Standard (as reflected
  1212. in Decus CPP) is dated November 12, 1984.
  1213. .s
  1214. Comments are removed from the input text.  The comment
  1215. is replaced by a single space character.  The -C option
  1216. preserves comments, writing them to the output file.
  1217. .s
  1218. The '$' character is considered to be a letter.  This is
  1219. a permitted extension.
  1220. .s
  1221. The following new features of C are processed by CPP:
  1222. .s.comment Note: significant spaces, not tabs, .br quotes #if, #elif
  1223. .br;####_#elif expression    (_#else _#if)
  1224. .br;####'_\xNNN'             (Hexadecimal constant)
  1225. .br;####'_\a'                (Ascii BELL)
  1226. .br;####'_\v'                (Ascii Vertical Tab)
  1227. .br;####_#if defined NAME    1 if defined, 0 if not
  1228. .br;####_#if defined (NAME)  1 if defined, 0 if not
  1229. .br;####_#if sizeof (basic type)
  1230. .br;####unary +
  1231. .br;####123U, 123LU          Unsigned ints and longs.
  1232. .br;####12.3L                Long double numbers
  1233. .br;####token_#token         Token concatenation
  1234. .br;####_#include token      Expands to filename
  1235. .s
  1236. The Draft Proposed Standard has extended C, adding a constant
  1237. string concatenation operator, where
  1238. .s
  1239. .nf
  1240.     "foo" "bar"
  1241. .s
  1242. .fill
  1243. is regarded as the single string "foobar".  (This does not
  1244. affect CPP's processing but does permit a limited form of
  1245. macro argument substitution into strings as will be discussed.)
  1246. .s
  1247. The Standard Committee plans to add token concatenation
  1248. to _#define command lines.  One suggested implementation
  1249. is as follows:  the sequence "Token1_#Token2" is treated
  1250. as if the programmer wrote "Token1Token2".  This could
  1251. be used as follows:
  1252. .s
  1253. .nf
  1254.     _#line 123
  1255.     _#define ATLINE foo_#____LINE____
  1256. .s
  1257. .fill
  1258. ATLINE would be defined as foo123.
  1259. .s
  1260. Note that "Token2" must either have the format of an
  1261. identifier or be a string of digits.  Thus, the string
  1262. .s
  1263. .nf
  1264.     _#define ATLINE foo_#1x3
  1265. .s
  1266. .fill
  1267. generates two tokens: "foo1" and "x3".
  1268. .s
  1269. If the tokens T1 and T2 are concatenated into T3,
  1270. this implementation operates as follows:
  1271. .s
  1272. .nf
  1273.   1. Expand T1 if it is a macro.
  1274.   2. Expand T2 if it is a macro.
  1275.   3. Join the tokens, forming T3.
  1276.   4. Expand T3 if it is a macro.
  1277. .s
  1278. .fill
  1279. A macro formal parameter will be substituted into a string
  1280. or character constant if it is the only component of that
  1281. constant:
  1282. .s
  1283. .nf
  1284.     _#define VECSIZE 123
  1285.     _#define vprint(name, size) _\
  1286.       printf("name" "[" "size" "] = {_\n")
  1287.       ... vprint(vector, VECSIZE);
  1288. .s
  1289. .fill
  1290. expands (effectively) to
  1291. .s
  1292. .nf
  1293.       vprint("vector[123] = {_\n");
  1294. .s
  1295. .fill
  1296. Note that this will be useful if your C compiler supports
  1297. the new string concatenation operation noted above.
  1298. As implemented here, if you write
  1299. .s
  1300. .nf
  1301.     _#define string(arg) "arg"
  1302.       ... string("foo") ...
  1303. .s
  1304. .fill
  1305. This implementation generates "foo", rather than the strictly
  1306. correct ""foo"" (which will probably generate an error message).
  1307. This is, strictly speaking, an error in CPP and may be removed
  1308. from future releases.
  1309. .s
  1310. .i -8;ERROR MESSAGES:
  1311. .s
  1312. Many.  CPP prints warning or error messages if you try to
  1313. use multiple-byte character constants (non-transportable)
  1314. if you _#undef a symbol that was not defined, or if your
  1315. program has potentially nested comments.
  1316. .s
  1317. .i -8;AUTHOR:
  1318. .s
  1319. Martin Minow
  1320. .s
  1321. .i -8;BUGS:
  1322. .s
  1323. The _#if expression processor uses signed integers only.
  1324. I.e, _#if 0xFFFFu < 0 may be TRUE.
  1325. .s
  1326. .lm 8.rm 72.nhy
  1327.  
  1328. -h- makefile.txt    Mon Jan  7 23:59:27 1985    makefile.txt
  1329. # Unix makefile for cpp
  1330. #
  1331. # The redefinition of strchr() and strrchr() are needed for
  1332. # Ultrix-32, Unix 4.2 bsd (and maybe some other Unices).
  1333. #
  1334. BSDDEFINE = -Dstrchr=index -Dstrrchr=rindex
  1335. #
  1336. # On certain systems, such as Unix System III, you may need to define
  1337. # $(LINTFLAGS) in the make command line to set system-specific lint flags.
  1338. #
  1339. # This Makefile assumes cpp will replace the "standard" preprocessor.
  1340. # Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
  1341. # LINEFIX is a sed script filter that reinserts #line -- used for testing
  1342. # if LINE_PREFIX is set to "".   Note that we must stand on our heads to
  1343. # match the # and a line had better not begin with $.  By the way, what
  1344. # we really want is
  1345. #    LINEFIX = | sed "s/^#/#line/"
  1346. #
  1347. CPPDEFINE = -DLINE_PREFIX=\"\"
  1348. LINEFIX = | sed "s/^[^ !\"%-~]/&line/"
  1349. #
  1350. # Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
  1351. # "as compatible as possible" with the standard Unix V7 or Ultrix
  1352. # preprocessors.  This is needed to rebuild 4.2bsd, for example, as
  1353. # the preprocessor is used to modify assembler code, rather than C.
  1354. # This is not recommended for current development.  OLD_PREPROCESSOR
  1355. # forces the following definitions:
  1356. #   OK_DOLLAR        FALSE    $ is not allowed in variables
  1357. #   OK_CONCAT        FALSE    # cannot concatenate tokens
  1358. #   COMMENT_INVISIBLE    TRUE    old-style comment concatenation
  1359. #   STRING_FORMAL    TRUE    old-style string expansion
  1360. #
  1361. OLDDEFINE = -DOLD_PREPROCESSOR=1
  1362. #
  1363. # DEFINES collects all -D arguments for cc and lint:
  1364. # Change DEFINES = $(BSDDEFINE) $(CPPDEFINE) $(OLDDEFINE)
  1365. # for an old-style preprocessor.
  1366. #
  1367. DEFINES = $(BSDDEFINE) $(CPPDEFINE)
  1368.  
  1369. CFLAGS = -O $(DEFINES)
  1370.  
  1371. #
  1372. # ** compile cpp
  1373. #
  1374. SRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
  1375. OBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
  1376. cpp: $(OBJS)
  1377.     $(CC) $(CFLAGS) $(OBJS) -o cpp
  1378.  
  1379. #
  1380. # ** Test cpp by preprocessing itself, compiling the result,
  1381. # ** repeating the process and diff'ing the result.  Note: this
  1382. # ** is not a good test of cpp, but a simple verification.
  1383. # ** The diff's should not report any changes.
  1384. # ** Note that a sed script may be executed for each compile
  1385. #
  1386. test:
  1387.     cpp cpp1.c $(LINEFIX) >old.tmp1.c
  1388.     cpp cpp2.c $(LINEFIX) >old.tmp2.c
  1389.     cpp cpp3.c $(LINEFIX) >old.tmp3.c
  1390.     cpp cpp4.c $(LINEFIX) >old.tmp4.c
  1391.     cpp cpp5.c $(LINEFIX) >old.tmp5.c
  1392.     cpp cpp6.c $(LINEFIX) >old.tmp6.c
  1393.     $(CC) $(CFLAGS) old.tmp[123456].c
  1394.     a.out cpp1.c >new.tmp1.c
  1395.     a.out cpp2.c >new.tmp2.c
  1396.     a.out cpp3.c >new.tmp3.c
  1397.     a.out cpp4.c >new.tmp4.c
  1398.     a.out cpp5.c >new.tmp5.c
  1399.     a.out cpp6.c >new.tmp6.c
  1400.     diff old.tmp1.c new.tmp1.c
  1401.     diff old.tmp2.c new.tmp2.c
  1402.     diff old.tmp3.c new.tmp3.c
  1403.     diff old.tmp4.c new.tmp4.c
  1404.     diff old.tmp5.c new.tmp5.c
  1405.     diff old.tmp6.c new.tmp6.c
  1406.     rm a.out old.tmp[123456].* new.tmp[123456].*
  1407.  
  1408. #
  1409. # A somewhat more extensive test is provided by the "clock"
  1410. # program (which is not distributed).  Substitute your favorite
  1411. # macro-rich program here.
  1412. #
  1413. clock:    clock.c cpp
  1414.     cpp clock.c $(LINEFIX) >temp.cpp.c
  1415.     cc temp.cpp.c -lcurses -ltermcap -o clock
  1416.     rm temp.cpp.c
  1417.  
  1418. #
  1419. # ** Lint the code
  1420. #
  1421.  
  1422. lint:    $(SRCS)
  1423.     lint $(LINTFLAGS) $(DEFINES) $(SRCS)
  1424.  
  1425. #
  1426. # ** Remove unneeded files
  1427. #
  1428. clean:
  1429.     rm -f $(OBJS) cpp
  1430.  
  1431. #
  1432. # ** Rebuild the archive files needed to distribute cpp
  1433. # ** Uses the Decus C archive utility.
  1434. #
  1435.  
  1436. archc:    archc.c
  1437.     $(CC) $(CFLAGS) archc.c -o archc
  1438.  
  1439. archx:    archx.c
  1440.     $(CC) $(CFLAGS) archx.c -o archx
  1441.  
  1442. archive: archc
  1443.     archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
  1444.         cpp*.h >cpp1.arc
  1445.     archc cpp1.c cpp2.c cpp3.c >cpp2.arc
  1446.     archc cpp4.c cpp5.c cpp6.c >cpp3.arc
  1447.  
  1448. #
  1449. # Object module dependencies
  1450. #
  1451.  
  1452. cpp1.o    :    cpp1.c cpp.h cppdef.h
  1453.  
  1454. cpp2.o    :    cpp2.c cpp.h cppdef.h
  1455.  
  1456. cpp3.o    :    cpp3.c cpp.h cppdef.h
  1457.  
  1458. cpp4.o    :    cpp4.c cpp.h cppdef.h
  1459.  
  1460. cpp5.o    :    cpp5.c cpp.h cppdef.h
  1461.  
  1462. cpp6.o    :    cpp6.c cpp.h cppdef.h
  1463.  
  1464.  
  1465. -h- cpp.h    Mon Jan  7 23:59:27 1985    cpp.h
  1466.  
  1467. /*
  1468.  *    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
  1469.  *
  1470.  * In general, definitions in this file should not be changed.
  1471.  */
  1472.  
  1473. #ifndef    TRUE
  1474. #define    TRUE        1
  1475. #define    FALSE        0
  1476. #endif
  1477. #ifndef    EOS
  1478. /*
  1479.  * This is predefined in Decus C
  1480.  */
  1481. #define    EOS        '\0'        /* End of string        */
  1482. #endif
  1483. #define    EOF_CHAR    0        /* Returned by get() on eof    */
  1484. #define NULLST        ((char *) NULL)    /* Pointer to nowhere (linted)    */
  1485. #define    DEF_NOARGS    (-1)        /* #define foo vs #define foo()    */
  1486.  
  1487. /*
  1488.  * The following may need to change if the host system doesn't use ASCII.
  1489.  */
  1490. #define    DEF_MAGIC    0x1D        /* Magic for #defines        */
  1491. #define    TOK_SEP        0x1E        /* Token concatenation delim.    */
  1492. #define COM_SEP        0x1F        /* Magic comment separator    */
  1493.  
  1494. /*
  1495.  * Note -- in Ascii, the following will map macro formals onto DEL + the
  1496.  * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
  1497.  * be ok as long as PAR_MAC is less than 33).  Note that the last PAR_MAC
  1498.  * value is reserved for string substitution.
  1499.  */
  1500.  
  1501. #define    MAC_PARM    0x7F        /* Macro formals start here    */
  1502. #if PAR_MAC >= 33
  1503.     assertion fails -- PAR_MAC isn't less than 33
  1504. #endif
  1505. #define    LASTPARM    (PAR_MAC - 1)
  1506.  
  1507. /*
  1508.  * Character type codes.
  1509.  */
  1510.  
  1511. #define    INV        0        /* Invalid, must be zero    */
  1512. #define    OP_EOE        INV        /* End of expression        */
  1513. #define    DIG        1        /* Digit            */
  1514. #define    LET        2        /* Identifier start        */
  1515. #define    FIRST_BINOP    OP_ADD
  1516. #define    OP_ADD        3
  1517. #define    OP_SUB        4
  1518. #define    OP_MUL        5
  1519. #define    OP_DIV        6
  1520. #define    OP_MOD        7
  1521. #define    OP_ASL        8
  1522. #define    OP_ASR        9
  1523. #define    OP_AND        10        /* &, not &&            */
  1524. #define    OP_OR        11        /* |, not ||            */
  1525. #define    OP_XOR        12
  1526. #define    OP_EQ        13
  1527. #define    OP_NE        14
  1528. #define    OP_LT        15
  1529. #define    OP_LE        16
  1530. #define    OP_GE        17
  1531. #define    OP_GT        18
  1532. #define    OP_ANA        19        /* &&                */
  1533. #define    OP_ORO        20        /* ||                */
  1534. #define    OP_QUE        21        /* ?                */
  1535. #define    OP_COL        22        /* :                */
  1536. #define    OP_CMA        23        /* , (relevant?)        */
  1537. #define    LAST_BINOP    OP_CMA        /* Last binary operand        */
  1538. /*
  1539.  * The following are unary.
  1540.  */
  1541. #define    FIRST_UNOP    OP_PLU        /* First Unary operand        */
  1542. #define    OP_PLU        24        /* + (draft ANSI standard)    */
  1543. #define    OP_NEG        25        /* -                */
  1544. #define    OP_COM        26        /* ~                */
  1545. #define    OP_NOT        27        /* !                */
  1546. #define    LAST_UNOP    OP_NOT
  1547. #define    OP_LPA        28        /* (                */
  1548. #define    OP_RPA        29        /* )                */
  1549. #define    OP_END        30        /* End of expression marker    */
  1550. #define    OP_MAX        (OP_END + 1)    /* Number of operators        */
  1551. #define    OP_FAIL        (OP_END + 1)    /* For error returns        */
  1552.  
  1553. /*
  1554.  * The following are for lexical scanning only.
  1555.  */
  1556.  
  1557. #define    QUO        65        /* Both flavors of quotation    */
  1558. #define    DOT        66        /* . might start a number    */
  1559. #define    SPA        67        /* Space and tab        */
  1560. #define    BSH        68        /* Just a backslash        */
  1561. #define    END        69        /* EOF                */
  1562.  
  1563. /*
  1564.  * These bits are set in ifstack[]
  1565.  */
  1566. #define    WAS_COMPILING    1        /* TRUE if compile set at entry    */
  1567. #define    ELSE_SEEN    2        /* TRUE when #else processed    */
  1568. #define    TRUE_SEEN    4        /* TRUE when #if TRUE processed    */
  1569.  
  1570. /*
  1571.  * Define bits for the basic types and their adjectives
  1572.  */
  1573.  
  1574. #define    T_CHAR          1
  1575. #define    T_INT          2
  1576. #define    T_FLOAT          4
  1577. #define    T_DOUBLE      8
  1578. #define    T_SHORT         16
  1579. #define    T_LONG         32
  1580. #define    T_SIGNED     64
  1581. #define    T_UNSIGNED    128
  1582. #define    T_PTR        256        /* Pointer            */
  1583. #define    T_FPTR        512        /* Pointer to functions        */
  1584.  
  1585. /*
  1586.  * The DEFBUF structure stores information about #defined
  1587.  * macros.  Note that the defbuf->repl information is always
  1588.  * in malloc storage.
  1589.  */
  1590.  
  1591. typedef struct defbuf {
  1592.     struct defbuf    *link;        /* Next define in chain    */
  1593.     char        *repl;        /* -> replacement    */
  1594.     int        hash;        /* Symbol table hash    */
  1595.     int        nargs;        /* For define(args)    */
  1596.     char        name[1];    /* #define name        */
  1597. } DEFBUF;
  1598.  
  1599. /*
  1600.  * The FILEINFO structure stores information about open files
  1601.  * and macros being expanded.
  1602.  */
  1603.  
  1604. typedef struct fileinfo {
  1605.     char        *bptr;        /* Buffer pointer    */
  1606.     int        line;        /* for include or macro    */
  1607.     FILE        *fp;        /* File if non-null    */
  1608.     struct fileinfo    *parent;    /* Link to includer    */
  1609.     char        *filename;    /* File/macro name    */
  1610.     char        *progname;    /* From #line statement    */
  1611.     unsigned int    unrecur;    /* For macro recursion    */
  1612.     char        buffer[1];    /* current input line    */
  1613. } FILEINFO;
  1614.  
  1615. /*
  1616.  * The SIZES structure is used to store the values for #if sizeof
  1617.  */
  1618.  
  1619. typedef struct sizes {
  1620.     short    bits;            /* If this bit is set,        */
  1621.     short    size;            /* this is the datum size value    */
  1622.     short    psize;            /* this is the pointer size    */
  1623. } SIZES;
  1624. /*
  1625.  * nomacarg is a built-in #define on Decus C.
  1626.  */
  1627.  
  1628. #ifdef    nomacarg
  1629. #define    cput        output        /* cput concatenates tokens    */
  1630. #else
  1631. #if COMMENT_INVISIBLE
  1632. #define    cput(c)        { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
  1633. #else
  1634. #define    cput(c)        { if (c != TOK_SEP) putchar(c); }
  1635. #endif
  1636. #endif
  1637.  
  1638. #ifndef    nomacarg
  1639. #define    streq(s1, s2)    (strcmp(s1, s2) == 0)
  1640. #endif
  1641.  
  1642. /*
  1643.  * Error codes.  VMS uses system definitions.
  1644.  * Decus C codes are defined in stdio.h.
  1645.  * Others are cooked to order.
  1646.  */
  1647.  
  1648. #if HOST == SYS_VMS
  1649. #include        <ssdef.h>
  1650. #include        <stsdef.h>
  1651. #define    IO_NORMAL    (SS$_NORMAL | STS$M_INHIB_MSG)
  1652. #define    IO_ERROR    SS$_ABORT
  1653. #endif
  1654. /*
  1655.  * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
  1656.  */
  1657. #ifndef    IO_NORMAL
  1658. #define    IO_NORMAL    0
  1659. #endif
  1660. #ifndef    IO_ERROR
  1661. #define    IO_ERROR    1
  1662. #endif
  1663.  
  1664. /*
  1665.  * Externs
  1666.  */
  1667.  
  1668. extern int    line;            /* Current line number        */
  1669. extern int    wrongline;        /* Force #line to cc pass 1    */
  1670. extern char    type[];            /* Character classifier        */
  1671. extern char    token[IDMAX + 1];    /* Current input token        */
  1672. extern int    instring;        /* TRUE if scanning string    */
  1673. extern int    inmacro;        /* TRUE if scanning #define    */
  1674. extern int    errors;            /* Error counter        */
  1675. extern int    recursion;        /* Macro depth counter        */
  1676. extern char    ifstack[BLK_NEST];    /* #if information        */
  1677. #define    compiling ifstack[0]
  1678. extern char    *ifptr;            /* -> current ifstack item    */
  1679. extern char    *incdir[NINCLUDE];    /* -i directories        */
  1680. extern char    **incend;        /* -> active end of incdir    */
  1681. extern int    cflag;            /* -C option (keep comments)    */
  1682. extern int    eflag;            /* -E option (ignore errors)    */
  1683. extern int    nflag;            /* -N option (no pre-defines)    */
  1684. extern int    rec_recover;        /* unwind recursive macros    */
  1685. extern char    *preset[];        /* Standard predefined symbols    */
  1686. extern char    *magic[];        /* Magic predefined symbols    */
  1687. extern FILEINFO    *infile;        /* Current input file        */
  1688. extern char    work[NWORK + 1];    /* #define scratch        */
  1689. extern char    *workp;            /* Free space in work        */
  1690. #if    DEBUG
  1691. extern int    debug;            /* Debug level            */
  1692. #endif
  1693. extern int    keepcomments;        /* Don't remove comments if set    */
  1694. extern SIZES    size_table[];        /* For #if sizeof sizes        */
  1695. extern char    *getmem();        /* Get memory or die.        */
  1696. extern DEFBUF    *lookid();        /* Look for a #define'd thing    */
  1697. extern DEFBUF    *defendel();        /* Symbol table enter/delete    */
  1698. extern char    *savestring();        /* Stuff string in malloc mem.    */
  1699. extern char    *strcpy();
  1700. extern char    *strcat();
  1701. extern char    *strrchr();
  1702. extern char    *strchr();
  1703. extern long    time();
  1704. extern char    *sprintf();        /* Lint needs this        */
  1705. -h- cppdef.h    Mon Jan  7 23:59:27 1985    cppdef.h
  1706. /*
  1707.  *           S y s t e m   D e p e n d e n t
  1708.  *        D e f i n i t i o n s    f o r   C P P
  1709.  *
  1710.  * Definitions in this file may be edited to configure CPP for particular
  1711.  * host operating systems and target configurations.
  1712.  *
  1713.  * NOTE: cpp assumes it is compiled by a compiler that supports macros
  1714.  * with arguments.  If this is not the case (as for Decus C), #define
  1715.  * nomacarg -- and provide function equivalents for all macros.
  1716.  *
  1717.  * cpp also assumes the host and target implement the Ascii character set.
  1718.  * If this is not the case, you will have to do some editing here and there.
  1719.  */
  1720.  
  1721. /*
  1722.  * This redundant definition of TRUE and FALSE works around
  1723.  * a limitation of Decus C.
  1724.  */
  1725. #ifndef    TRUE
  1726. #define    TRUE            1
  1727. #define    FALSE            0
  1728. #endif
  1729.  
  1730. /*
  1731.  * Define the HOST operating system.  This is needed so that
  1732.  * cpp can use appropriate filename conventions.
  1733.  */
  1734. #define    SYS_UNKNOWN        0
  1735. #define    SYS_UNIX        1
  1736. #define    SYS_VMS            2
  1737. #define    SYS_RSX            3
  1738. #define    SYS_RT11        4
  1739. #define    SYS_LATTICE        5
  1740. #define    SYS_ONYX        6
  1741. #define    SYS_68000        7
  1742.  
  1743. #ifndef    HOST
  1744. #ifdef    unix
  1745. #define    HOST            SYS_UNIX
  1746. #else
  1747. #ifdef    vms
  1748. #define    HOST            SYS_VMS
  1749. #else
  1750. #ifdef    rsx
  1751. #define    HOST            SYS_RSX
  1752. #else
  1753. #ifdef    rt11
  1754. #define    HOST            SYS_RT11
  1755. #endif
  1756. #endif
  1757. #endif
  1758. #endif
  1759. #endif
  1760.  
  1761. #ifndef    HOST
  1762. #define    HOST            SYS_UNKNOWN
  1763. #endif
  1764.  
  1765. /*
  1766.  * We assume that the target is the same as the host system
  1767.  */
  1768. #ifndef    TARGET
  1769. #define    TARGET            HOST
  1770. #endif
  1771.  
  1772. /*
  1773.  * In order to predefine machine-dependent constants,
  1774.  * several strings are defined here:
  1775.  *
  1776.  * MACHINE    defines the target cpu (by name)
  1777.  * SYSTEM    defines the target operating system
  1778.  * COMPILER    defines the target compiler
  1779.  *
  1780.  *    The above may be #defined as "" if they are not wanted.
  1781.  *    They should not be #defined as NULL.
  1782.  *
  1783.  * LINE_PREFIX    defines the # output line prefix, if not "line"
  1784.  *        This should be defined as "" if cpp is to replace
  1785.  *        the "standard" C pre-processor.
  1786.  *
  1787.  * FILE_LOCAL    marks functions which are referenced only in the
  1788.  *        file they reside.  Some C compilers allow these
  1789.  *        to be marked "static" even though they are referenced
  1790.  *        by "extern" statements elsewhere.
  1791.  *
  1792.  * OK_DOLLAR    Should be set TRUE if $ is a valid alphabetic character
  1793.  *        in identifiers (default), or zero if $ is invalid.
  1794.  *        Default is TRUE.
  1795.  *
  1796.  * OK_CONCAT    Should be set TRUE if # may be used to concatenate
  1797.  *        tokens in macros (per the Ansi Draft Standard) or
  1798.  *        FALSE for old-style # processing (needed if cpp is
  1799.  *        to process assembler source code).
  1800.  *
  1801.  * OK_DATE    Predefines the compilation date if set TRUE.
  1802.  *        Not permitted by the Nov. 12, 1984 Draft Standard.
  1803.  *
  1804.  * S_CHAR etc.    Define the sizeof the basic TARGET machine word types.
  1805.  *        By default, sizes are set to the values for the HOST
  1806.  *        computer.  If this is inappropriate, see the code in
  1807.  *        cpp3.c for details on what to change.  Also, if you
  1808.  *        have a machine where sizeof (signed int) differs from
  1809.  *        sizeof (unsigned int), you will have to edit code and
  1810.  *        tables in cpp3.c (and extend the -S option definition.)
  1811.  *
  1812.  * CPP_LIBRARY    May be defined if you have a site-specific include directory
  1813.  *        which is to be searched *before* the operating-system
  1814.  *        specific directories.
  1815.  */
  1816.  
  1817. #if TARGET == SYS_LATTICE
  1818. /*
  1819.  * We assume the operating system is pcdos for the IBM-PC.
  1820.  * We also assume the small model (just like the PDP-11)
  1821.  */
  1822. #define MACHINE            "i8086"
  1823. #define    SYSTEM            "pcdos"
  1824. #endif
  1825.  
  1826. #if TARGET == SYS_ONYX
  1827. #define    MACHINE            "z8000"
  1828. #define    SYSTEM            "unix"
  1829. #endif
  1830.  
  1831. #if TARGET == SYS_VMS
  1832. #define    MACHINE            "vax"
  1833. #define    SYSTEM            "vms"
  1834. #define    COMPILER        "vax11c"
  1835. #endif
  1836.  
  1837. #if TARGET == SYS_RSX
  1838. #define    MACHINE            "pdp11"
  1839. #define    SYSTEM            "rsx"
  1840. #define    COMPILER        "decus"
  1841. #endif
  1842.  
  1843. #if TARGET == SYS_RT11
  1844. #define    MACHINE            "pdp11"
  1845. #define    SYSTEM            "rt11"
  1846. #define    COMPILER        "decus"
  1847. #endif
  1848.  
  1849. #if TARGET == SYS_68000
  1850. /*
  1851.  * All three machine designators have been seen in various systems.
  1852.  * Warning -- compilers differ as to sizeof (int).  cpp3 assumes that
  1853.  * sizeof (int) == 2
  1854.  */
  1855. #define    MACHINE            "M68000", "m68000", "m68k"
  1856. #define    SYSTEM            "unix"
  1857. #endif
  1858.  
  1859. #if    TARGET == SYS_UNIX
  1860. #define    SYSTEM            "unix"
  1861. #ifdef    pdp11
  1862. #define    MACHINE            "pdp11"
  1863. #endif
  1864. #ifdef    vax
  1865. #define    MACHINE            "vax"
  1866. #endif
  1867. #endif
  1868.  
  1869. /*
  1870.  * defaults
  1871.  */
  1872.  
  1873. #ifndef MSG_PREFIX
  1874. #define MSG_PREFIX        "cpp: "
  1875. #endif
  1876.  
  1877. #ifndef LINE_PREFIX
  1878. #ifdef    decus
  1879. #define    LINE_PREFIX        ""
  1880. #else
  1881. #define LINE_PREFIX        "line"
  1882. #endif
  1883. #endif
  1884.  
  1885. /*
  1886.  * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT,
  1887.  * COMMENT_INVISIBLE, and STRING_FORMAL to values appropriate for
  1888.  * an old-style preprocessor.
  1889.  */
  1890.  
  1891. #ifndef    OLD_PREPROCESSOR
  1892. #define    OLD_PREPROCESSOR    FALSE
  1893. #endif
  1894.  
  1895. #if    OLD_PREPROCESSOR
  1896. #define    OK_DOLLAR        FALSE
  1897. #define    OK_CONCAT        FALSE
  1898. #define    COMMENT_INVISIBLE    TRUE
  1899. #define    STRING_FORMAL        TRUE
  1900. #endif
  1901.  
  1902. /*
  1903.  * RECURSION_LIMIT may be set to -1 to disable the macro recursion test.
  1904.  */
  1905. #ifndef    RECURSION_LIMIT
  1906. #define    RECURSION_LIMIT    1000
  1907. #endif
  1908.  
  1909. /*
  1910.  * BITS_CHAR may be defined to set the number of bits per character.
  1911.  * it is needed only for multi-byte character constants.
  1912.  */
  1913. #ifndef    BITS_CHAR
  1914. #define    BITS_CHAR        8
  1915. #endif
  1916.  
  1917. /*
  1918.  * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
  1919.  * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
  1920.  * It is set FALSE on machines (such as the PDP-11 and Vax-11)
  1921.  * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
  1922.  * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
  1923.  */
  1924. #ifndef    BIG_ENDIAN
  1925. #define    BIG_ENDIAN         FALSE
  1926. #endif
  1927.  
  1928. /*
  1929.  * COMMENT_INVISIBLE may be defined to allow "old-style" comment
  1930.  * processing, whereby the comment becomes a zero-length token
  1931.  * delimiter.  This permitted tokens to be concatenated in macro
  1932.  * expansions.  This was removed from the Draft Ansi Standard.
  1933.  */
  1934. #ifndef    COMMENT_INVISIBLE
  1935. #define    COMMENT_INVISIBLE    FALSE
  1936. #endif
  1937.  
  1938. /*
  1939.  * STRING_FORMAL may be defined to allow recognition of macro parameters
  1940.  * anywhere in replacement strings.  This was removed from the Draft Ansi
  1941.  * Standard and a limited recognition capability added.
  1942.  */
  1943. #ifndef    STRING_FORMAL
  1944. #define    STRING_FORMAL        FALSE
  1945. #endif
  1946.  
  1947. /*
  1948.  * OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
  1949.  * This is a permitted extension to the Ansi Standard and is required
  1950.  * for e.g., VMS, RSX-11M, etc.   It should be set FALSE if cpp is
  1951.  * used to preprocess assembler source on Unix systems.  OLD_PREPROCESSOR
  1952.  * sets OK_DOLLAR FALSE for that reason.
  1953.  */
  1954. #ifndef    OK_DOLLAR
  1955. #define    OK_DOLLAR        TRUE
  1956. #endif
  1957.  
  1958. /*
  1959.  * OK_CONCAT enables (one possible implementation of) token concatenation.
  1960.  * If cpp is used to preprocess Unix assembler source, this should be
  1961.  * set FALSE as the concatenation character, #, is used by the assembler.
  1962.  */
  1963. #ifndef    OK_CONCAT
  1964. #define    OK_CONCAT        TRUE
  1965. #endif
  1966.  
  1967. /*
  1968.  * OK_DATE may be enabled to predefine today's date as a string
  1969.  * at the start of each compilation.  This is apparently not permitted
  1970.  * by the Draft Ansi Standard.
  1971.  */
  1972. #ifndef    OK_DATE
  1973. #define    OK_DATE        TRUE
  1974. #endif
  1975.  
  1976. /*
  1977.  * Some common definitions.
  1978.  */
  1979.  
  1980. #ifndef    DEBUG
  1981. #define    DEBUG            FALSE
  1982. #endif
  1983.  
  1984. /*
  1985.  * The following definitions are used to allocate memory for
  1986.  * work buffers.  In general, they should not be modified
  1987.  * by implementors.
  1988.  *
  1989.  * PAR_MAC    The maximum number of #define parameters (31 per Standard)
  1990.  *        Note: we need another one for strings.
  1991.  * IDMAX    The longest identifier, 31 per Ansi Standard
  1992.  * NBUFF    Input buffer size
  1993.  * NWORK    Work buffer size -- the longest macro
  1994.  *        must fit here after expansion.
  1995.  * NEXP        The nesting depth of #if expressions
  1996.  * NINCLUDE    The number of directories that may be specified
  1997.  *        on a per-system basis, or by the -I option.
  1998.  * BLK_NEST    The number of nested #if's permitted.
  1999.  */
  2000.  
  2001. #define    IDMAX             31
  2002. #define    PAR_MAC           (31 + 1)
  2003. #define    NBUFF            512
  2004. #define    NWORK            512
  2005. #define    NEXP            128
  2006. #define    NINCLUDE          7
  2007. #define    NPARMWORK        (NWORK * 2)
  2008. #define    BLK_NEST        32
  2009.  
  2010. /*
  2011.  * Some special constants.  These may need to be changed if cpp
  2012.  * is ported to a wierd machine.
  2013.  *
  2014.  * NOTE: if cpp is run on a non-ascii machine, ALERT and VT may
  2015.  * need to be changed.  They are used to implement the proposed
  2016.  * ANSI standard C control characters '\a' and '\v' only.
  2017.  * DEL is used to tag macro tokens to prevent #define foo foo
  2018.  * from looping.  Note that we don't try to prevent more elaborate
  2019.  * #define loops from occurring.
  2020.  */
  2021.  
  2022. #ifndef    ALERT
  2023. #define    ALERT            '\007'        /* '\a' is "Bell"    */
  2024. #endif
  2025.  
  2026. #ifndef    VT
  2027. #define    VT            '\013'        /* Vertical Tab CTRL/K    */
  2028. #endif
  2029.  
  2030.  
  2031. #ifndef    FILE_LOCAL
  2032. #ifdef    decus
  2033. #define    FILE_LOCAL        static
  2034. #else
  2035. #ifdef    vax11c
  2036. #define    FILE_LOCAL        static
  2037. #else
  2038. #define    FILE_LOCAL                /* Others are global    */
  2039. #endif
  2040. #endif
  2041. #endif
  2042.  
  2043.