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

##### Functions

    blankline         X
    comfree           X
    comstand          X
    contfree          X
    contstand         X
    empseek           X
    inchar            X
    labfree           X
    labstand          X
    nonblchar         X
    rdfree            X
    rdstand           X
    unchar            X
    uptolow           X

##### Variables

    unbp              X
    unbuf             X

##### Macros

    CARDSIZE          X
    maxunbp           X

       1: #ifndef lint
       2: static char sccsid[] = "@(#)1.form.c	4.1	(Berkeley)	2/11/83";
       3: #endif not lint
       4:
       5: #include <stdio.h>
       6: #include "1.defs.h"
       7: #include "def.h"
       8: extern int linechar, errflag, debug;
       9: extern int (*input)(), (*unput)();
      10:
      11:
      12:
      13: uptolow(c)      /*translates upper to lower case */
      14: int c;
      15:     {
      16:     if ('A' <= c && c <= 'Z')
      17:         return(c+'a'-'A');
      18:     else
      19:         return(c);
      20:     }
      21:
      22: rdfree(func)
      23: int (*func)();
      24:     {
      25:     int c;
      26:     while ( (c = (*input)()) != '\n')
      27:         {
      28:         (*func)(c);
      29:         }
      30:     }
      31:
      32: rdstand(func)
      33: int (*func)();
      34:     {
      35:     int c;
      36:     while ( (c=(*input)()) != '\n')
      37:         {
      38:         (*func)(c);
      39:         }
      40:     }
      41:
      42: labfree(func)           /* labels in freeform input */
      43: int (*func)();
      44:     {
      45:     int c;
      46:     int temp[6];
      47:     int j;
      48:     for (j = 0; j < 5; ++j)
      49:         {
      50:         while ( (c = (*input)()) == ' ' || c == '\t' );
      51:         if (c == '\n')
      52:             {
      53:             if (j != 0)
      54:                 {
      55:                 temp[j] = '\0';
      56:                 error("label without code - ignored:","","");
      57:                 }
      58:             }
      59:         if (c < '0' || c > '9')
      60:             {
      61:             (*unput)(c);
      62:             break;
      63:             }
      64:         else
      65:             {
      66:             temp[j] = c;
      67:             (*func)(c);
      68:             }
      69:         }
      70:     for ( ; j < 5; ++j)
      71:         (*func)(' ');
      72:     }
      73:
      74: labstand(func)          /* labels in standard form input */
      75: int (*func)();
      76:     {
      77:     int c;
      78:     int j;
      79:
      80:     for (j = 0; j < 5; ++j)
      81:         {
      82:         c = (*input)();
      83:         if (c == '\n')
      84:             {
      85:             error("line shorter than 5 characters","","");
      86:             errflag = 1;
      87:             (*unput)('\n');
      88:             }
      89:         if (c == '\t' || c == '\n')
      90:             {
      91:             for ( ;j<5; ++j)
      92:                 (*func)(' ');
      93:             return;
      94:             }
      95:         (*func)(c);
      96:         }
      97:     (*input)();         /* throw away continuation char */
      98:     }
      99:
     100:
     101:
     102: contfree()          /* identify continuation lines in free-form input */
     103:     {
     104:     return(nonblchar(_diglet,0));   /* any non-alpha non-digit */
     105:     }
     106:
     107:
     108: nonblchar(class,yesno)
     109: int class,yesno;
     110:     {
     111: #define CARDSIZE    121
     112:     int temp[CARDSIZE];
     113:     int j;
     114:     for (j=0; (temp[j]=(*input)()) == ' ' || temp[j] == '\t'; ++j)
     115:         if (j>=CARDSIZE-1)
     116:             {
     117:             temp[CARDSIZE-1] = '\0';
     118:              error ("line unexpectedly long","","");
     119:             break;
     120:             }
     121:     if (temp[j]!=EOF && classmatch(temp[j],class)==yesno)
     122:         return(1);
     123:     else
     124:         {
     125:         for ( ; j >= 0; --j)
     126:             (*unput)(temp[j]);
     127:         return(0);
     128:         }
     129:     }
     130:
     131:
     132: contstand()         /* continuation lines in standard form input */
     133:     {
     134:     int temp[6];
     135:     int i;
     136:
     137:     for (i = 0; i < 6; ++i)
     138:         {
     139:         temp[i] = (*input)();
     140:         if (temp[i] == '\t' || temp[i] == '\n' || temp[i] == '\0' || temp[i] == EOF)
     141:             {
     142:             for ( ;i >= 0; --i)
     143:                 (*unput)(temp[i]);
     144:             return(0);
     145:             }
     146:         }
     147:     if (temp[5] != '0' && temp[5] != ' ')
     148:         return(1);
     149:     else
     150:         {
     151:         for ( i = 5 ; i >= 0; --i)
     152:             (*unput)(temp[i]);
     153:         return(0);
     154:         }
     155:     }
     156:
     157:
     158:
     159: comstand(posafter)          /* standard form comments */
     160: int posafter;
     161:     {
     162:     int c;
     163:     c = (*input)();
     164:     if (!posafter)
     165:         (*unput)(c);
     166:     if (c == 'c' || c == '*' || c== '#')
     167:         return(1);
     168:     else
     169:         return(0);
     170:     }
     171:
     172:
     173: comfree(posafter)
     174: int posafter;
     175:     {
     176:     return(comstand(posafter));
     177:     }
     178: int (*rline[])()        = {rdfree,rdstand};
     179: int (*comment[])()      = {comfree,comstand};
     180: int (*getlabel[])()     = {labfree, labstand};
     181: int (*chkcont[])()      = {contfree,contstand};
     182:
     183: blankline()
     184:     {
     185:     if ( nonblchar(_nl,1) )     /* first non-blank is nl */
     186:         {
     187:         (*unput) ('\n');
     188:         return(1);
     189:         }
     190:     else return(0);
     191:     }
     192:
     193: #define maxunbp 80
     194: char unbuf[maxunbp+1];
     195: int unbp;
     196:
     197: empseek(linebeg)
     198: int linebeg;
     199:     {
     200:     unbp = 0;
     201:     if (fseek(infd,(long)(linebeg+rtnbeg),0) == -1)
     202:         faterr("in disk seek","","");
     203:     }
     204:
     205: inchar()
     206:     {
     207:     if (unbp > 0)
     208:         return( unbuf[--unbp] );
     209:     else
     210:         {
     211:         return( uptolow(getc(infd)) );
     212:         }
     213:     }
     214:
     215:
     216: unchar(c)
     217: int c;
     218:     {
     219:     if (unbp >= maxunbp)
     220:         faterr("dec.rat: unbuf size exceeded","","");
     221:     if(c!=EOF)unbuf[unbp++] = c;
     222:     }

#### Defined functions

blankline defined in line 183; used 5 times

- in /usr/src/usr.bin/struct/1.line.c line 47, 60
- in /usr/src/usr.bin/struct/4.form.c line 28, 34, 63

comfree defined in line 173; used 3 times

- in line 179
- in /usr/src/usr.bin/struct/1.line.c line 18
- in /usr/src/usr.bin/struct/4.form.c line 10

comstand defined in line 159; used 4 times

- in line 176-179(2)
- in /usr/src/usr.bin/struct/1.line.c line 19
- in /usr/src/usr.bin/struct/4.form.c line 11

contfree defined in line 102; used 3 times

- in line 181
- in /usr/src/usr.bin/struct/1.line.c line 18
- in /usr/src/usr.bin/struct/4.form.c line 10

contstand defined in line 132; used 3 times

- in line 181
- in /usr/src/usr.bin/struct/1.line.c line 19
- in /usr/src/usr.bin/struct/4.form.c line 11

empseek defined in line 197; used 3 times

- in /usr/src/usr.bin/struct/1.hash.c line 28
- in /usr/src/usr.bin/struct/4.out.c line 283, 293

inchar defined in line 205; used 2 times

- in /usr/src/usr.bin/struct/1.line.c line 86
- in /usr/src/usr.bin/struct/4.form.c line 102

labfree defined in line 42; used 3 times

- in line 180
- in /usr/src/usr.bin/struct/1.line.c line 18
- in /usr/src/usr.bin/struct/4.form.c line 10

labstand defined in line 74; used 3 times

- in line 180
- in /usr/src/usr.bin/struct/1.line.c line 19
- in /usr/src/usr.bin/struct/4.form.c line 11

nonblchar defined in line 108; used 2 times

- in line 104, 185

rdfree defined in line 22; used 3 times

- in line 178
- in /usr/src/usr.bin/struct/1.line.c line 18
- in /usr/src/usr.bin/struct/4.form.c line 10

rdstand defined in line 32; used 3 times

- in line 178
- in /usr/src/usr.bin/struct/1.line.c line 19
- in /usr/src/usr.bin/struct/4.form.c line 11

unchar defined in line 216; used 2 times

- in /usr/src/usr.bin/struct/1.line.c line 105
- in /usr/src/usr.bin/struct/4.form.c line 114

uptolow defined in line 13; used 1 times

- in line 211

#### Defined variables

sccsid defined in line 2; never used
unbp defined in line 195; used 5 times

- in line 200, 207-208(2), 219-221(2)

unbuf defined in line 194; used 2 times

- in line 208, 221

#### Defined macros

CARDSIZE defined in line 111; used 3 times

- in line 112-117(3)

maxunbp defined in line 193; used 2 times

- in line 194, 219

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 939 |