1: #ifndef lint
   2: static char sccsid[] = "@(#)1.line.c	4.1	(Berkeley)	2/11/83";
   3: #endif not lint
   4: 
   5: #include <stdio.h>
   6: #
   7: #include "def.h"
   8: #define bufsize 1601
   9: char buffer[bufsize];
  10: int bufcount;
  11: extern int errflag;
  12: long stchars;           /* counts number of chars at most recent \n read */
  13: #ifndef unix
  14: long ostchars;
  15: extern long ftell();
  16: #endif
  17: int newline;            /* counts number of lines read so far in file */
  18: extern int rdfree(), comfree(),labfree(), contfree();
  19: extern int rdstand(), comstand(), labstand(), contstand();
  20: extern int (*rline[])();
  21: extern int (*comment[])();
  22: extern int (*getlabel[])();
  23: extern int (*chkcont[])();
  24: 
  25: 
  26: 
  27: flush()
  28:     {bufcount = 0; }
  29: 
  30: addchar(c)
  31:     {
  32:     buffer[bufcount++] = c;
  33:     }
  34: 
  35: getline(lastline,lastchar,linecom,charcom)
  36: int *lastline, *linecom;
  37: long *lastchar, *charcom;
  38:                 /* set *lastline to number of last line of statement,
  39: 				set *lastchar to number of last char of statement,
  40: 				set *linecom to number of last line of comment preceding statement */
  41:     {
  42: 
  43:     int i;
  44:     flush();
  45:     while ( unput1(input1()) != EOF)
  46:         {
  47:         while ( (*comment[inputform])(0)  || blankline() )
  48:             {
  49:             (*rline[inputform])(addchar);
  50:             flush();
  51:             }
  52:         *linecom = newline;
  53:             /* set charcom to number of last char of comment, starting at 0
  54: 					if at start of file and no comment, will be -1  */
  55:         *charcom = stchars - 1;
  56:         if (unput1(input1()) == EOF)  break;
  57:         (*getlabel[inputform])(addchar);
  58:         (*rline[inputform])(addchar);
  59: 
  60:         while ( blankline() || ( !(*comment[inputform])(0) &&  (*chkcont[inputform])() ))
  61:             (*rline[inputform])(addchar);
  62: 
  63:         addchar('\0');
  64:         *lastline = newline;
  65:         *lastchar = stchars - 1;
  66: if (debug == 40)
  67: fprintf(stderr,"line %d; bufcount: %d\n",newline,bufcount);
  68: 
  69:         for (i = 5; i < bufcount; ++i)
  70:             if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n')
  71:                 buffer[i] = '~';
  72:         return(bufcount);
  73:         }
  74:     return(-1);
  75:     }
  76: 
  77: 
  78: int linechars;          /* counts number of chars read so far in current line */
  79: long newchar;           /* counts number of chars read so far in file */
  80: 
  81: 
  82: input1()
  83:     {
  84:     static int c;
  85:     if (c == '\n') linechars = 0;
  86:     c = inchar();
  87:     ++linechars;
  88:     ++newchar;
  89:     if (c == '\n')
  90:         {
  91:         ++newline;
  92: #ifdef unix
  93:         stchars = newchar;
  94: #else
  95:         ostchars=stchars; stchars=ftell(infd);
  96: #endif
  97:         }
  98:     return(c);
  99:     }
 100: 
 101: unput1(c)
 102:     {
 103:     --linechars;
 104:     --newchar;
 105:     unchar(c);
 106:     if (c == '\n')
 107:         {
 108: #ifdef unix
 109:         stchars = newchar;
 110: #else
 111:         stchars=ostchars;
 112: #endif
 113:         --newline;
 114:         }
 115:     return(c);
 116:     }

Defined functions

addchar defined in line 30; used 5 times
flush defined in line 27; used 2 times
getline defined in line 35; used 2 times
input1 defined in line 82; used 4 times
unput1 defined in line 101; used 4 times

Defined variables

bufcount defined in line 10; used 5 times
buffer defined in line 9; used 8 times
linechars defined in line 78; used 6 times
newchar defined in line 79; used 4 times
newline defined in line 17; used 5 times
ostchars defined in line 14; used 2 times
sccsid defined in line 2; never used
stchars defined in line 12; used 7 times

Defined macros

bufsize defined in line 8; used 1 times
  • in line 9
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1063
Valid CSS Valid XHTML 1.0 Strict