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
comfree defined in line 173; used 3 times
comstand defined in line 159; used 4 times
contfree defined in line 102; used 3 times
contstand defined in line 132; used 3 times
empseek defined in line 197; used 3 times
inchar defined in line 205; used 2 times
labfree defined in line 42; used 3 times
labstand defined in line 74; used 3 times
nonblchar defined in line 108; used 2 times
rdfree defined in line 22; used 3 times
rdstand defined in line 32; used 3 times
uptolow defined in line 13; used 1 times

Defined variables

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

Defined macros

CARDSIZE defined in line 111; used 3 times
maxunbp defined in line 193; used 2 times
Last modified: 1983-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1312
Valid CSS Valid XHTML 1.0 Strict