# 2.11BSD#431 - /usr/src/usr.bin/struct/1.line.c

##### Functions

    addchar           X
    flush             X
    getline           X
    input1            X
    unput1            X

##### Variables

    bufcount          X
    buffer            X
    linechars         X
    newchar           X
    newline           X
    ostchars          X
    stchars           X

##### Macros

    bufsize           X

       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

- in line 49, 57-63(4)

flush defined in line 27; used 2 times

- in line 44, 50

getline defined in line 35; used 2 times

- in /usr/src/usr.bin/struct/1.hash.c line 29, 86

input1 defined in line 82; used 4 times

- in line 45, 56
- in /usr/src/usr.bin/struct/main.c line 23, 39

unput1 defined in line 101; used 4 times

- in line 45, 56
- in /usr/src/usr.bin/struct/main.c line 23, 40

#### Defined variables

bufcount defined in line 10; used 5 times

- in line 28-32(2), 67-72(3)

buffer defined in line 9; used 8 times

- in line 32, 70-71(4)
- in /usr/src/usr.bin/struct/1.recog.c line 20(2), 231

linechars defined in line 78; used 6 times

- in line 85-87(2), 103
- in /usr/src/usr.bin/struct/4.form.c line 104-106(2), 115

newchar defined in line 79; used 4 times

- in line 88-93(2), 104-109(2)

newline defined in line 17; used 5 times

- in line 52, 64-67(2), 91, 113

ostchars defined in line 14; used 2 times

- in line 95, 111

sccsid defined in line 2; never used
stchars defined in line 12; used 7 times

- in line 55, 65, 93-95(3), 109-111(2)

#### 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: 698 |