home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / f2c / src / lex.c < prev    next >
C/C++ Source or Header  |  2000-06-23  |  30KB  |  1,470 lines

  1. /****************************************************************
  2. Copyright 1990, 1992 by AT&T Bell Laboratories and Bellcore.
  3.  
  4. Permission to use, copy, modify, and distribute this software
  5. and its documentation for any purpose and without fee is hereby
  6. granted, provided that the above copyright notice appear in all
  7. copies and that both that the copyright notice and this
  8. permission notice and warranty disclaimer appear in supporting
  9. documentation, and that the names of AT&T Bell Laboratories or
  10. Bellcore or any of their entities not be used in advertising or
  11. publicity pertaining to distribution of the software without
  12. specific, written prior permission.
  13.  
  14. AT&T and Bellcore disclaim all warranties with regard to this
  15. software, including all implied warranties of merchantability
  16. and fitness.  In no event shall AT&T or Bellcore be liable for
  17. any special, indirect or consequential damages or any damages
  18. whatsoever resulting from loss of use, data or profits, whether
  19. in an action of contract, negligence or other tortious action,
  20. arising out of or in connection with the use or performance of
  21. this software.
  22. ****************************************************************/
  23.  
  24. #include "defs.h"
  25. #include "tokdefs.h"
  26. #include "p1defs.h"
  27.  
  28. #define BLANK    ' '
  29. #define MYQUOTE (2)
  30. #define SEOF 0
  31.  
  32. /* card types */
  33.  
  34. #define STEOF 1
  35. #define STINITIAL 2
  36. #define STCONTINUE 3
  37.  
  38. /* lex states */
  39.  
  40. #define NEWSTMT    1
  41. #define FIRSTTOKEN    2
  42. #define OTHERTOKEN    3
  43. #define RETEOS    4
  44.  
  45.  
  46. LOCAL int stkey;    /* Type of the current statement (DO, END, IF, etc) */
  47. extern char token[];    /* holds the actual token text */
  48. static int needwkey;
  49. ftnint yystno;
  50. flag intonly;
  51. extern int new_dcl;
  52. LOCAL long int stno;
  53. LOCAL long int nxtstno;    /* Statement label */
  54. LOCAL int parlev;    /* Parentheses level */
  55. LOCAL int parseen;
  56. LOCAL int expcom;
  57. LOCAL int expeql;
  58. LOCAL char *nextch;
  59. LOCAL char *lastch;
  60. LOCAL char *nextcd     = NULL;
  61. LOCAL char *endcd;
  62. LOCAL long prevlin;
  63. LOCAL long thislin;
  64. LOCAL int code;        /* Card type; INITIAL, CONTINUE or EOF */
  65. LOCAL int lexstate    = NEWSTMT;
  66. LOCAL char sbuf[1390];    /* Main buffer for Fortran source input.  The number
  67.                comes from lines of at most 66 characters, with at
  68.                most 20 continuation cards (or something); this is
  69.                part of the defn of the standard */
  70. LOCAL char *send    = sbuf+20*66;
  71. LOCAL int nincl    = 0;    /* Current number of include files */
  72. LOCAL long firstline;
  73. LOCAL char *laststb, *stb0;
  74. extern int addftnsrc;
  75. #define CONTMAX 100    /* max continuation lines for ! processing */
  76. char *linestart[CONTMAX];
  77. LOCAL int ncont;
  78. LOCAL char comstart[Table_size];
  79. #define USC (unsigned char *)
  80.  
  81. static char anum_buf[Table_size];
  82. #define isalnum_(x) anum_buf[x]
  83. #define isalpha_(x) (anum_buf[x] == 1)
  84.  
  85. #define COMMENT_BUF_STORE 4088
  86.  
  87. typedef struct comment_buf {
  88.     struct comment_buf *next;
  89.     char *last;
  90.     char buf[COMMENT_BUF_STORE];
  91.     } comment_buf;
  92. static comment_buf *cbfirst, *cbcur;
  93. static char *cbinit, *cbnext, *cblast;
  94. static void flush_comments();
  95. extern flag use_bs;
  96.  
  97.  
  98. /* Comment buffering data
  99.  
  100.     Comments are kept in a list until the statement before them has
  101.    been parsed.  This list is implemented with the above comment_buf
  102.    structure and the pointers cbnext and cblast.
  103.  
  104.     The comments are stored with terminating NULL, and no other
  105.    intervening space.  The last few bytes of each block are likely to
  106.    remain unused.
  107. */
  108.  
  109. /* struct Inclfile   holds the state information for each include file */
  110. struct Inclfile
  111. {
  112.     struct Inclfile *inclnext;
  113.     FILEP inclfp;
  114.     char *inclname;
  115.     int incllno;
  116.     char *incllinp;
  117.     int incllen;
  118.     int inclcode;
  119.     ftnint inclstno;
  120. };
  121.  
  122. LOCAL struct Inclfile *inclp    =  NULL;
  123. struct Keylist {
  124.     char *keyname;
  125.     int keyval;
  126.     char notinf66;
  127. };
  128. struct Punctlist {
  129.     char punchar;
  130.     int punval;
  131. };
  132. struct Fmtlist {
  133.     char fmtchar;
  134.     int fmtval;
  135. };
  136. struct Dotlist {
  137.     char *dotname;
  138.     int dotval;
  139.     };
  140. LOCAL struct Keylist *keystart[26], *keyend[26];
  141.  
  142. /* KEYWORD AND SPECIAL CHARACTER TABLES
  143. */
  144.  
  145. static struct Punctlist puncts[ ] =
  146. {
  147.     '(', SLPAR,
  148.     ')', SRPAR,
  149.     '=', SEQUALS,
  150.     ',', SCOMMA,
  151.     '+', SPLUS,
  152.     '-', SMINUS,
  153.     '*', SSTAR,
  154.     '/', SSLASH,
  155.     '$', SCURRENCY,
  156.     ':', SCOLON,
  157.     '<', SLT,
  158.     '>', SGT,
  159.     0, 0 };
  160.  
  161. LOCAL struct Dotlist  dots[ ] =
  162. {
  163.     "and.", SAND,
  164.         "or.", SOR,
  165.         "not.", SNOT,
  166.         "true.", STRUE,
  167.         "false.", SFALSE,
  168.         "eq.", SEQ,
  169.         "ne.", SNE,
  170.         "lt.", SLT,
  171.         "le.", SLE,
  172.         "gt.", SGT,
  173.         "ge.", SGE,
  174.         "neqv.", SNEQV,
  175.         "eqv.", SEQV,
  176.         0, 0 };
  177.  
  178. LOCAL struct Keylist  keys[ ] =
  179. {
  180.     { "assign",  SASSIGN  },
  181.     { "automatic",  SAUTOMATIC, YES  },
  182.     { "backspace",  SBACKSPACE  },
  183.     { "blockdata",  SBLOCK  },
  184.     { "call",  SCALL  },
  185.     { "character",  SCHARACTER, YES  },
  186.     { "close",  SCLOSE, YES  },
  187.     { "common",  SCOMMON  },
  188.     { "complex",  SCOMPLEX  },
  189.     { "continue",  SCONTINUE  },
  190.     { "data",  SDATA  },
  191.     { "dimension",  SDIMENSION  },
  192.     { "doubleprecision",  SDOUBLE  },
  193.     { "doublecomplex", SDCOMPLEX, YES  },
  194.     { "elseif",  SELSEIF, YES  },
  195.     { "else",  SELSE, YES  },
  196.     { "endfile",  SENDFILE  },
  197.     { "endif",  SENDIF, YES  },
  198.     { "enddo", SENDDO, YES },
  199.     { "end",  SEND  },
  200.     { "entry",  SENTRY, YES  },
  201.     { "equivalence",  SEQUIV  },
  202.     { "external",  SEXTERNAL  },
  203.     { "format",  SFORMAT  },
  204.     { "function",  SFUNCTION  },
  205.     { "goto",  SGOTO  },
  206.     { "implicit",  SIMPLICIT, YES  },
  207.     { "include",  SINCLUDE, YES  },
  208.     { "inquire",  SINQUIRE, YES  },
  209.     { "intrinsic",  SINTRINSIC, YES  },
  210.     { "integer",  SINTEGER  },
  211.     { "logical",  SLOGICAL  },
  212.     { "namelist", SNAMELIST, YES },
  213.     { "none", SUNDEFINED, YES },
  214.     { "open",  SOPEN, YES  },
  215.     { "parameter",  SPARAM, YES  },
  216.     { "pause",  SPAUSE  },
  217.     { "print",  SPRINT  },
  218.     { "program",  SPROGRAM, YES  },
  219.     { "punch",  SPUNCH, YES  },
  220.     { "read",  SREAD  },
  221.     { "real",  SREAL  },
  222.     { "return",  SRETURN  },
  223.     { "rewind",  SREWIND  },
  224.     { "save",  SSAVE, YES  },
  225.     { "static",  SSTATIC, YES  },
  226.     { "stop",  SSTOP  },
  227.     { "subroutine",  SSUBROUTINE  },
  228.     { "then",  STHEN, YES  },
  229.     { "undefined", SUNDEFINED, YES  },
  230.     { "while", SWHILE, YES  },
  231.     { "write",  SWRITE  },
  232.     { 0, 0 }
  233. };
  234.  
  235. LOCAL void analyz(), crunch(), store_comment();
  236. LOCAL int getcd(), getcds(), getkwd(), gettok();
  237. LOCAL char *stbuf[3];
  238.  
  239. inilex(name)
  240. char *name;
  241. {
  242.     stbuf[0] = Alloc(3*P1_STMTBUFSIZE);
  243.     stbuf[1] = stbuf[0] + P1_STMTBUFSIZE;
  244.     stbuf[2] = stbuf[1] + P1_STMTBUFSIZE;
  245.     nincl = 0;
  246.     inclp = NULL;
  247.     doinclude(name);
  248.     lexstate = NEWSTMT;
  249.     return(NO);
  250. }
  251.  
  252.  
  253.  
  254. /* throw away the rest of the current line */
  255. flline()
  256. {
  257.     lexstate = RETEOS;
  258. }
  259.  
  260.  
  261.  
  262. char *lexline(n)
  263. int *n;
  264. {
  265.     *n = (lastch - nextch) + 1;
  266.     return(nextch);
  267. }
  268.  
  269.  
  270.  
  271.  
  272.  
  273. doinclude(name)
  274. char *name;
  275. {
  276.     FILEP fp;
  277.     struct Inclfile *t;
  278.  
  279.     if(inclp)
  280.     {
  281.         inclp->incllno = thislin;
  282.         inclp->inclcode = code;
  283.         inclp->inclstno = nxtstno;
  284.         if(nextcd)
  285.             inclp->incllinp = copyn(inclp->incllen = endcd-nextcd , nextcd);
  286.         else
  287.             inclp->incllinp = 0;
  288.     }
  289.     nextcd = NULL;
  290.  
  291.     if(++nincl >= MAXINCLUDES)
  292.         Fatal("includes nested too deep");
  293.     if(name[0] == '\0')
  294.         fp = stdin;
  295.     else
  296.         fp = fopen(name, textread);
  297.     if (fp)
  298.     {
  299.         t = inclp;
  300.         inclp = ALLOC(Inclfile);
  301.         inclp->inclnext = t;
  302.         prevlin = thislin = 0;
  303.         infname = inclp->inclname = name;
  304.         infile = inclp->inclfp = fp;
  305.     }
  306.     else
  307.     {
  308.         fprintf(diagfile, "Cannot open file %s\n", name);
  309.         done(1);
  310.     }
  311. }
  312.  
  313.  
  314.  
  315.  
  316. LOCAL popinclude()
  317. {
  318.     struct Inclfile *t;
  319.     register char *p;
  320.     register int k;
  321.  
  322.     if(infile != stdin)
  323.         clf(&infile, infname, 1);    /* Close the input file */
  324.     free(infname);
  325.  
  326.     --nincl;
  327.     t = inclp->inclnext;
  328.     free( (charptr) inclp);
  329.     inclp = t;
  330.     if(inclp == NULL) {
  331.         infname = 0;
  332.         return(NO);
  333.         }
  334.  
  335.     infile = inclp->inclfp;
  336.     infname = inclp->inclname;
  337.     prevlin = thislin = inclp->incllno;
  338.     code = inclp->inclcode;
  339.     stno = nxtstno = inclp->inclstno;
  340.     if(inclp->incllinp)
  341.     {
  342.         endcd = nextcd = sbuf;
  343.         k = inclp->incllen;
  344.         p = inclp->incllinp;
  345.         while(--k >= 0)
  346.             *endcd++ = *p++;
  347.         free( (charptr) (inclp->incllinp) );
  348.     }
  349.     else
  350.         nextcd = NULL;
  351.     return(YES);
  352. }
  353.  
  354.  static void
  355. putlineno()
  356. {
  357.     static long lastline;
  358.     static char *lastfile = "??", *lastfile0 = "?";
  359.     static char fbuf[P1_FILENAME_MAX];
  360.     extern int gflag;
  361.     register char *s0, *s1;
  362.  
  363.     if (gflag) {
  364.         if (lastline) {
  365.             if (lastfile != lastfile0) {
  366.                 p1puts(P1_FILENAME, fbuf);
  367.                 lastfile0 = lastfile;
  368.                 }
  369.             p1_line_number(lastline);
  370.             }
  371.         lastline = firstline;
  372.         if (lastfile != infname)
  373.             if (lastfile = infname) {
  374.                 strncpy(fbuf, lastfile, sizeof(fbuf));
  375.                 fbuf[sizeof(fbuf)-1] = 0;
  376.                 }
  377.             else
  378.                 fbuf[0] = 0;
  379.         }
  380.     if (addftnsrc) {
  381.         if (laststb && *laststb) {
  382.             for(s1 = laststb; *s1; s1++) {
  383.                 for(s0 = s1; *s1 != '\n'; s1++)
  384.                     if (*s1 == '*' && s1[1] == '/')
  385.                         *s1 = '+';
  386.                 *s1 = 0;
  387.                 p1puts(P1_FORTRAN, s0);
  388.                 }
  389.             *laststb = 0;    /* prevent trouble after EOF */
  390.             }
  391.         laststb = stb0;
  392.         }
  393.     }
  394.  
  395.  
  396. yylex()
  397. {
  398.     static int  tokno;
  399.     int retval;
  400.  
  401.     switch(lexstate)
  402.     {
  403.     case NEWSTMT :    /* need a new statement */
  404.         retval = getcds();
  405.         putlineno();
  406.         if(retval == STEOF) {
  407.             retval = SEOF;
  408.             break;
  409.         } /* if getcds() == STEOF */
  410.         crunch();
  411.         tokno = 0;
  412.         lexstate = FIRSTTOKEN;
  413.         yystno = stno;
  414.         stno = nxtstno;
  415.         toklen = 0;
  416.         retval = SLABEL;
  417.         break;
  418.  
  419. first:
  420.     case FIRSTTOKEN :    /* first step on a statement */
  421.         analyz();
  422.         lexstate = OTHERTOKEN;
  423.         tokno = 1;
  424.         retval = stkey;
  425.         break;
  426.  
  427.     case OTHERTOKEN :    /* return next token */
  428.         if(nextch > lastch)
  429.             goto reteos;
  430.         ++tokno;
  431.         if( (stkey==SLOGIF || stkey==SELSEIF) && parlev==0 && tokno>3)
  432.             goto first;
  433.  
  434.         if(stkey==SASSIGN && tokno==3 && nextch<lastch &&
  435.             nextch[0]=='t' && nextch[1]=='o')
  436.         {
  437.             nextch+=2;
  438.             retval = STO;
  439.             break;
  440.         }
  441.         retval = gettok();
  442.         break;
  443.  
  444. reteos:
  445.     case RETEOS:
  446.         lexstate = NEWSTMT;
  447.         retval = SEOS;
  448.         break;
  449.     default:
  450.         fatali("impossible lexstate %d", lexstate);
  451.         break;
  452.     }
  453.  
  454.     if (retval == SEOF)
  455.         flush_comments ();
  456.  
  457.     return retval;
  458. }
  459.  
  460. /* Get Cards.
  461.  
  462.    Returns STEOF or STINITIAL, never STCONTINUE.  Any continuation cards get
  463. merged into one long card (hence the size of the buffer named   sbuf)   */
  464.  
  465.  LOCAL int
  466. getcds()
  467. {
  468.     register char *p, *q;
  469.  
  470.     flush_comments ();
  471. top:
  472.     if(nextcd == NULL)
  473.     {
  474.         code = getcd( nextcd = sbuf, 1 );
  475.         stno = nxtstno;
  476.         prevlin = thislin;
  477.     }
  478.     if(code == STEOF)
  479.         if( popinclude() )
  480.             goto top;
  481.         else
  482.             return(STEOF);
  483.  
  484.     if(code == STCONTINUE)
  485.     {
  486.         lineno = thislin;
  487.         nextcd = NULL;
  488.         goto top;
  489.     }
  490.  
  491. /* Get rid of unused space at the head of the buffer */
  492.  
  493.     if(nextcd > sbuf)
  494.     {
  495.         q = nextcd;
  496.         p = sbuf;
  497.         while(q < endcd)
  498.             *p++ = *q++;
  499.         endcd = p;
  500.     }
  501.  
  502. /* Be aware that the input (i.e. the string at the address   nextcd)   is NOT
  503.    NULL-terminated */
  504.  
  505. /* This loop merges all continuations into one long statement, AND puts the next
  506.    card to be read at the end of the buffer (i.e. it stores the look-ahead card
  507.    when there's room) */
  508.  
  509.     ncont = 0;
  510.     do {
  511.         nextcd = endcd;
  512.         if (ncont < CONTMAX)
  513.             linestart[ncont++] = nextcd;
  514.         }
  515.         while(nextcd+66<=send && (code = getcd(nextcd,0))==STCONTINUE);
  516.     nextch = sbuf;
  517.     lastch = nextcd - 1;
  518.  
  519. /* Handle buffer overflow by zeroing the 'next' pointer   (nextcd)   so that
  520.    the top of this function will initialize it next time it is called */
  521.  
  522.     if(nextcd >= send)
  523.         nextcd = NULL;
  524.     lineno = prevlin;
  525.     prevlin = thislin;
  526.     return(STINITIAL);
  527. }
  528.  
  529.  static void
  530. bang(a,b,c,d,e)        /* save ! comments */
  531.  char *a, *b, *c;
  532.  register char *d, *e;
  533. {
  534.     char buf[COMMENT_BUFFER_SIZE + 1];
  535.     register char *p, *pe;
  536.  
  537.     p = buf;
  538.     pe = buf + COMMENT_BUFFER_SIZE;
  539.     *pe = 0;
  540.     while(a < b)
  541.         if (!(*p++ = *a++))
  542.             p[-1] = 0;
  543.     if (b < c)
  544.         *p++ = '\t';
  545.     while(d < e) {
  546.         if (!(*p++ = *d++))
  547.             p[-1] = ' ';
  548.         if (p == pe) {
  549.             store_comment(buf);
  550.             p = buf;
  551.             }
  552.         }
  553.     if (p > buf) {
  554.         while(--p >= buf && *p == ' ');
  555.         p[1] = 0;
  556.         store_comment(buf);
  557.         }
  558.     }
  559.  
  560.  
  561. /* getcd - Get next input card
  562.  
  563.     This function reads the next input card from global file pointer   infile.
  564. It assumes that   b   points to currently empty storage somewhere in  sbuf  */
  565.  
  566.  LOCAL int
  567. getcd(b, nocont)
  568.  register char *b;
  569. {
  570.     register int c;
  571.     register char *p, *bend;
  572.     int speclin;        /* Special line - true when the line is allowed
  573.                    to have more than 66 characters (e.g. the
  574.                    "&" shorthand for continuation, use of a "\t"
  575.                    to skip part of the label columns) */
  576.     static char a[6];    /* Statement label buffer */
  577.     static char *aend    = a+6;
  578.     static char *stb, *stbend;
  579.     static int nst;
  580.     char *atend, *endcd0;
  581.     extern int warn72;
  582.     char buf72[24];
  583.     int amp, i;
  584.     char storage[COMMENT_BUFFER_SIZE + 1];
  585.     char *pointer;
  586.  
  587. top:
  588.     endcd = b;
  589.     bend = b+66;
  590.     amp = speclin = NO;
  591.     atend = aend;
  592.  
  593. /* Handle the continuation shorthand of "&" in the first column, which stands
  594.    for "     x" */
  595.  
  596.     if( (c = getc(infile)) == '&')
  597.     {
  598.         a[0] = c;
  599.         a[1] = 0;
  600.         a[5] = 'x';
  601.         amp = speclin = YES;
  602.         bend = send;
  603.         p = aend;
  604.     }
  605.  
  606. /* Handle the Comment cards (a 'C', 'c', '*', or '!' in the first column). */
  607.  
  608.     else if(comstart[c & 0xfff])
  609.     {
  610.         if (feof (infile))
  611.             return STEOF;
  612.  
  613.         storage[COMMENT_BUFFER_SIZE] = c = '\0';
  614.         pointer = storage;
  615.         while( !feof (infile) && (*pointer++ = c = getc(infile)) != '\n') {
  616.  
  617. /* Handle obscure end of file conditions on many machines */
  618.  
  619.             if (feof (infile) && (c == '\377' || c == EOF)) {
  620.                 pointer--;
  621.                 break;
  622.             } /* if (feof (infile)) */
  623.  
  624.             if (c == '\0')
  625.                 *(pointer - 1) = ' ';
  626.  
  627.             if (pointer == &storage[COMMENT_BUFFER_SIZE]) {
  628.                 store_comment (storage);
  629.                 pointer = storage;
  630.             } /* if (pointer == BUFFER_SIZE) */
  631.         } /* while */
  632.  
  633.         if (pointer > storage) {
  634.             if (c == '\n')
  635.  
  636. /* Get rid of the newline */
  637.  
  638.             pointer[-1] = 0;
  639.             else
  640.             *pointer = 0;
  641.  
  642.             store_comment (storage);
  643.         } /* if */
  644.  
  645.         if (feof (infile))
  646.             if (c != '\n')    /* To allow the line index to
  647.                        increment correctly */
  648.             return STEOF;
  649.  
  650.         ++thislin;
  651.         goto top;
  652.     }
  653.  
  654.     else if(c != EOF)
  655.     {
  656.  
  657. /* Load buffer   a   with the statement label */
  658.  
  659.         /* a tab in columns 1-6 skips to column 7 */
  660.         ungetc(c, infile);
  661.         for(p=a; p<aend && (c=getc(infile)) != '\n' && c!=EOF; )
  662.             if(c == '\t')
  663.  
  664. /* The tab character translates into blank characters in the statement label */
  665.  
  666.             {
  667.                 atend = p;
  668.                 while(p < aend)
  669.                     *p++ = BLANK;
  670.                 speclin = YES;
  671.                 bend = send;
  672.             }
  673.             else
  674.                 *p++ = c;
  675.     }
  676.  
  677. /* By now we've read either a continuation character or the statement label
  678.    field */
  679.  
  680.     if(c == EOF)
  681.         return(STEOF);
  682.  
  683. /* The next 'if' block handles lines that have fewer than 7 characters */
  684.  
  685.     if(c == '\n')
  686.     {
  687.         while(p < aend)
  688.             *p++ = BLANK;
  689.  
  690. /* Blank out the buffer on lines which are not longer than 66 characters */
  691.  
  692.         endcd0 = endcd;
  693.         if( ! speclin )
  694.             while(endcd < bend)
  695.                 *endcd++ = BLANK;
  696.     }
  697.     else    {    /* read body of line */
  698.         if (warn72 & 2) {
  699.             speclin = YES;
  700.             bend = send;
  701.             }
  702.         while( endcd<bend && (c=getc(infile)) != '\n' && c!=EOF )
  703.             *endcd++ = c;
  704.         if(c == EOF)
  705.             return(STEOF);
  706.  
  707. /* Drop any extra characters on the input card; this usually means those after
  708.    column 72 */
  709.  
  710.         if(c != '\n')
  711.         {
  712.             i = 0;
  713.             while( (c=getc(infile)) != '\n' && c != EOF)
  714.                 if (i < 23)
  715.                     buf72[i++] = c;
  716.             if (warn72 && i && !speclin) {
  717.                 buf72[i] = 0;
  718.                 if (i >= 23)
  719.                     strcpy(buf72+20, "...");
  720.                 lineno = thislin + 1;
  721.                 errstr("text after column 72: %s", buf72);
  722.                 }
  723.             if(c == EOF)
  724.                 return(STEOF);
  725.         }
  726.  
  727.         endcd0 = endcd;
  728.         if( ! speclin )
  729.             while(endcd < bend)
  730.                 *endcd++ = BLANK;
  731.     }
  732.  
  733. /* The flow of control usually gets to this line (unless an earlier RETURN has
  734.    been taken) */
  735.  
  736.     ++thislin;
  737.  
  738.     /* Fortran 77 specifies that a 0 in column 6 */
  739.     /* does not signify continuation */
  740.  
  741.     if( !isspace(a[5]) && a[5]!='0') {
  742.         if (!amp)
  743.             for(p = a; p < aend;)
  744.                 if (*p++ == '!' && p != aend)
  745.                     goto initcheck;
  746.         if (addftnsrc && stb) {
  747.             if (stbend > stb + 7) { /* otherwise forget col 1-6 */
  748.                 /* kludge around funny p1gets behavior */
  749.                 *stb++ = '$';
  750.                 if (amp)
  751.                     *stb++ = '&';
  752.                 else
  753.                     for(p = a; p < atend;)
  754.                         *stb++ = *p++;
  755.                 }
  756.             if (endcd0 - b > stbend - stb) {
  757.                 if (stb > stbend)
  758.                     stb = stbend;
  759.                 endcd0 = b + (stbend - stb);
  760.                 }
  761.             for(p = b; p < endcd0;)
  762.                 *stb++ = *p++;
  763.             *stb++ = '\n';
  764.             *stb = 0;
  765.             }
  766.         if (nocont) {
  767.             lineno = thislin;
  768.             errstr("illegal continuation card (starts \"%.6s\")",a);
  769.             }
  770.         else if (!amp && strncmp(a,"     ",5)) {
  771.             lineno = thislin;
  772.             errstr("labeled continuation line (starts \"%.6s\")",a);
  773.             }
  774.         return(STCONTINUE);
  775.         }
  776. initcheck:
  777.     for(p=a; p<atend; ++p)
  778.         if( !isspace(*p) ) {
  779.             if (*p++ != '!')
  780.                 goto initline;
  781.             bang(p, atend, aend, b, endcd);
  782.             goto top;
  783.             }
  784.     for(p = b ; p<endcd ; ++p)
  785.         if( !isspace(*p) ) {
  786.             if (*p++ != '!')
  787.                 goto initline;
  788.             bang(a, a, a, p, endcd);
  789.             goto top;
  790.             }
  791.  
  792. /* Skip over blank cards by reading the next one right away */
  793.  
  794.     goto top;
  795.  
  796. initline:
  797.     if (addftnsrc) {
  798.         nst = (nst+1)%3;
  799.         if (!laststb && stb0)
  800.             laststb = stb0;
  801.         stb0 = stb = stbuf[nst];
  802.         *stb++ = '$';    /* kludge around funny p1gets behavior */
  803.         stbend = stb + sizeof(stbuf[0])-2;
  804.         for(p = a; p < atend;)
  805.             *stb++ = *p++;
  806.         if (atend < aend)
  807.             *stb++ = '\t';
  808.         for(p = b; p < endcd0;)
  809.             *stb++ = *p++;
  810.         *stb++ = '\n';
  811.         *stb = 0;
  812.         }
  813.  
  814. /* Set   nxtstno   equal to the integer value of the statement label */
  815.  
  816.     nxtstno = 0;
  817.     bend = a + 5;
  818.     for(p = a ; p < bend ; ++p)
  819.         if( !isspace(*p) )
  820.             if(isdigit(*p))
  821.                 nxtstno = 10*nxtstno + (*p - '0');
  822.             else if (*p == '!') {
  823.                 if (!addftnsrc)
  824.                     bang(p+1,atend,aend,b,endcd);
  825.                 endcd = b;
  826.                 break;
  827.                 }
  828.             else    {
  829.                 lineno = thislin;
  830.                 errstr(
  831.                 "nondigit in statement label field \"%.5s\"", a);
  832.                 nxtstno = 0;
  833.                 break;
  834.             }
  835.     firstline = thislin;
  836.     return(STINITIAL);
  837. }
  838.  
  839.  
  840. /* crunch -- deletes all space characters, folds the backslash chars and
  841.    Hollerith strings, quotes the Fortran strings */
  842.  
  843.  LOCAL void
  844. crunch()
  845. {
  846.     register char *i, *j, *j0, *j1, *prvstr;
  847.     int k, ten, nh, nh0, quote;
  848.  
  849.     /* i is the next input character to be looked at
  850.        j is the next output character */
  851.  
  852.     new_dcl = needwkey = parlev = parseen = 0;
  853.     expcom = 0;    /* exposed ','s */
  854.     expeql = 0;    /* exposed equal signs */
  855.     j = sbuf;
  856.     prvstr = sbuf;
  857.     k = 0;
  858.     for(i=sbuf ; i<=lastch ; ++i)
  859.     {
  860.         if(isspace(*i) )
  861.             continue;
  862.         if (*i == '!') {
  863.             while(i >= linestart[k])
  864.                 if (++k >= CONTMAX)
  865.                     Fatal("too many continuations\n");
  866.             j0 = linestart[k];
  867.             if (!addftnsrc)
  868.                 bang(sbuf,sbuf,sbuf,i+1,j0);
  869.             i = j0-1;
  870.             continue;
  871.             }
  872.  
  873. /* Keep everything in a quoted string */
  874.  
  875.         if(*i=='\'' ||  *i=='"')
  876.         {
  877.             int len = 0;
  878.  
  879.             quote = *i;
  880.             *j = MYQUOTE; /* special marker */
  881.             for(;;)
  882.             {
  883.                 if(++i > lastch)
  884.                 {
  885.                     err("unbalanced quotes; closing quote supplied");
  886.                     if (j >= lastch)
  887.                         j = lastch - 1;
  888.                     break;
  889.                 }
  890.                 if(*i == quote)
  891.                     if(i<lastch && i[1]==quote) ++i;
  892.                     else break;
  893.                 else if(*i=='\\' && i<lastch && use_bs) {
  894.                     ++i;
  895.                     *i = escapes[*(unsigned char *)i];
  896.                     }
  897.                 if (len + 2 < MAXTOKENLEN)
  898.                     *++j = *i;
  899.                 else if (len + 2 == MAXTOKENLEN)
  900.                     erri
  901.         ("String too long, truncating to %d chars", MAXTOKENLEN - 2);
  902.                 len++;
  903.             } /* for (;;) */
  904.  
  905.             j[1] = MYQUOTE;
  906.             j += 2;
  907.             prvstr = j;
  908.         }
  909.         else if( (*i=='h' || *i=='H')  && j>prvstr)    /* test for Hollerith strings */
  910.         {
  911.             j0 = j - 1;
  912.             if( ! isdigit(*j0)) goto copychar;
  913.             nh = *j0 - '0';
  914.             ten = 10;
  915.             j1 = prvstr;
  916.             if (j1+4 < j)
  917.                 j1 = j-4;
  918.             for(;;) {
  919.                 if (j0-- <= j1)
  920.                     goto copychar;
  921.                 if( ! isdigit(*j0 ) ) break;
  922.                 nh += ten * (*j0-'0');
  923.                 ten*=10;
  924.                 }
  925.             /* a hollerith must be preceded by a punctuation mark.
  926.    '*' is possible only as repetition factor in a data statement
  927.    not, in particular, in character*2h
  928. */
  929.  
  930.             if( !(*j0=='*'&&sbuf[0]=='d') && *j0!='/'
  931.             && *j0!='(' && *j0!=',' && *j0!='=' && *j0!='.')
  932.                 goto copychar;
  933.             nh0 = nh;
  934.             if(i+nh > lastch || nh + 2 > MAXTOKENLEN)
  935.             {
  936.                 erri("%dH too big", nh);
  937.                 nh = lastch - i;
  938.                 if (nh > MAXTOKENLEN - 2)
  939.                     nh = MAXTOKENLEN - 2;
  940.                 nh0 = -1;
  941.             }
  942.             j0[1] = MYQUOTE; /* special marker */
  943.             j = j0 + 1;
  944.             while(nh-- > 0)
  945.             {
  946.                 if (++i > lastch) {
  947.  hol_overflow:
  948.                     if (nh0 >= 0)
  949.                       erri("escapes make %dH too big",
  950.                         nh0);
  951.                     break;
  952.                     }
  953.                 if(*i == '\\' && use_bs) {
  954.                     if (++i > lastch)
  955.                         goto hol_overflow;
  956.                     *i = escapes[*(unsigned char *)i];
  957.                     }
  958.                 *++j = *i;
  959.             }
  960.             j[1] = MYQUOTE;
  961.             j+=2;
  962.             prvstr = j;
  963.         }
  964.         else    {
  965.             if(*i == '(') parseen = ++parlev;
  966.             else if(*i == ')') --parlev;
  967.             else if(parlev == 0)
  968.                 if(*i == '=') expeql = 1;
  969.                 else if(*i == ',') expcom = 1;
  970. copychar:        /*not a string or space -- copy, shifting case if necessary */
  971.             if(shiftcase && isupper(*i))
  972.                 *j++ = tolower(*i);
  973.             else    *j++ = *i;
  974.         }
  975.     }
  976.     lastch = j - 1;
  977.     nextch = sbuf;
  978. }
  979.  
  980.  LOCAL void
  981. analyz()
  982. {
  983.     register char *i;
  984.  
  985.     if(parlev != 0)
  986.     {
  987.         err("unbalanced parentheses, statement skipped");
  988.         stkey = SUNKNOWN;
  989.         lastch = sbuf - 1; /* prevent double error msg */
  990.         return;
  991.     }
  992.     if(nextch+2<=lastch && nextch[0]=='i' && nextch[1]=='f' && nextch[2]=='(')
  993.     {
  994.         /* assignment or if statement -- look at character after balancing paren */
  995.         parlev = 1;
  996.         for(i=nextch+3 ; i<=lastch; ++i)
  997.             if(*i == (MYQUOTE))
  998.             {
  999.                 while(*++i != MYQUOTE)
  1000.                     ;
  1001.             }
  1002.             else if(*i == '(')
  1003.                 ++parlev;
  1004.             else if(*i == ')')
  1005.             {
  1006.                 if(--parlev == 0)
  1007.                     break;
  1008.             }
  1009.         if(i >= lastch)
  1010.             stkey = SLOGIF;
  1011.         else if(i[1] == '=')
  1012.             stkey = SLET;
  1013.         else if( isdigit(i[1]) )
  1014.             stkey = SARITHIF;
  1015.         else    stkey = SLOGIF;
  1016.         if(stkey != SLET)
  1017.             nextch += 2;
  1018.     }
  1019.     else if(expeql) /* may be an assignment */
  1020.     {
  1021.         if(expcom && nextch<lastch &&
  1022.             nextch[0]=='d' && nextch[1]=='o')
  1023.         {
  1024.             stkey = SDO;
  1025.             nextch += 2;
  1026.         }
  1027.         else    stkey = SLET;
  1028.     }
  1029.     else if (parseen && nextch + 7 < lastch
  1030.             && nextch[2] != 'u' /* screen out "double..." early */
  1031.             && nextch[0] == 'd' && nextch[1] == 'o'
  1032.             && ((nextch[2] >= '0' && nextch[2] <= '9')
  1033.                 || nextch[2] == ','
  1034.                 || nextch[2] == 'w'))
  1035.         {
  1036.         stkey = SDO;
  1037.         nextch += 2;
  1038.         needwkey = 1;
  1039.         }
  1040.     /* otherwise search for keyword */
  1041.     else    {
  1042.         stkey = getkwd();
  1043.         if(stkey==SGOTO && lastch>=nextch)
  1044.             if(nextch[0]=='(')
  1045.                 stkey = SCOMPGOTO;
  1046.             else if(isalpha_(* USC nextch))
  1047.                 stkey = SASGOTO;
  1048.     }
  1049.     parlev = 0;
  1050. }
  1051.  
  1052.  
  1053.  
  1054.  LOCAL int
  1055. getkwd()
  1056. {
  1057.     register char *i, *j;
  1058.     register struct Keylist *pk, *pend;
  1059.     int k;
  1060.  
  1061.     if(! isalpha_(* USC nextch) )
  1062.         return(SUNKNOWN);
  1063.     k = letter(nextch[0]);
  1064.     if(pk = keystart[k])
  1065.         for(pend = keyend[k] ; pk<=pend ; ++pk )
  1066.         {
  1067.             i = pk->keyname;
  1068.             j = nextch;
  1069.             while(*++i==*++j && *i!='\0')
  1070.                 ;
  1071.             if(*i=='\0' && j<=lastch+1)
  1072.             {
  1073.                 nextch = j;
  1074.                 if(no66flag && pk->notinf66)
  1075.                     errstr("Not a Fortran 66 keyword: %s",
  1076.                         pk->keyname);
  1077.                 return(pk->keyval);
  1078.             }
  1079.         }
  1080.     return(SUNKNOWN);
  1081. }
  1082.  
  1083. initkey()
  1084. {
  1085.     register struct Keylist *p;
  1086.     register int i,j;
  1087.     register char *s;
  1088.  
  1089.     for(i = 0 ; i<26 ; ++i)
  1090.         keystart[i] = NULL;
  1091.  
  1092.     for(p = keys ; p->keyname ; ++p) {
  1093.         j = letter(p->keyname[0]);
  1094.         if(keystart[j] == NULL)
  1095.             keystart[j] = p;
  1096.         keyend[j] = p;
  1097.         }
  1098.     comstart['c'] = comstart['C'] = comstart['*'] = comstart['!'] = 1;
  1099.     s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
  1100.     while(i = *s++)
  1101.         anum_buf[i] = 1;
  1102.     s = "0123456789";
  1103.     while(i = *s++)
  1104.         anum_buf[i] = 2;
  1105.     }
  1106.  
  1107.  LOCAL int
  1108. hexcheck(key)
  1109.  int key;
  1110. {
  1111.     register int radix;
  1112.     register char *p;
  1113.     char *kind;
  1114.  
  1115.     switch(key) {
  1116.         case 'z':
  1117.         case 'Z':
  1118.         case 'x':
  1119.         case 'X':
  1120.             radix = 16;
  1121.             key = SHEXCON;
  1122.             kind = "hexadecimal";
  1123.             break;
  1124.         case 'o':
  1125.         case 'O':
  1126.             radix = 8;
  1127.             key = SOCTCON;
  1128.             kind = "octal";
  1129.             break;
  1130.         case 'b':
  1131.         case 'B':
  1132.             radix = 2;
  1133.             key = SBITCON;
  1134.             kind = "binary";
  1135.             break;
  1136.         default:
  1137.             err("bad bit identifier");
  1138.             return(SNAME);
  1139.         }
  1140.     for(p = token; *p; p++)
  1141.         if (hextoi(*p) >= radix) {
  1142.             errstr("invalid %s character", kind);
  1143.             break;
  1144.             }
  1145.     return key;
  1146.     }
  1147.  
  1148. /* gettok -- moves the right amount of text from   nextch   into the   token
  1149.    buffer.   token   initially contains garbage (leftovers from the prev token) */
  1150.  
  1151.  LOCAL int
  1152. gettok()
  1153. {
  1154. int havdot, havexp, havdbl;
  1155.     int radix, val;
  1156.     struct Punctlist *pp;
  1157.     struct Dotlist *pd;
  1158.     register int ch;
  1159.  
  1160.     char *i, *j, *n1, *p;
  1161.  
  1162.     ch = * USC nextch;
  1163.     if(ch == (MYQUOTE))
  1164.     {
  1165.         ++nextch;
  1166.         p = token;
  1167.         while(*nextch != MYQUOTE)
  1168.             *p++ = *nextch++;
  1169.         toklen = p - token;
  1170.         *p = 0;
  1171.         /* allow octal, binary, hex constants of the form 'abc'x (etc.) */
  1172.         if (++nextch <= lastch && isalpha_(val = * USC nextch)) {
  1173.             ++nextch;
  1174.             return hexcheck(val);
  1175.             }
  1176.         return (SHOLLERITH);
  1177.     }
  1178.  
  1179.     if(needkwd)
  1180.     {
  1181.         needkwd = 0;
  1182.         return( getkwd() );
  1183.     }
  1184.  
  1185.     for(pp=puncts; pp->punchar; ++pp)
  1186.         if(ch == pp->punchar) {
  1187.             val = pp->punval;
  1188.             if (++nextch <= lastch)
  1189.                 switch(ch) {
  1190.                 case '/':
  1191.                     if (*nextch == '/') {
  1192.                         nextch++;
  1193.                         val = SCONCAT;
  1194.                         }
  1195.                     else if (new_dcl && parlev == 0)
  1196.                         val = SSLASHD;
  1197.                     return val;
  1198.                 case '*':
  1199.                     if (*nextch == '*') {
  1200.                         nextch++;
  1201.                         return SPOWER;
  1202.                         }
  1203.                     break;
  1204.                 case '<':
  1205.                     if (*nextch == '=') {
  1206.                         nextch++;
  1207.                         val = SLE;
  1208.                         }
  1209.                     if (*nextch == '>') {
  1210.                         nextch++;
  1211.                         val = SNE;
  1212.                         }
  1213.                     goto extchk;
  1214.                 case '=':
  1215.                     if (*nextch == '=') {
  1216.                         nextch++;
  1217.                         val = SEQ;
  1218.                         goto extchk;
  1219.                         }
  1220.                     break;
  1221.                 case '>':
  1222.                     if (*nextch == '=') {
  1223.                         nextch++;
  1224.                         val = SGE;
  1225.                         }
  1226.  extchk:
  1227.                     NOEXT("Fortran 8x comparison operator");
  1228.                     return val;
  1229.                 }
  1230.             else if (ch == '/' && new_dcl && parlev == 0)
  1231.                 return SSLASHD;
  1232.             switch(val) {
  1233.                 case SLPAR:
  1234.                     ++parlev;
  1235.                     break;
  1236.                 case SRPAR:
  1237.                     --parlev;
  1238.                 }
  1239.             return(val);
  1240.             }
  1241.     if(ch == '.')
  1242.         if(nextch >= lastch) goto badchar;
  1243.         else if(isdigit(nextch[1])) goto numconst;
  1244.         else    {
  1245.             for(pd=dots ; (j=pd->dotname) ; ++pd)
  1246.             {
  1247.                 for(i=nextch+1 ; i<=lastch ; ++i)
  1248.                     if(*i != *j) break;
  1249.                     else if(*i != '.') ++j;
  1250.                     else    {
  1251.                         nextch = i+1;
  1252.                         return(pd->dotval);
  1253.                     }
  1254.             }
  1255.             goto badchar;
  1256.         }
  1257.     if( isalpha_(ch) )
  1258.     {
  1259.         p = token;
  1260.         *p++ = *nextch++;
  1261.         while(nextch<=lastch)
  1262.             if( isalnum_(* USC nextch) )
  1263.                 *p++ = *nextch++;
  1264.             else break;
  1265.         toklen = p - token;
  1266.         *p = 0;
  1267.         if (needwkey) {
  1268.             needwkey = 0;
  1269.             if (toklen == 5
  1270.                 && nextch <= lastch && *nextch == '(' /*)*/
  1271.                 && !strcmp(token,"while"))
  1272.             return(SWHILE);
  1273.             }
  1274.         if(inioctl && nextch<=lastch && *nextch=='=')
  1275.         {
  1276.             ++nextch;
  1277.             return(SNAMEEQ);
  1278.         }
  1279.         if(toklen>8 && eqn(8,token,"function")
  1280.         && isalpha_(* USC (token+8)) &&
  1281.             nextch<lastch && nextch[0]=='(' &&
  1282.             (nextch[1]==')' || isalpha_(* USC (nextch+1))) )
  1283.         {
  1284.             nextch -= (toklen - 8);
  1285.             return(SFUNCTION);
  1286.         }
  1287.  
  1288.         if(toklen > 50)
  1289.         {
  1290.             char buff[100];
  1291.             sprintf(buff, toklen >= 60
  1292.                 ? "name %.56s... too long, truncated to %.*s"
  1293.                 : "name %s too long, truncated to %.*s",
  1294.                 token, 50, token);
  1295.             err(buff);
  1296.             toklen = 50;
  1297.             token[50] = '\0';
  1298.         }
  1299.         if(toklen==1 && *nextch==MYQUOTE) {
  1300.             val = token[0];
  1301.             ++nextch;
  1302.             for(p = token ; *nextch!=MYQUOTE ; )
  1303.                 *p++ = *nextch++;
  1304.             ++nextch;
  1305.             toklen = p - token;
  1306.             *p = 0;
  1307.             return hexcheck(val);
  1308.         }
  1309.         return(SNAME);
  1310.     }
  1311.  
  1312.     if (isdigit(ch)) {
  1313.  
  1314.         /* Check for NAG's special hex constant */
  1315.  
  1316.         if (nextch[1] == '#'
  1317.         ||  nextch[2] == '#' && isdigit(nextch[1])) {
  1318.  
  1319.             radix = atoi (nextch);
  1320.             if (*++nextch != '#')
  1321.             nextch++;
  1322.             if (radix != 2 && radix != 8 && radix != 16) {
  1323.                 erri("invalid base %d for constant, defaulting to hex",
  1324.                 radix);
  1325.             radix = 16;
  1326.             } /* if */
  1327.             if (++nextch > lastch)
  1328.             goto badchar;
  1329.             for (p = token; hextoi(*nextch) < radix;) {
  1330.             *p++ = *nextch++;
  1331.             if (nextch > lastch)
  1332.                 break;
  1333.             }
  1334.             toklen = p - token;
  1335.             *p = 0;
  1336.             return (radix == 16) ? SHEXCON : ((radix == 8) ? SOCTCON :
  1337.                 SBITCON);
  1338.             }
  1339.         }
  1340.     else
  1341.         goto badchar;
  1342. numconst:
  1343.     havdot = NO;
  1344.     havexp = NO;
  1345.     havdbl = NO;
  1346.     for(n1 = nextch ; nextch<=lastch ; ++nextch)
  1347.     {
  1348.         if(*nextch == '.')
  1349.             if(havdot) break;
  1350.             else if(nextch+2<=lastch && isalpha_(* USC (nextch+1))
  1351.                 && isalpha_(* USC (nextch+2)))
  1352.                 break;
  1353.             else    havdot = YES;
  1354.         else if( !intonly && (*nextch=='d' || *nextch=='e') )
  1355.         {
  1356.             p = nextch;
  1357.             havexp = YES;
  1358.             if(*nextch == 'd')
  1359.                 havdbl = YES;
  1360.             if(nextch<lastch)
  1361.                 if(nextch[1]=='+' || nextch[1]=='-')
  1362.                     ++nextch;
  1363.             if( ! isdigit(*++nextch) )
  1364.             {
  1365.                 nextch = p;
  1366.                 havdbl = havexp = NO;
  1367.                 break;
  1368.             }
  1369.             for(++nextch ;
  1370.                 nextch<=lastch && isdigit(* USC nextch);
  1371.                 ++nextch);
  1372.             break;
  1373.         }
  1374.         else if( ! isdigit(* USC nextch) )
  1375.             break;
  1376.     }
  1377.     p = token;
  1378.     i = n1;
  1379.     while(i < nextch)
  1380.         *p++ = *i++;
  1381.     toklen = p - token;
  1382.     *p = 0;
  1383.     if(havdbl) return(SDCON);
  1384.     if(havdot || havexp) return(SRCON);
  1385.     return(SICON);
  1386. badchar:
  1387.     sbuf[0] = *nextch++;
  1388.     return(SUNKNOWN);
  1389. }
  1390.  
  1391. /* Comment buffering code */
  1392.  
  1393.  static void
  1394. store_comment(str)
  1395.  char *str;
  1396. {
  1397.     int len;
  1398.     comment_buf *ncb;
  1399.  
  1400.     if (nextcd == sbuf) {
  1401.         flush_comments();
  1402.         p1_comment(str);
  1403.         return;
  1404.         }
  1405.     len = strlen(str) + 1;
  1406.     if (cbnext + len > cblast) {
  1407.         if (!cbcur || !(ncb = cbcur->next)) {
  1408.             ncb = (comment_buf *) Alloc(sizeof(comment_buf));
  1409.             if (cbcur) {
  1410.                 cbcur->last = cbnext;
  1411.                 cbcur->next = ncb;
  1412.                 }
  1413.             else {
  1414.                 cbfirst = ncb;
  1415.                 cbinit = ncb->buf;
  1416.                 }
  1417.             ncb->next = 0;
  1418.             }
  1419.         cbcur = ncb;
  1420.         cbnext = ncb->buf;
  1421.         cblast = cbnext + COMMENT_BUF_STORE;
  1422.         }
  1423.     strcpy(cbnext, str);
  1424.     cbnext += len;
  1425.     }
  1426.  
  1427.  static void
  1428. flush_comments()
  1429. {
  1430.     register char *s, *s1;
  1431.     register comment_buf *cb;
  1432.     if (cbnext == cbinit)
  1433.         return;
  1434.     cbcur->last = cbnext;
  1435.     for(cb = cbfirst;; cb = cb->next) {
  1436.         for(s = cb->buf; s < cb->last; s = s1) {
  1437.             /* compute s1 = new s value first, since */
  1438.             /* p1_comment may insert nulls into s */
  1439.             s1 = s + strlen(s) + 1;
  1440.             p1_comment(s);
  1441.             }
  1442.         if (cb == cbcur)
  1443.             break;
  1444.         }
  1445.     cbcur = cbfirst;
  1446.     cbnext = cbinit;
  1447.     cblast = cbnext + COMMENT_BUF_STORE;
  1448.     }
  1449.  
  1450.  void
  1451. unclassifiable()
  1452. {
  1453.     register char *s, *se;
  1454.  
  1455.     s = sbuf;
  1456.     se = lastch;
  1457.     if (se < sbuf)
  1458.         return;
  1459.     lastch = s - 1;
  1460.     if (se - s > 10)
  1461.         se = s + 10;
  1462.     for(; s < se; s++)
  1463.         if (*s == MYQUOTE) {
  1464.             se = s;
  1465.             break;
  1466.             }
  1467.     *se = 0;
  1468.     errstr("unclassifiable statement (starts \"%s\")", sbuf);
  1469.     }
  1470.